Skip to content

fix(conversations): system messages won't bump activity in room / thread order anymore#17977

Open
sudormant wants to merge 10 commits into
nextcloud:mainfrom
sudormant:main
Open

fix(conversations): system messages won't bump activity in room / thread order anymore#17977
sudormant wants to merge 10 commits into
nextcloud:mainfrom
sudormant:main

Conversation

@sudormant
Copy link
Copy Markdown

☑️ Resolves

AI (if applicable)

  • The content of this PR was partly or fully generated using AI
    -> none used

UI

  • this only changes backend behavior but nothing in the ui / client side

🛠️ API Checklist

Test Plan

  • behavior of chat messages is unchanged
  • adding and removing users, promoting and demoting users in rooms works as before
  • chat messages still trigger activity bumps
  • system messages are still shown in the client, but don't trigger activity bumps and conversations reorderings

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not possible
  • 📘 API documentation in docs/ has been updated or is not required
  • 🔖 Capability is added or not needed

This Pull request solves the issue in #11882:
Currently, system messages like user_added, user_removed, moderator_promoted, moderator_demoted bumped activity / reordered the room / thread list on each update.
With these changes, system messages are still signaled to the client, but won't bump the activity anymore.
This also introduces a differentiation between lastActivity and a new attribute lastMetadaActivity. lastActivity will still be updated on new chat messages, all other state changes like participant list will only change lastMetadataActivity. Later on this can be useful to handle different kinds of events independently on the backend.
The API to the frontend remains unchanged and there are no changes necessary client-side.

I tested it in my local development setup, @nickvergessen please review & check if the changes now reflect the desired behavior or if we need further changes. Thanks!

sudormant added 5 commits May 13, 2026 00:00
…ctivity flag for event dispatcher from false to true. This should help with chat state changes (users removed / added, moderators promoted / demoted) from triggering a reordering in the room list in Nextcloud Talk.

Signed-off-by: Christian Lorang <madcatcl2@gmx.de>
…tMetadaActivity for Rooms and Threads, similar to lastActivity. This also adds a database migration for the oc_talk_rooms and oc_talk_threads tables as well. Functions are introduced and prepared for later use. The use of the field lastActivity to signal when the last real message in a conversation appeared remains unchanged to keep the API stable. The intended use of this feature is to better distinguish between real messages (lastActivity) to notify and bump conversations in the thread list to the top, and other status / metadata related messages (lastMetadataActivity) like room state and participant list changes that shall get synced and be updated in the clients, but not trigger an activity bump of its conversations in the thread list.

Signed-off-by: Christian Lorang <madcatcl2@gmx.de>
…t will still go by last message activity, after introducing lastMetadataActivity, and not sort by last metadata changes in rooms like participant list updates.

Signed-off-by: Christian Lorang <madcatcl2@gmx.de>
…oms and Threads to use / set lastMetadataActivity instaed of lastActivity where appropriate, i.e. where system messages are signalled and not real chat messages.

Signed-off-by: Christian Lorang <madcatcl2@gmx.de>
: system messages like user added or removed, moderator promoted or demoted trigger an activity bump of the conversation in the list and move it to the top. This fix keeps activity bumps for real chat messages but won't bump the activity anymore for the aforementioned system messages. This fix also incorporates use of the new lastMetadataActivity field to update this information instead of lastActivity accordingly and can be expanded later on to handle other kind of messages differently. No changes client side are needed.

Signed-off-by: Christian Lorang <madcatcl2@gmx.de>
@nickvergessen nickvergessen added this to the 🏖️ Next Beta (34) milestone May 13, 2026
@nickvergessen nickvergessen self-assigned this May 13, 2026
@nickvergessen nickvergessen added bug feature: chat 💬 Chat and system messages feature: api 🛠️ OCS API for conversations, chats and participants feature: conversations 👥 labels May 13, 2026
@nickvergessen nickvergessen self-requested a review May 13, 2026 06:00
Copy link
Copy Markdown
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't (with a quick look) see an issue with the thread handling at the moment. So in terms of separation of concern, I would simply skip that for now to keep the scope of the PR smaller.
If there is a similar/further issue with threads in the same way, feel free to outline steps, I tried editing, deleting a message and doing a reaction, but nothing bumped the thread unexpectingly?

Comment thread lib/Migration/Version24000Date20260510193300.php Outdated
Comment thread lib/ResponseDefinitions.php
if (isset($host['lastMetadataActivity']) && $host['lastMetadataActivity'] !== 0 && $host['lastMetadataActivity'] !== ((int)$local->getLastMetadataActivity()?->getTimestamp())) {
$lastMetadataActivity = $this->timeFactory->getDateTime('@' . $host['lastMetadataActivity']);
$this->setLastMetadataActivity($local, $lastMetadataActivity);
$changed[] = ARoomSyncEvent::PROPERTY_LAST_METADATA_ACTIVITY;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would need handling in OCA\Talk\Federation\CloudFederationProviderTalk

Comment thread lib/Chat/SystemMessage/Listener.php Outdated
}

