Skip to content

Commit

Permalink
fix(archive): Don't send notifications for default calls and at-all m…
Browse files Browse the repository at this point in the history
…entions

Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Sep 20, 2024
1 parent f8fef7d commit e5d37de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/Chat/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ public function notifyMentionedUsers(Room $chat, IComment $comment, array $alrea
$shouldFlush = $this->notificationManager->defer();
}


foreach ($usersToNotify as $mentionedUser) {
if ($this->shouldMentionedUserBeNotified($mentionedUser['id'], $comment, $chat, $mentionedUser['attendee'] ?? null)) {
if ($this->shouldMentionedUserBeNotified($mentionedUser['id'], $comment, $chat, $mentionedUser['attendee'] ?? null, $mentionedUser['reason'])) {
if (!$silent) {
$notification->setUser($mentionedUser['id']);
if (isset($mentionedUser['reason'])) {
Expand Down Expand Up @@ -210,7 +209,7 @@ public function notifyReplyToAuthor(Room $chat, IComment $comment, IComment $rep
];
}

if (!$this->shouldMentionedUserBeNotified($replyTo->getActorId(), $comment, $chat)) {
if (!$this->shouldMentionedUserBeNotified($replyTo->getActorId(), $comment, $chat, null, 'reply')) {
return [];
}

Expand Down Expand Up @@ -565,14 +564,8 @@ protected function getDefaultGroupNotification(): int {
* 2. The user must exist
* 3. The user must be a participant of the room
* 4. The user must not be active in the room
*
* @param string $userId
* @param IComment $comment
* @param Room $room
* @param Attendee|null $attendee
* @return bool
*/
protected function shouldMentionedUserBeNotified(string $userId, IComment $comment, Room $room, ?Attendee $attendee = null): bool {
protected function shouldMentionedUserBeNotified(string $userId, IComment $comment, Room $room, ?Attendee $attendee, string $reason): bool {
if ($comment->getActorType() === Attendee::ACTOR_USERS && $userId === $comment->getActorId()) {
// Do not notify the user if they mentioned themselves
return false;
Expand All @@ -590,6 +583,10 @@ protected function shouldMentionedUserBeNotified(string $userId, IComment $comme
$participant = new Participant($room, $attendee, null);
}

if ($reason === 'all' && $attendee->isArchived()) {
return false;
}

if ($room->getLobbyState() !== Webinary::LOBBY_NONE &&
!($participant->getPermissions() & Attendee::PERMISSIONS_LOBBY_IGNORE)) {
return false;
Expand Down
1 change: 1 addition & 0 deletions lib/Service/ParticipantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,7 @@ public function getParticipantUserIdsForCallNotifications(Room $room): array {
->where($query->expr()->eq('a.room_id', $query->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->eq('a.actor_type', $query->createNamedParameter(Attendee::ACTOR_USERS)))
->andWhere($query->expr()->eq('a.notification_calls', $query->createNamedParameter(Participant::NOTIFY_CALLS_ON)))
->andWhere($query->expr()->eq('a.archived', $query->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
->andWhere($query->expr()->isNull('s.in_call'));

if ($room->getLobbyState() !== Webinary::LOBBY_NONE) {
Expand Down

0 comments on commit e5d37de

Please sign in to comment.