From 70035f204345b09305fbb487208708e69bd79a53 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Thu, 29 Jul 2021 21:59:03 +0200 Subject: Formatting --- lib/room.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/room.h b/lib/room.h index cdbfe58f..a1cb6261 100644 --- a/lib/room.h +++ b/lib/room.h @@ -181,12 +181,10 @@ public: QString name() const; /// Room aliases defined on the current user's server /// \sa remoteAliases, setLocalAliases - [[deprecated("Use aliases()")]] - QStringList localAliases() const; + [[deprecated("Use aliases()")]] QStringList localAliases() const; /// Room aliases defined on other servers /// \sa localAliases - [[deprecated("Use aliases()")]] - QStringList remoteAliases() const; + [[deprecated("Use aliases()")]] QStringList remoteAliases() const; QString canonicalAlias() const; QStringList altAliases() const; QStringList aliases() const; @@ -271,7 +269,8 @@ public: */ Q_INVOKABLE QString roomMembername(const Quotient::User* u) const; /*! - * \brief Get a disambiguated name for a user with this id in the room context + * \brief Get a disambiguated name for a user with this id in the room + * context * * \deprecated use safeMemberName() instead */ @@ -339,9 +338,13 @@ public: const char* relType) const; const RoomCreateEvent* creation() const - { return getCurrentState(); } + { + return getCurrentState(); + } const RoomTombstoneEvent* tombstone() const - { return getCurrentState(); } + { + return getCurrentState(); + } bool displayed() const; /// Mark the room as currently displayed to the user -- cgit v1.2.3 From e0d9125de7ac132c2a54152015687abbe5e73193 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Fri, 30 Jul 2021 08:10:48 +0200 Subject: Room: drop 0.6 deprecations; deprecate RoomAliasEvent Namely memberCount(), localAliases(), remoteAliases(), timelineEdge(). --- lib/events/simplestateevents.h | 6 ++++-- lib/room.cpp | 30 +++++------------------------- lib/room.h | 14 ++------------ 3 files changed, 11 insertions(+), 39 deletions(-) (limited to 'lib') diff --git a/lib/events/simplestateevents.h b/lib/events/simplestateevents.h index d6261a8f..3bac54e6 100644 --- a/lib/events/simplestateevents.h +++ b/lib/events/simplestateevents.h @@ -56,8 +56,10 @@ namespace EventContent { DEFINE_SIMPLE_STATE_EVENT(RoomNameEvent, "m.room.name", QString, name) DEFINE_SIMPLE_STATE_EVENT(RoomTopicEvent, "m.room.topic", QString, topic) -class RoomAliasesEvent - : public StateEvent> { +class [[deprecated( + "m.room.aliases events are deprecated by the Matrix spec; use" + " RoomCanonicalAliasEvent::altAliases() to get non-authoritative aliases")]] // +RoomAliasesEvent : public StateEvent> { public: DEFINE_EVENT_TYPEID("m.room.aliases", RoomAliasesEvent) explicit RoomAliasesEvent(const QJsonObject& obj) diff --git a/lib/room.cpp b/lib/room.cpp index 10e827d7..f223e0b9 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -540,21 +540,6 @@ QStringList Room::altAliases() const return d->getCurrentState()->altAliases(); } -QStringList Room::localAliases() const -{ - return d->getCurrentState( - connection()->domain()) - ->aliases(); -} - -QStringList Room::remoteAliases() const -{ - QStringList result; - for (const auto& s : std::as_const(d->aliasServers)) - result += d->getCurrentState(s)->aliases(); - return result; -} - QString Room::canonicalAlias() const { return d->getCurrentState()->alias(); @@ -793,8 +778,6 @@ Room::Timeline::const_iterator Room::syncEdge() const return d->timeline.cend(); } -Room::rev_iter_t Room::timelineEdge() const { return historyEdge(); } - TimelineItem::index_t Room::minTimelineIndex() const { return d->timeline.empty() ? 0 : d->timeline.front().index(); @@ -813,7 +796,7 @@ bool Room::isValidIndex(TimelineItem::index_t timelineIndex) const Room::rev_iter_t Room::findInTimeline(TimelineItem::index_t index) const { - return timelineEdge() + return historyEdge() - (isValidIndex(index) ? index - minTimelineIndex() + 1 : 0); } @@ -1279,8 +1262,6 @@ QStringList Room::htmlSafeMemberNames() const return res; } -int Room::memberCount() const { return d->membersMap.size(); } - int Room::timelineSize() const { return int(d->timeline.size()); } bool Room::usesEncryption() const @@ -2153,8 +2134,7 @@ RoomEventPtr makeRedacted(const RoomEvent& target, { QStringLiteral("ban"), QStringLiteral("events"), QStringLiteral("events_default"), QStringLiteral("kick"), QStringLiteral("redact"), QStringLiteral("state_default"), - QStringLiteral("users"), QStringLiteral("users_default") } }, - { RoomAliasesEvent::typeId(), { QStringLiteral("aliases") } } + QStringLiteral("users"), QStringLiteral("users_default") } } // , { RoomJoinRules::typeId(), { QStringLiteral("join_rule") } } // , { RoomHistoryVisibility::typeId(), // { QStringLiteral("history_visibility") } } @@ -2743,7 +2723,7 @@ Room::Changes Room::processEphemeralEvent(EventPtr&& event) << p.receipts.size() << "users"; } const auto newMarker = findInTimeline(p.evtId); - if (newMarker != timelineEdge()) { + if (newMarker != historyEdge()) { for (const Receipt& r : p.receipts) { if (r.userId == connection()->userId()) continue; // FIXME, #185 @@ -2763,7 +2743,7 @@ Room::Changes Room::processEphemeralEvent(EventPtr&& event) continue; // FIXME, #185 auto u = user(r.userId); if (memberJoinState(u) == JoinState::Join - && readMarker(u) == timelineEdge()) + && readMarker(u) == historyEdge()) changes |= d->setLastReadEvent(u, p.evtId); } } @@ -2791,7 +2771,7 @@ Room::Changes Room::processAccountDataEvent(EventPtr&& event) qCDebug(STATE) << "Server-side read marker at" << readEventId; d->serverReadMarker = readEventId; const auto newMarker = findInTimeline(readEventId); - changes |= newMarker != timelineEdge() + changes |= newMarker != historyEdge() ? d->markMessagesAsRead(newMarker) : d->setLastReadEvent(localUser(), readEventId); } diff --git a/lib/room.h b/lib/room.h index a1cb6261..0ab18ef7 100644 --- a/lib/room.h +++ b/lib/room.h @@ -93,7 +93,6 @@ class Room : public QObject { Q_PROPERTY(int timelineSize READ timelineSize NOTIFY addedMessages) Q_PROPERTY(QStringList memberNames READ safeMemberNames NOTIFY memberListChanged) - Q_PROPERTY(int memberCount READ memberCount NOTIFY memberListChanged) Q_PROPERTY(int joinedCount READ joinedCount NOTIFY memberListChanged) Q_PROPERTY(int invitedCount READ invitedCount NOTIFY memberListChanged) Q_PROPERTY(int totalMemberCount READ totalMemberCount NOTIFY memberListChanged) @@ -179,14 +178,9 @@ public: Room* successor(JoinStates statesFilter = JoinState::Invite | JoinState::Join) const; QString name() const; - /// Room aliases defined on the current user's server - /// \sa remoteAliases, setLocalAliases - [[deprecated("Use aliases()")]] QStringList localAliases() const; - /// Room aliases defined on other servers - /// \sa localAliases - [[deprecated("Use aliases()")]] QStringList remoteAliases() const; QString canonicalAlias() const; QStringList altAliases() const; + //! Get a list of both canonical and alternative aliases QStringList aliases() const; QString displayName() const; QString topic() const; @@ -202,8 +196,6 @@ public: QStringList memberNames() const; QStringList safeMemberNames() const; QStringList htmlSafeMemberNames() const; - [[deprecated("Use joinedCount(), invitedCount(), totalMemberCount()")]] - int memberCount() const; int timelineSize() const; bool usesEncryption() const; RoomEventPtr decryptMessage(const EncryptedEvent& encryptedEvent); @@ -320,8 +312,6 @@ public: * arrived event; same as messageEvents().cend() */ Timeline::const_iterator syncEdge() const; - /// \deprecated Use historyEdge instead - rev_iter_t timelineEdge() const; Q_INVOKABLE Quotient::TimelineItem::index_t minTimelineIndex() const; Q_INVOKABLE Quotient::TimelineItem::index_t maxTimelineIndex() const; Q_INVOKABLE bool @@ -387,7 +377,7 @@ public: * events (non-redacted message events from users other than local) * are counted. * - * In a case when readMarker() == timelineEdge() (the local read + * In a case when readMarker() == historyEdge() (the local read * marker is beyond the local timeline) only the bottom limit of * the unread messages number can be estimated (and even that may * be slightly off due to, e.g., redactions of events not loaded -- cgit v1.2.3 From 02eac9e9ff573d85677f900288e82473f5296ee3 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Fri, 30 Jul 2021 08:12:09 +0200 Subject: Use a better type in makeRedacted --- lib/room.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/room.cpp b/lib/room.cpp index f223e0b9..47a0ec94 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -2127,7 +2127,7 @@ RoomEventPtr makeRedacted(const RoomEvent& target, QStringLiteral("membership") }; // clang-format on - std::vector> keepContentKeysMap { + static const std::pair keepContentKeysMap[] { { RoomMemberEvent::typeId(), { QStringLiteral("membership") } }, { RoomCreateEvent::typeId(), { QStringLiteral("creator") } }, { RoomPowerLevelsEvent::typeId(), @@ -2146,9 +2146,9 @@ RoomEventPtr makeRedacted(const RoomEvent& target, ++it; } auto keepContentKeys = - find_if(keepContentKeysMap.begin(), keepContentKeysMap.end(), + find_if(begin(keepContentKeysMap), end(keepContentKeysMap), [&target](const auto& t) { return target.type() == t.first; }); - if (keepContentKeys == keepContentKeysMap.end()) { + if (keepContentKeys == end(keepContentKeysMap)) { originalJson.remove(ContentKeyL); originalJson.remove(PrevContentKeyL); } else { -- cgit v1.2.3 From 7ee1681d7640b7e7683f7bb40bf768704a48832c Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Fri, 30 Jul 2021 08:22:13 +0200 Subject: Clean up after the previous commit RoomAliasesEvent is no more even registered (meaning that the library will load m.room.aliases as unknown state events); quotest code updated to use historyEdge() instead of timelineEdge(). --- lib/events/simplestateevents.h | 1 - quotest/quotest.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/events/simplestateevents.h b/lib/events/simplestateevents.h index 3bac54e6..cf1bfbba 100644 --- a/lib/events/simplestateevents.h +++ b/lib/events/simplestateevents.h @@ -72,5 +72,4 @@ public: QString server() const { return stateKey(); } QStringList aliases() const { return content().value; } }; -REGISTER_EVENT_TYPE(RoomAliasesEvent) } // namespace Quotient diff --git a/quotest/quotest.cpp b/quotest/quotest.cpp index 5646d54d..ec7d4dcb 100644 --- a/quotest/quotest.cpp +++ b/quotest/quotest.cpp @@ -557,7 +557,7 @@ bool TestSuite::checkRedactionOutcome(const QByteArray& thisTest, // redacted at the next sync, or the nearest sync completes with // the unredacted event but the next one brings redaction. auto it = targetRoom->findInTimeline(evtIdToRedact); - if (it == targetRoom->timelineEdge()) + if (it == targetRoom->historyEdge()) return false; // Waiting for the next sync if ((*it)->isRedacted()) { -- cgit v1.2.3