protected function attendeesAddedEvent(AttendeesAddedEvent $event): void {
$event->shouldSkipLastMessageUpdate = true;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A parallel PR made this read-only and private, so I guess we need to drop read-only and add a setter

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I committed another change to use getter / setters in this place.
I removed readonly also but kept it private, so this should now be compatible to the other pull request?

sudormant and others added 5 commits May 17, 2026 21:02
Signed-off-by: Christian Lorang <madcatcl2@gmx.de>
…s only to rooms, remove same handling from threads

Signed-off-by: Christian Lorang <madcatcl2@gmx.de>
…ssageUpdate to be compatible with another pull request making this field private

Signed-off-by: Christian Lorang <madcatcl2@gmx.de>
…e (like room creation) when deciding whether to bump activity

Signed-off-by: Christian Lorang <madcatcl2@gmx.de>
Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
Signed-off-by: sudormant <madcatcl2@gmx.de>
@sudormant
Copy link
Copy Markdown
Author

I don't (with a quick look) see an issue with the thread handling at the moment. So in terms of separation of concern, I would simply skip that for now to keep the scope of the PR smaller. If there is a similar/further issue with threads in the same way, feel free to outline steps, I tried editing, deleting a message and doing a reaction, but nothing bumped the thread unexpectingly?

Yes, there were no problems with the activity handling in Threads or federated Threads. I had found it prudent to adapt all areas using lastActivity markers to handle the new split situation with lastActivity and lastMetadataactivity to keep the code and behavior going forward consistent.
But you're right, for this simple fix concerning room activity bumping, I removed these parts for Threads and kept them for Rooms only.

When testing my changes removing the aforementioned parts for Threads I also caught a regression and added another commit for it: $event doesn't have getLastMessage for all event types, e.g. room creation, and handled it for now.

Comment on lines +50 to +53
* @param bool $pShouldSkipLastActivity
*/
public function setShouldSkipLastActivityUpdate(bool $pShouldSkipLastActivity) {
$this->$skipLastActivityUpdate = $pShouldSkipLastactivity;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param bool $pShouldSkipLastActivity
*/
public function setShouldSkipLastActivityUpdate(bool $pShouldSkipLastActivity) {
$this->$skipLastActivityUpdate = $pShouldSkipLastactivity;
*/
public function setShouldSkipLastActivityUpdate(bool $shouldSkipLastActivity) {
$this->skipLastActivityUpdate = $shouldSkipLastActivity;

Comment on lines +33 to +34
public function setShouldSkipLastActivityUpdate(bool $pShouldSkipLastActivityUpdate) {
$this->shouldSkipLastMessageUpdate = $pShouldSkipLastActivityUpdate;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function setShouldSkipLastActivityUpdate(bool $pShouldSkipLastActivityUpdate) {
$this->shouldSkipLastMessageUpdate = $pShouldSkipLastActivityUpdate;
public function setShouldSkipLastMessageUpdate(bool $shouldSkipLastMessageUpdate) {
$this->shouldSkipLastMessageUpdate = $shouldSkipLastMessageUpdate;

array $parameters = [],
?Participant $participant = null,
bool $shouldSkipLastMessageUpdate = false,
bool $shouldSkipLastMessageUpdate = true,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we keep this we need to check all the calls in this file. E.g. currently posting a file does not update the last message anymore.
Other cases where I would still bump would be: lobby_none, lobby_timer_reached, breakout_rooms_started, breakout_rooms_stopped, call_left, call_joined, call_started, setCallRecording

Comment on lines +732 to +733
* // UNIX timestamp of the last metadata, not message, activity in the thread
* lastMetadataActivity: int
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you reverted the thread change by now, so this sould be reverted as well

$thread->setId($threadId);
$thread->setName($title);
$thread->setRoomId($room->getId());
$thread->setLastActivity($this->timeFactory->getDateTime());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs restoring

// getLastMessage doesn't exist for all event types, e.g. room creation
if (($event->getLastMessage() ?? null) !== null) {
$lastMessage = $event->getLastMessage();
// TODO: is there any better getter / way to access message type?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole logic is "local" to the event. so it only contains last messages of adding users and can be applied/skipped unconditionally.

@github-actions
Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug feature: api 🛠️ OCS API for conversations, chats and participants feature: chat 💬 Chat and system messages feature: conversations 👥 feedback-requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Order in the chat overview is messed up when a new user is added

2 participants