aboutsummaryrefslogtreecommitdiff
path: root/lib/room.cpp
AgeCommit message (Collapse)Author
2021-09-08Room: actually initialise read marker when neededAlexey Rusakov
This fixes the `q->readMarker() != historyEdge()` assertion failure occuring in recalculateUnreadCount() when new events from sync arrive to a room with no read marker and all history loaded.
2021-08-01Room::setDisplayed(): Don't reset unread countersAlexey Rusakov
Closes #489.
2021-08-01Room::toJson(): save the last local user's read receiptAlexey Rusakov
Read receipts are entangled with counting unread messages, and saving them also helps in not sending receipts for too old events. Other users' read receipts are still treated as truly ephemeral.
2021-08-01Enhanced logging for read receiptsAlexey Rusakov
2021-08-01SyncRoomData: distinguish between omitted and 0 unread countersAlexey Rusakov
This is a more conservative but less idiomatic.readable fix for entirely missing notification_count/highlight_count. In reality, Synapse seems to always send them; but that is not required by The Spec.
2021-07-25Room: update cache state if needed after loading historyAlexey Rusakov
For now this is to update saved unread counts.
2021-07-24Room::setLastDisplayedEventId: Update local read receipt immediatelyAlexey Rusakov
There is no harm in updating it locally, as read receipts are only supposed to move forwards; if an update from another client of the same user arrives the next millisecond, it will only be incorporated if it points to an even newer event (exactly as would be expected). In any case, read receipts are more for others than for yourself.
2021-07-24Fix unread counter left intact after loading backscrollAlexey Rusakov
Another regression after the read receipts/markers rework, most prominently seen when a room has "0+" unread messages and the first historical batch gets loaded.
2021-07-24Room::Private::sync/historyEdge()Alexey Rusakov
Move Room::sync/historyEdge() implementation to Room::Private, so that internal logic could use the same readable shortcuts without q-> prefixes, instead of timeline.crend() and timeline.cend() that are much less readable.
2021-07-20Promote read receipts/marker in addNewMessageEvents()Alexey Rusakov
Read marker promotion worked before the rework - and it works again with this commit. Read receipts are promoted from anywhere, the fully read marker is only promoted if it's adjacent to the batch just added.
2021-07-19addHistoricalMessageEvents(): restore force-recount logicAlexey Rusakov
Pre-e12d7ba2, addHistoricalMessageEvents() triggered recounting and emitting unreadMessagesChanged() even if the number remained the same. This logic has been lost when refactoring the code; now it's back there again.
2021-07-19Fix m.read getting stuck behind m.fully_readAlexey Rusakov
2021-07-10Fix Room::processAccountDataEvent() return valueAlexey Rusakov
2021-07-10Room: refactoring around logging (esp. profile logs)Alexey Rusakov
2021-07-10Room: fix the read markers/receipts confusionAlexey Rusakov
This turns the design changes laid out in #464 comments to code: - readMarker() now returns the fully read marker, unlike readMarker(User*) that returns a read receipt, even when called for the local user. - Private::setLastReadEvent() -> setLastReadReceipt(), incorporating the "promotion" logic from promoteReadReceipt(). - The above makes promoteReadReceipt() unneeded; the remaining piece of logic that recalculates the number of unread messages is put to its own method - Private::recalculateUnreadCount(). - Private::updateUnreadCount() is only slightly refreshed, continues to use the fully read marker position (as it used to). - Now that read receipts and fully read markers are managed separately, Private::setLastReadReceipt() has got its counterpart, Private::setFullyReadMarker(); both only update their respective markers locally (emitting signals as needed), without interaction with the homeserver. - Private::markMessagesAsRead() now delegates updating the fully read marker to setFullyReadMarker() and on top of that sends the new fully read marker to the homeserver. - Private::serverReadMarker -> fullyReadUntilEventId (to be really clear what it stores). - The hand-written PostReadMarkersJob is replaced with the generated SetReadMarkerJob that does the same thing (and can update the read receipt on top, though the current code doesn't use that).
2021-07-02Room::memberJoinState(): return Leave if user == nullptrAlexey Rusakov
2021-06-27Room::processEphemeralEvents(): refactoringAlexey Rusakov
2021-03-04Tighten up against malformed user ids in eventsAlexey Rusakov
A few months ago 3c85f049 introduced validation of user ids but the rest of the library code wasn't updated to the fact that Connection::user() may quite legitimately (if not routinely) return nullptr, leading to crashes particularaly when malformed ids come from the wire. This commit adds necessary checks before using the value returned from user(). Closes #456.
2020-12-28Cleanup and clang-tidy/clazy fixesKitsune Ral
(cherry picked from commit 56c1db077b5da653c230432abc6c746318a77bed)
2020-12-24Room: don't accept . at 0-th position in the tagKitsune Ral
Also: use a structured binding for better code readability.
2020-12-24Fix clang-tidy/clazy warningsKitsune Ral
2020-12-03Room: fix breakage in internal member mapKitsune Ral
The change in 39830496 led to prev_content becoming a fallback not only for displaying user names but also for storing them in the internal member map, which is really not what was intended.
2020-11-19Fix Q_ASSERT failure on sending messagesKitsune Ral
Changes in e81117fb exposed a flaw in EncryptionEvent causing assertion failure when this event is default-initialised (i.e. no encryption).
2020-11-15Room: add power level events to redaction rulesKitsune Ral
2020-11-15Room::P::getCurrentState<>(): bypass the factory chainKitsune Ral
This is to optimize a rather hot path creating stub events (for member events in bigger rooms, in particular) when the event type is known. Version 0.7 will have a completely different code based on event content rather than event that will obviate stubs creation but 0.6.x can benefit from it.
2020-11-09Room: be more robust in Release modeKitsune Ral
...in one particular case, when trying to add a user to a room it's already a member of.
2020-09-04More fixing of clazy warningsKitsune Ral
2020-09-03Address clazy warningsKitsune Ral
2020-08-22Cleanup and some extra commentsKitsune Ral
2020-08-04User: optimise names/avatars storing and updatingKitsune Ral
The current mechanism relied on a complicated and fragile machinery around setNameForRoom() and setAvatarForRoom() that maintained the "most used" entity for a given user along with "other" ones. Given that per-room avatars are pretty rare in Matrix, it's also been inefficient as commit c69f100e shows. The new mechanism stores the "default" (as per user profile) name and avatar and maintains a singleton map of avatar objects across all users. Per-user profile only (normally) exists for the local user so there's yet another inefficiency - this will be fixed in 0.7 by introducing a special class for a user profile.
2020-08-04Room: various minor tweaks and fixesKitsune Ral
2020-07-24Room: send read receipts in a background requestKitsune Ral
Sending them in the foreground causes Quaternion to throw scary messages when read receipts don't go through while that's actually not a big deal. Also, network traffic deprioritisation.
2020-07-23Room::P::isEventNotable(): edits are not notableKitsune Ral
Edits are (normally) applied to some other event up the timeline, therefore not displayed. Having [1] in unread counts while seeing nothing in the timeline is quite confusing.
2020-06-20Room: PostReadMarkersJob should be in backgroundKitsune Ral
...meaning - errors from it should not throw up at a user, who has no clue (they still should go to logs for investigation).
2020-06-19Fix FTBFS and warnings with E2EE switched onKitsune Ral
2020-06-10Room: fix messageSent() being emitted too earlyKitsune Ral
Closes #406.
2020-06-05Avoid Qt 5.15 deprecation warningKitsune Ral
operator+() is no more wanted with iterators on associative containers.
2020-05-31room.cpp: clean away unused variablesKitsune Ral
2020-04-14Room: emit updatedEvent() on un-reactionKitsune Ral
2020-04-12Room::safeMemberName()Kitsune Ral
Pulled from Quaternion code.
2020-04-12Room::canSwitchVersions(): refactor and make Q_INVOKABLEKitsune Ral
2020-04-07Room::addNewMessageEvents: fix an assertion failure on empty senderKitsune Ral
When a message is redacted it has no sender. If it happens to be in the bulkhead, Quotient tries to promote a read marker over it and fails on being unable to resolve the author.
2020-03-26Refactoring around Connection::onSyncSuccess()Kitsune Ral
The method grew large and a bit unwieldy over the years.
2020-03-26Room::aliases(): don't add canonical alias if it's emptyKitsune Ral
Fixes #394.
2020-03-21Merge pull request #383 from ram-nad/msc2432-fixKitsune Ral
fixing msc2432
2020-03-21Update aliases code lib/room.cppRam Nad
Co-Authored-By: Kitsune Ral <Kitsune-Ral@users.sf.net>
2020-03-20emit nameChanged() on AliasesChangeRam Nad
2020-03-20dont use thisRam Nad
2020-03-20added altAliases()Ram Nad
2020-03-20made suggested changesRam Nad