Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(federation): Mark notifications for federated rooms read similarly #11861

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/Federation/Proxy/TalkV1/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@

namespace OCA\Talk\Federation\Proxy\TalkV1\Controller;

use OCA\Talk\Chat\Notifier;
use OCA\Talk\Exceptions\CannotReachRemoteException;
use OCA\Talk\Federation\Proxy\TalkV1\ProxyRequest;
use OCA\Talk\Federation\Proxy\TalkV1\UserConverter;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Participant;
use OCA\Talk\ResponseDefinitions;
use OCA\Talk\Room;
Expand All @@ -52,6 +54,7 @@ public function __construct(
protected UserConverter $userConverter,
protected ParticipantService $participantService,
protected RoomFormatter $roomFormatter,
protected Notifier $notifier,
ICacheFactory $cacheFactory,
) {
$this->proxyCacheMessages = $cacheFactory->isAvailable() ? $cacheFactory->createDistributed('talk/pcm/') : null;
Expand Down Expand Up @@ -139,6 +142,11 @@ public function receiveMessages(
int $markNotificationsAsRead): DataResponse {
$cacheKey = sha1(json_encode([$room->getRemoteServer(), $room->getRemoteToken()]));


if ($lookIntoFuture && $markNotificationsAsRead && $participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS) {
$this->notifier->markMentionNotificationsRead($room, $participant->getAttendee()->getActorId());
}

if ($lookIntoFuture) {
if ($this->proxyCacheMessages instanceof ICache) {
for ($i = 0; $i <= $timeout; $i++) {
Expand Down Expand Up @@ -232,6 +240,10 @@ public function getMessageContext(Room $room, Participant $participant, int $mes
],
);

if ($participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS) {
$this->notifier->markMentionNotificationsRead($room, $participant->getAttendee()->getActorId());
}

if ($proxy->getStatusCode() === Http::STATUS_NOT_MODIFIED) {
return new DataResponse([], Http::STATUS_NOT_MODIFIED);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Notification/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected function markInvitationRead(Room $room, IUser $user): void {
* Reaction: "{user} reacted with {reaction} in {call}"
*
* We should not mark reactions read based on the read-status of the comment
* they apply to, but the point in time when the reaction as done.
* they apply to, but the point in time when the reaction was done.
* However, these messages are not visible and don't update the read marker,
* so we purge them on joining the conversation.
* This already happened before on the initial loading of a chat with
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/features/federation/chat.feature
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ Feature: federation/chat
| spreed | chat | room/Hi @all bye | participant1-displayname mentioned everyone in conversation room | Hi room bye |
| spreed | chat | room/Hi @"federated_user/participant2@{$REMOTE_URL}" bye | participant1-displayname mentioned you in conversation room | Hi @participant2-displayname bye |
| spreed | chat | room/Message 1-1 | participant1-displayname replied to your message in conversation room | Message 1-1 |
When next message request has the following parameters set
| timeout | 0 |
| lookIntoFuture | 1 |
| lastKnownMessageId | Hi @all bye |
And user "participant2" sees the following messages in room "LOCAL::room" with 304
Then user "participant2" has the following notifications
| app | object_type | object_id | subject | message |

Scenario: Mentioning a federated user as a guest also triggers a notification for them
Given the following "spreed" app config is set
Expand Down
Loading