diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2021-07-30 19:32:25 +0200 |
---|---|---|
committer | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2021-07-30 19:32:25 +0200 |
commit | a2e8575f8b843eb9534c42b9c2864923a0329119 (patch) | |
tree | d35fc9648e19d4c2b39ea96c851e48dad5beb179 | |
parent | 62c829cc8de8a870c08926c41331f2766e766f37 (diff) | |
parent | 7ee1681d7640b7e7683f7bb40bf768704a48832c (diff) | |
download | libquotient-a2e8575f8b843eb9534c42b9c2864923a0329119.tar.gz libquotient-a2e8575f8b843eb9534c42b9c2864923a0329119.zip |
Merge branch 'master' into kitsune-fix-read-receipts-and-markers
-rw-r--r-- | .clang-format | 1 | ||||
-rw-r--r-- | lib/events/simplestateevents.h | 7 | ||||
-rw-r--r-- | lib/room.cpp | 30 | ||||
-rw-r--r-- | lib/room.h | 27 | ||||
-rw-r--r-- | quotest/quotest.cpp | 2 |
5 files changed, 21 insertions, 46 deletions
diff --git a/.clang-format b/.clang-format index 3eafee44..6e13223e 100644 --- a/.clang-format +++ b/.clang-format @@ -133,6 +133,7 @@ Standard: c++17 StatementMacros: - Q_UNUSED - QT_REQUIRE_VERSION + - DEFINE_EVENT_TYPEID TabWidth: 4 #UseCRLF: false #UseTab: Never diff --git a/lib/events/simplestateevents.h b/lib/events/simplestateevents.h index d6261a8f..cf1bfbba 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<EventContent::SimpleContent<QStringList>> { +class [[deprecated( + "m.room.aliases events are deprecated by the Matrix spec; use" + " RoomCanonicalAliasEvent::altAliases() to get non-authoritative aliases")]] // +RoomAliasesEvent : public StateEvent<EventContent::SimpleContent<QStringList>> { public: DEFINE_EVENT_TYPEID("m.room.aliases", RoomAliasesEvent) explicit RoomAliasesEvent(const QJsonObject& obj) @@ -70,5 +72,4 @@ public: QString server() const { return stateKey(); } QStringList aliases() const { return content().value; } }; -REGISTER_EVENT_TYPE(RoomAliasesEvent) } // namespace Quotient diff --git a/lib/room.cpp b/lib/room.cpp index 9a571127..c7f29b6d 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -541,21 +541,6 @@ QStringList Room::altAliases() const return d->getCurrentState<RoomCanonicalAliasEvent>()->altAliases(); } -QStringList Room::localAliases() const -{ - return d->getCurrentState<RoomAliasesEvent>( - connection()->domain()) - ->aliases(); -} - -QStringList Room::remoteAliases() const -{ - QStringList result; - for (const auto& s : std::as_const(d->aliasServers)) - result += d->getCurrentState<RoomAliasesEvent>(s)->aliases(); - return result; -} - QString Room::canonicalAlias() const { return d->getCurrentState<RoomCanonicalAliasEvent>()->alias(); @@ -829,8 +814,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(); @@ -849,7 +832,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); } @@ -1324,8 +1307,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 @@ -2191,15 +2172,14 @@ RoomEventPtr makeRedacted(const RoomEvent& target, QStringLiteral("membership") }; // clang-format on - std::vector<std::pair<event_type_t, QStringList>> keepContentKeysMap { + static const std::pair<event_type_t, QStringList> keepContentKeysMap[] { { RoomMemberEvent::typeId(), { QStringLiteral("membership") } }, { RoomCreateEvent::typeId(), { QStringLiteral("creator") } }, { RoomPowerLevelsEvent::typeId(), { 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") } } @@ -2211,9 +2191,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 { @@ -115,7 +115,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) @@ -203,16 +202,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; @@ -228,8 +220,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); @@ -295,7 +285,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 */ @@ -345,8 +336,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 @@ -363,9 +352,13 @@ public: const char* relType) const; const RoomCreateEvent* creation() const - { return getCurrentState<RoomCreateEvent>(); } + { + return getCurrentState<RoomCreateEvent>(); + } const RoomTombstoneEvent* tombstone() const - { return getCurrentState<RoomTombstoneEvent>(); } + { + return getCurrentState<RoomTombstoneEvent>(); + } bool displayed() const; /// Mark the room as currently displayed to the user @@ -417,7 +410,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 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()) { |