From 10b65b78fa8265dbeeb33e755fafcd642b21b514 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Tue, 11 Apr 2023 00:11:46 +0200 Subject: [PATCH] Adapt to the new inherited variant --- CMakeLists.txt | 2 +- io.github.NhekoReborn.Nheko.yaml | 2 +- src/Cache.cpp | 50 ++++++++++++---------------- src/Cache_p.h | 10 +++--- src/ChatPage.cpp | 17 +++++----- src/EventAccessors.cpp | 2 +- src/Utils.cpp | 8 ++--- src/Utils.h | 9 +++-- src/encryption/Olm.cpp | 8 ++--- src/timeline/EventStore.cpp | 38 ++++++++++----------- src/timeline/EventStore.h | 12 +++---- src/timeline/InputBar.cpp | 2 +- src/timeline/TimelineModel.cpp | 39 +++++++++++----------- src/timeline/TimelineModel.h | 2 +- src/timeline/TimelineViewManager.cpp | 2 +- src/timeline/TimelineViewManager.h | 2 +- 16 files changed, 99 insertions(+), 106 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20fcb029..62db167f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -602,7 +602,7 @@ if(USE_BUNDLED_MTXCLIENT) FetchContent_Declare( MatrixClient GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git - GIT_TAG dd2bdbd104ae8f70f82da9ff7b4b60007fc105c3 + GIT_TAG e136bc27b28d3bb5683735eb5a65d6ef2534ca3a ) set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "") set(BUILD_LIB_TESTS OFF CACHE INTERNAL "") diff --git a/io.github.NhekoReborn.Nheko.yaml b/io.github.NhekoReborn.Nheko.yaml index 97d0b770..d45dba3d 100644 --- a/io.github.NhekoReborn.Nheko.yaml +++ b/io.github.NhekoReborn.Nheko.yaml @@ -213,7 +213,7 @@ modules: buildsystem: cmake-ninja name: mtxclient sources: - - commit: dd2bdbd104ae8f70f82da9ff7b4b60007fc105c3 + - commit: e136bc27b28d3bb5683735eb5a65d6ef2534ca3a #tag: v0.9.2 type: git url: https://github.com/Nheko-Reborn/mtxclient.git diff --git a/src/Cache.cpp b/src/Cache.cpp index 329be386..b0b50004 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -1284,9 +1284,8 @@ Cache::runMigrations() else if (j["token"].get() != oldMessages.prev_batch) break; - mtx::events::collections::TimelineEvent te; - from_json(j["event"], te); - oldMessages.events.push_back(te.data); + oldMessages.events.push_back( + j["event"].get()); } // messages were stored in reverse order, so we // need to reverse them @@ -2398,15 +2397,13 @@ Cache::getTimelineMessages(lmdb::txn &txn, const std::string &room_id, uint64_t if (!success) continue; - mtx::events::collections::TimelineEvent te; try { - from_json(nlohmann::json::parse(event), te); + messages.timeline.events.push_back( + nlohmann::json::parse(event).get()); } catch (std::exception &e) { nhlog::db()->error("Failed to parse message from cache {}", e.what()); continue; } - - messages.timeline.events.push_back(std::move(te.data)); } cursor.close(); @@ -2417,7 +2414,7 @@ Cache::getTimelineMessages(lmdb::txn &txn, const std::string &room_id, uint64_t return messages; } -std::optional +std::optional Cache::getEvent(const std::string &room_id, std::string_view event_id) { auto txn = ro_txn(env_); @@ -2428,24 +2425,21 @@ Cache::getEvent(const std::string &room_id, std::string_view event_id) if (!success) return {}; - mtx::events::collections::TimelineEvent te; try { - from_json(nlohmann::json::parse(event), te); + return nlohmann::json::parse(event).get(); } catch (std::exception &e) { nhlog::db()->error("Failed to parse message from cache {}", e.what()); return std::nullopt; } - - return te; } void Cache::storeEvent(const std::string &room_id, const std::string &event_id, - const mtx::events::collections::TimelineEvent &event) + const mtx::events::collections::TimelineEvents &event) { auto txn = lmdb::txn::begin(env_); auto eventsDb = getEventsDb(txn, room_id); - auto event_json = mtx::accessors::serialize_event(event.data); + auto event_json = mtx::accessors::serialize_event(event); eventsDb.put(txn, event_id, event_json.dump()); txn.commit(); } @@ -2453,17 +2447,17 @@ Cache::storeEvent(const std::string &room_id, void Cache::replaceEvent(const std::string &room_id, const std::string &event_id, - const mtx::events::collections::TimelineEvent &event) + const mtx::events::collections::TimelineEvents &event) { auto txn = lmdb::txn::begin(env_); auto eventsDb = getEventsDb(txn, room_id); auto relationsDb = getRelationsDb(txn, room_id); - auto event_json = mtx::accessors::serialize_event(event.data).dump(); + auto event_json = mtx::accessors::serialize_event(event).dump(); { eventsDb.del(txn, event_id); eventsDb.put(txn, event_id, event_json); - for (const auto &relation : mtx::accessors::relations(event.data).relations) { + for (const auto &relation : mtx::accessors::relations(event).relations) { relationsDb.put(txn, relation.event_id, event_id); } } @@ -3430,19 +3424,19 @@ Cache::isRoomMember(const std::string &user_id, const std::string &room_id) void Cache::savePendingMessage(const std::string &room_id, - const mtx::events::collections::TimelineEvent &message) + const mtx::events::collections::TimelineEvents &message) { auto txn = lmdb::txn::begin(env_); auto eventsDb = getEventsDb(txn, room_id); mtx::responses::Timeline timeline; - timeline.events.push_back(message.data); + timeline.events.push_back(message); saveTimelineMessages(txn, eventsDb, room_id, timeline); auto pending = getPendingMessagesDb(txn, room_id); int64_t now = QDateTime::currentMSecsSinceEpoch(); - pending.put(txn, lmdb::to_sv(now), mtx::accessors::event_id(message.data)); + pending.put(txn, lmdb::to_sv(now), mtx::accessors::event_id(message)); txn.commit(); } @@ -3469,7 +3463,7 @@ Cache::pendingEvents(const std::string &room_id) return related_ids; } -std::optional +std::optional Cache::firstPendingMessage(const std::string &room_id) { auto txn = lmdb::txn::begin(env_); @@ -3487,8 +3481,8 @@ Cache::firstPendingMessage(const std::string &room_id) } try { - mtx::events::collections::TimelineEvent te; - from_json(nlohmann::json::parse(event), te); + mtx::events::collections::TimelineEvents te = + nlohmann::json::parse(event).get(); pendingCursor.close(); return te; @@ -3622,10 +3616,10 @@ Cache::saveTimelineMessages(lmdb::txn &txn, if (!success) continue; - mtx::events::collections::TimelineEvent te; try { - from_json(nlohmann::json::parse(std::string_view(oldEvent.data(), oldEvent.size())), - te); + auto te = nlohmann::json::parse(std::string_view(oldEvent.data(), oldEvent.size())) + .get(); + // overwrite the content and add redation data std::visit( [&redaction, &room_id, &txn, &eventsDb, this](auto &ev) { @@ -3652,8 +3646,8 @@ Cache::saveTimelineMessages(lmdb::txn &txn, mtx::events::collections::StateEvents{redactedEvent}); } }, - te.data); - event = mtx::accessors::serialize_event(te.data); + te); + event = mtx::accessors::serialize_event(te); event["content"].clear(); } catch (std::exception &e) { diff --git a/src/Cache_p.h b/src/Cache_p.h index cc016d4b..7acb483f 100644 --- a/src/Cache_p.h +++ b/src/Cache_p.h @@ -193,14 +193,14 @@ public: uint64_t index = std::numeric_limits::max(), bool forward = false); - std::optional + std::optional getEvent(const std::string &room_id, std::string_view event_id); void storeEvent(const std::string &room_id, const std::string &event_id, - const mtx::events::collections::TimelineEvent &event); + const mtx::events::collections::TimelineEvents &event); void replaceEvent(const std::string &room_id, const std::string &event_id, - const mtx::events::collections::TimelineEvent &event); + const mtx::events::collections::TimelineEvents &event); std::vector relatedEvents(const std::string &room_id, const std::string &event_id); struct TimelineRange @@ -219,9 +219,9 @@ public: std::string previousBatchToken(const std::string &room_id); uint64_t saveOldMessages(const std::string &room_id, const mtx::responses::Messages &res); void savePendingMessage(const std::string &room_id, - const mtx::events::collections::TimelineEvent &message); + const mtx::events::collections::TimelineEvents &message); std::vector pendingEvents(const std::string &room_id); - std::optional + std::optional firstPendingMessage(const std::string &room_id); void removePendingStatus(const std::string &room_id, const std::string &txn_id); diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index b5c8d3b4..4e0d373c 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -270,7 +270,7 @@ ChatPage::ChatPage(QSharedPointer userSettings, QObject *parent) auto ctx = roomModel->pushrulesRoomContext(); std::vector< - std::pair> + std::pair> relatedEvents; for (const auto &event : room.timeline.events) { @@ -286,9 +286,9 @@ ChatPage::ChatPage(QSharedPointer userSettings, QObject *parent) if (sender == http::client()->user_id().to_string()) continue; - mtx::events::collections::TimelineEvent te{event}; + mtx::events::collections::TimelineEvents te{event}; std::visit([room_id = room_id](auto &event_) { event_.room_id = room_id; }, - te.data); + te); if (auto encryptedEvent = std::get_if>( @@ -298,23 +298,24 @@ ChatPage::ChatPage(QSharedPointer userSettings, QObject *parent) auto result = olm::decryptEvent(index, *encryptedEvent); if (result.event) - te.data = result.event.value(); + te = std::move(result.event).value(); } relatedEvents.clear(); - for (const auto &r : mtx::accessors::relations(te.data).relations) { + for (const auto &r : mtx::accessors::relations(te).relations) { auto related = cache::client()->getEvent(room_id, r.event_id); if (related) { relatedEvents.emplace_back(r, *related); if (auto encryptedEvent = std::get_if< mtx::events::EncryptedEvent>( - &related->data); + &related.value()); encryptedEvent && userSettings_->decryptNotifications()) { MegolmSessionIndex index(room_id, encryptedEvent->content); auto result = olm::decryptEvent(index, *encryptedEvent); if (result.event) - relatedEvents.back().second.data = result.event.value(); + relatedEvents.back().second = + std::move(result.event).value(); } } } @@ -343,7 +344,7 @@ ChatPage::ChatPage(QSharedPointer userSettings, QObject *parent) notificationsManager->postNotification( mtx::responses::Notification{ .actions = actions, - .event = te.data, + .event = std::move(te), .read = false, .profile_tag = "", .room_id = room_id, diff --git a/src/EventAccessors.cpp b/src/EventAccessors.cpp index 888baf5a..62969ed1 100644 --- a/src/EventAccessors.cpp +++ b/src/EventAccessors.cpp @@ -461,7 +461,7 @@ mtx::accessors::media_width(const mtx::events::collections::TimelineEvents &even nlohmann::json mtx::accessors::serialize_event(const mtx::events::collections::TimelineEvents &event) { - return std::visit([](const auto &e) { return nlohmann::json(e); }, event); + return nlohmann::json(event); } bool diff --git a/src/Utils.cpp b/src/Utils.cpp index 2bf8eb3b..c9a6fb55 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -37,8 +37,6 @@ #include "UserSettingsPage.h" #include "timeline/Permissions.h" -using TimelineEvent = mtx::events::collections::TimelineEvents; - template static DescInfo createDescriptionInfo(const Event &event, const QString &localUser, const QString &displayName) @@ -89,7 +87,9 @@ utils::stripReplyFromFormattedBody(const std::string &formatted_bodyi) } RelatedInfo -utils::stripReplyFallbacks(const TimelineEvent &event, std::string id, QString room_id_) +utils::stripReplyFallbacks(const mtx::events::collections::TimelineEvents &event, + std::string id, + QString room_id_) { RelatedInfo related = {}; related.quoted_user = QString::fromStdString(mtx::accessors::sender(event)); @@ -211,7 +211,7 @@ utils::descriptiveTime(const QDateTime &then) } DescInfo -utils::getMessageDescription(const TimelineEvent &event, +utils::getMessageDescription(const mtx::events::collections::TimelineEvents &event, const QString &localUser, const QString &displayName) { diff --git a/src/Utils.h b/src/Utils.h index 2c8988e5..af5ea340 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -39,9 +39,6 @@ struct RelatedInfo }; namespace utils { - -using TimelineEvent = mtx::events::collections::TimelineEvents; - //! Helper function to remove reply fallback from body std::string stripReplyFromBody(const std::string &body); @@ -51,7 +48,9 @@ std::string stripReplyFromFormattedBody(const std::string &formatted_body); RelatedInfo -stripReplyFallbacks(const TimelineEvent &event, std::string id, QString room_id_); +stripReplyFallbacks(const mtx::events::collections::TimelineEvents &event, + std::string id, + QString room_id_); bool codepointIsEmoji(uint code); @@ -75,7 +74,7 @@ descriptiveTime(const QDateTime &then); //! Generate a message description from the event to be displayed //! in the RoomList. DescInfo -getMessageDescription(const TimelineEvent &event, +getMessageDescription(const mtx::events::collections::TimelineEvents &event, const QString &localUser, const QString &displayName); diff --git a/src/encryption/Olm.cpp b/src/encryption/Olm.cpp index cde8db96..733ce94f 100644 --- a/src/encryption/Olm.cpp +++ b/src/encryption/Olm.cpp @@ -1273,13 +1273,13 @@ decryptEvent(const MegolmSessionIndex &index, body["origin_server_ts"] = event.origin_server_ts; body["unsigned"] = event.unsigned_data; - mtx::events::collections::TimelineEvent te; - from_json(body, te); + mtx::events::collections::TimelineEvents te = + body.get(); // relations are unencrypted in content... - mtx::accessors::set_relations(te.data, std::move(event.content.relations)); + mtx::accessors::set_relations(te, std::move(event.content.relations)); - return {DecryptionErrorCode::NoError, std::nullopt, std::move(te.data)}; + return {DecryptionErrorCode::NoError, std::nullopt, std::move(te)}; } catch (std::exception &e) { return {DecryptionErrorCode::ParsingFailed, e.what(), std::nullopt}; } diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp index 5aa105b0..84b6dcd4 100644 --- a/src/timeline/EventStore.cpp +++ b/src/timeline/EventStore.cpp @@ -155,7 +155,7 @@ EventStore::EventStore(std::string room_id, QObject *) } }); }, - event->data); + event.value()); }); connect( @@ -195,20 +195,20 @@ EventStore::EventStore(std::string room_id, QObject *) mtx::events::EncryptedEvent original_encrypted; if (auto encrypted = std::get_if>( - &pending_event->data)) { + &pending_event.value())) { auto d_event = decryptEvent({room_id_, encrypted->event_id}, *encrypted); if (d_event->event) { - was_encrypted = true; - original_encrypted = *encrypted; - pending_event->data = *d_event->event; + was_encrypted = true; + original_encrypted = std::move(*encrypted); + *pending_event = std::move(*d_event->event); } } - auto relations = mtx::accessors::relations(pending_event->data); + auto relations = mtx::accessors::relations(pending_event.value()); // Replace the blockquote in fallback reply auto related_text = std::get_if>( - &pending_event->data); + &pending_event.value()); if (related_text && relations.reply_to() == txn_id) { size_t index = related_text->content.formatted_body.find(txn_id); if (index != std::string::npos) { @@ -228,7 +228,7 @@ EventStore::EventStore(std::string room_id, QObject *) if (!replaced_txn) continue; - mtx::accessors::set_relations(pending_event->data, std::move(relations)); + mtx::accessors::set_relations(pending_event.value(), std::move(relations)); // reencrypt. This is a bit of a hack and might make people able to read the // message, that were in the room at the time of sending the last pending message. @@ -246,7 +246,7 @@ EventStore::EventStore(std::string room_id, QObject *) {"content", nlohmann::json(msg.content)}, {"room_id", room_id_}}; }, - pending_event->data); + pending_event.value()); auto data = olm::encrypt_group_message_with_session( session.session, http::client()->device_id(), std::move(doc)); @@ -255,8 +255,8 @@ EventStore::EventStore(std::string room_id, QObject *) olm_outbound_group_session_message_index(session.session.get()); cache::updateOutboundMegolmSession(room_id_, session.data, session.session); - original_encrypted.content = data; - pending_event->data = original_encrypted; + original_encrypted.content = std::move(data); + *pending_event = std::move(original_encrypted); } cache::client()->replaceEvent(room_id_, pending_event_id, *pending_event); @@ -629,7 +629,7 @@ EventStore::reactions(const std::string &event_id) return temp; } -mtx::events::collections::TimelineEvents * +mtx::events::collections::TimelineEvents const * EventStore::get(int idx, bool decrypt) { if (this->thread() != QThread::currentThread()) @@ -645,17 +645,17 @@ EventStore::get(int idx, bool decrypt) if (!event_id) return nullptr; - std::optional event; + std::optional event; auto edits_ = edits(*event_id); if (edits_.empty()) event = cache::client()->getEvent(room_id_, *event_id); else - event = mtx::events::collections::TimelineEvent{edits_.back()}; + event = mtx::events::collections::TimelineEvents{edits_.back()}; if (!event) return nullptr; else - event_ptr = new mtx::events::collections::TimelineEvents(std::move(event->data)); + event_ptr = new mtx::events::collections::TimelineEvents(std::move(*event)); events_.insert(index, event_ptr); } @@ -692,7 +692,7 @@ EventStore::indexToId(int idx) const return cache::client()->getTimelineEventId(room_id_, toInternalIdx(idx)); } -olm::DecryptionResult * +olm::DecryptionResult const * EventStore::decryptEvent(const IdIndex &idx, const mtx::events::EncryptedEvent &e) { @@ -813,7 +813,7 @@ EventStore::enableKeyRequests(bool suppressKeyRequests_) suppressKeyRequests = true; } -mtx::events::collections::TimelineEvents * +mtx::events::collections::TimelineEvents const * EventStore::get(const std::string &id, std::string_view related_to, bool decrypt, @@ -856,7 +856,7 @@ EventStore::get(const std::string &id, }); return nullptr; } - event_ptr = new mtx::events::collections::TimelineEvents(std::move(event->data)); + event_ptr = new mtx::events::collections::TimelineEvents(std::move(*event)); events_by_id_.insert(index, event_ptr); } @@ -895,7 +895,7 @@ EventStore::decryptionError(std::string id) if (!event) { return olm::DecryptionErrorCode::NoError; } - event_ptr = new mtx::events::collections::TimelineEvents(std::move(event->data)); + event_ptr = new mtx::events::collections::TimelineEvents(std::move(*event)); events_by_id_.insert(index, event_ptr); } diff --git a/src/timeline/EventStore.h b/src/timeline/EventStore.h index 5018ffbf..bf905fc6 100644 --- a/src/timeline/EventStore.h +++ b/src/timeline/EventStore.h @@ -73,12 +73,12 @@ public: // optionally returns the event or nullptr and fetches it, after which it emits a // relatedFetched event - mtx::events::collections::TimelineEvents *get(const std::string &id, - std::string_view related_to, - bool decrypt = true, - bool resolve_edits = true); + mtx::events::collections::TimelineEvents const *get(const std::string &id, + std::string_view related_to, + bool decrypt = true, + bool resolve_edits = true); // always returns a proper event as long as the idx is valid - mtx::events::collections::TimelineEvents *get(int idx, bool decrypt = true); + mtx::events::collections::TimelineEvents const *get(int idx, bool decrypt = true); QVariantList reactions(const std::string &event_id); std::vector edits(const std::string &event_id); @@ -126,7 +126,7 @@ public slots: void enableKeyRequests(bool suppressKeyRequests_); private: - olm::DecryptionResult * + olm::DecryptionResult const * decryptEvent(const IdIndex &idx, const mtx::events::EncryptedEvent &e); diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp index fe8b8e48..879ec7cc 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp @@ -53,7 +53,7 @@ threadFallbackEventId(const std::string &room_id, const std::string &thread_id) for (const auto &[index, event_id] : orderedEvents) { (void)index; if (auto event = cache::client()->getEvent(room_id, event_id)) { - if (mtx::accessors::relations(event->data).thread() == thread_id) + if (mtx::accessors::relations(event.value()).thread() == thread_id) return std::string(event_id); } } diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 918d1c0b..f80f2ee9 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -776,13 +776,12 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r return qml_mtx_events::NotificationLevel::Nothing; const auto &id = event_id(event); - std::vector> + std::vector> relatedEvents; for (const auto &r : mtx::accessors::relations(event).relations) { auto related = events.get(r.event_id, id); if (related) { - relatedEvents.emplace_back(r, - mtx::events::collections::TimelineEvent{*related}); + relatedEvents.emplace_back(r, *related); } } @@ -1790,7 +1789,7 @@ TimelineModel::openMedia(const QString &eventId) bool TimelineModel::saveMedia(const QString &eventId) const { - mtx::events::collections::TimelineEvents *event = events.get(eventId.toStdString(), ""); + auto event = events.get(eventId.toStdString(), ""); if (!event) return false; @@ -1865,7 +1864,7 @@ void TimelineModel::cacheMedia(const QString &eventId, const std::function &callback) { - mtx::events::collections::TimelineEvents *event = events.get(eventId.toStdString(), ""); + auto event = events.get(eventId.toStdString(), ""); if (!event) return; @@ -2150,7 +2149,7 @@ TimelineModel::formatTypingUsers(const std::vector &users, const QColor QString TimelineModel::formatJoinRuleEvent(const QString &id) { - mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), ""); + auto e = events.get(id.toStdString(), ""); if (!e) return {}; @@ -2187,7 +2186,7 @@ TimelineModel::formatJoinRuleEvent(const QString &id) QString TimelineModel::formatGuestAccessEvent(const QString &id) { - mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), ""); + auto e = events.get(id.toStdString(), ""); if (!e) return {}; @@ -2211,7 +2210,7 @@ TimelineModel::formatGuestAccessEvent(const QString &id) QString TimelineModel::formatHistoryVisibilityEvent(const QString &id) { - mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), ""); + auto e = events.get(id.toStdString(), ""); if (!e) return {}; @@ -2243,7 +2242,7 @@ TimelineModel::formatHistoryVisibilityEvent(const QString &id) QString TimelineModel::formatPowerLevelEvent(const QString &id) { - mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), ""); + auto e = events.get(id.toStdString(), ""); if (!e) return {}; @@ -2251,7 +2250,7 @@ TimelineModel::formatPowerLevelEvent(const QString &id) if (!event) return QString(); - mtx::events::StateEvent *prevEvent = nullptr; + mtx::events::StateEvent const *prevEvent = nullptr; if (!event->unsigned_data.replaces_state.empty()) { auto tempPrevEvent = events.get(event->unsigned_data.replaces_state, event->event_id); if (tempPrevEvent) { @@ -2519,7 +2518,7 @@ TimelineModel::formatPowerLevelEvent(const QString &id) QString TimelineModel::formatImagePackEvent(const QString &id) { - mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), ""); + auto e = events.get(id.toStdString(), ""); if (!e) return {}; @@ -2527,7 +2526,7 @@ TimelineModel::formatImagePackEvent(const QString &id) if (!event) return {}; - mtx::events::StateEvent *prevEvent = nullptr; + mtx::events::StateEvent const *prevEvent = nullptr; if (!event->unsigned_data.replaces_state.empty()) { auto tempPrevEvent = events.get(event->unsigned_data.replaces_state, event->event_id); if (tempPrevEvent) { @@ -2591,8 +2590,8 @@ TimelineModel::formatImagePackEvent(const QString &id) QString TimelineModel::formatPolicyRule(const QString &id) { - auto idStr = id.toStdString(); - mtx::events::collections::TimelineEvents *e = events.get(idStr, ""); + auto idStr = id.toStdString(); + auto e = events.get(idStr, ""); if (!e) return {}; @@ -2683,7 +2682,7 @@ QVariantMap TimelineModel::formatRedactedEvent(const QString &id) { QVariantMap pair{{"first", ""}, {"second", ""}}; - mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), ""); + auto e = events.get(id.toStdString(), ""); if (!e) return pair; @@ -2720,7 +2719,7 @@ TimelineModel::formatRedactedEvent(const QString &id) void TimelineModel::acceptKnock(const QString &id) { - mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), ""); + auto e = events.get(id.toStdString(), ""); if (!e) return; @@ -2745,7 +2744,7 @@ TimelineModel::acceptKnock(const QString &id) bool TimelineModel::showAcceptKnockButton(const QString &id) { - mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), ""); + auto e = events.get(id.toStdString(), ""); if (!e) return false; @@ -2766,7 +2765,7 @@ TimelineModel::showAcceptKnockButton(const QString &id) void TimelineModel::joinReplacementRoom(const QString &id) { - mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), ""); + auto e = events.get(id.toStdString(), ""); if (!e) return; @@ -2792,7 +2791,7 @@ TimelineModel::joinReplacementRoom(const QString &id) QString TimelineModel::formatMemberEvent(const QString &id) { - mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), ""); + auto e = events.get(id.toStdString(), ""); if (!e) return {}; @@ -2800,7 +2799,7 @@ TimelineModel::formatMemberEvent(const QString &id) if (!event) return {}; - mtx::events::StateEvent *prevEvent = nullptr; + mtx::events::StateEvent const *prevEvent = nullptr; if (!event->unsigned_data.replaces_state.empty()) { auto tempPrevEvent = events.get(event->unsigned_data.replaces_state, event->event_id); if (tempPrevEvent) { diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index ef845bb5..0244c1b1 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -483,7 +483,7 @@ signals: void isDirectChanged(); void directChatOtherUserIdChanged(); void permissionsChanged(); - void forwardToRoom(mtx::events::collections::TimelineEvents *e, QString roomId); + void forwardToRoom(mtx::events::collections::TimelineEvents const *e, QString roomId); void scrollTargetChanged(); diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index c19d0c3f..b949e4c3 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -461,7 +461,7 @@ TimelineViewManager::completerFor(const QString &completerName, const QString &r } void -TimelineViewManager::forwardMessageToRoom(mtx::events::collections::TimelineEvents *e, +TimelineViewManager::forwardMessageToRoom(mtx::events::collections::TimelineEvents const *e, QString roomId) { auto room = rooms_->getRoomById(roomId); diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index 089b2e1f..ee5cf031 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -113,7 +113,7 @@ public slots: QObject *completerFor(const QString &completerName, const QString &roomId = QLatin1String(QLatin1String(""))); - void forwardMessageToRoom(mtx::events::collections::TimelineEvents *e, QString roomId); + void forwardMessageToRoom(mtx::events::collections::TimelineEvents const *e, QString roomId); RoomlistModel *rooms() { return rooms_; }