summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2022-08-25 13:44:44 +0200
committerGitHub <noreply@github.com>2022-08-25 13:44:44 +0200
commit986af98255b2d55527a5cab20694f6095d1f4193 (patch)
tree086f5944601bb4e7cd425bb36efd7ceb4427691f /lib
parente7ff7d563132a99ea50b2c724154148dc56048da (diff)
parenta275c1cfdd99e9f955038a1f6ada6ef92b0ec7c3 (diff)
Merge pull request #7788 from nextcloud/bugfix/7775/fix-notifications-when-lobby-is-active
Fix notifications when lobby is active
Diffstat (limited to 'lib')
-rw-r--r--lib/Chat/Notifier.php8
-rw-r--r--lib/Notification/Notifier.php15
-rw-r--r--lib/Service/ParticipantService.php22
3 files changed, 45 insertions, 0 deletions
diff --git a/lib/Chat/Notifier.php b/lib/Chat/Notifier.php
index 3f048c056..56f668252 100644
--- a/lib/Chat/Notifier.php
+++ b/lib/Chat/Notifier.php
@@ -32,6 +32,7 @@ use OCA\Talk\Model\Session;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
+use OCA\Talk\Webinary;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Comments\IComment;
use OCP\IConfig;
@@ -450,6 +451,13 @@ class Notifier {
$participant = $room->getParticipant($userId, false);
$attendee = $participant->getAttendee();
+ } else {
+ $participant = new Participant($room, $attendee, null);
+ }
+
+ if ($room->getLobbyState() !== Webinary::LOBBY_NONE &&
+ !($participant->getPermissions() & Attendee::PERMISSIONS_LOBBY_IGNORE)) {
+ return false;
}
$notificationLevel = $attendee->getNotificationLevel();
diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php
index 77dbcfaf5..a369ae016 100644
--- a/lib/Notification/Notifier.php
+++ b/lib/Notification/Notifier.php
@@ -37,6 +37,7 @@ use OCA\Talk\Model\Attendee;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
+use OCA\Talk\Webinary;
use OCP\Comments\ICommentsManager;
use OCP\Comments\NotFoundException;
use OCP\HintException;
@@ -247,12 +248,26 @@ class Notifier implements INotifier {
return $this->parseInvitation($notification, $room, $l);
}
if ($subject === 'call') {
+ if ($room->getLobbyState() !== Webinary::LOBBY_NONE &&
+ $participant instanceof Participant &&
+ !($participant->getPermissions() & Attendee::PERMISSIONS_LOBBY_IGNORE)) {
+ // User is blocked by the lobby, remove notification
+ throw new AlreadyProcessedException();
+ }
+
if ($room->getObjectType() === 'share:password') {
return $this->parsePasswordRequest($notification, $room, $l);
}
return $this->parseCall($notification, $room, $l);
}
if ($subject === 'reply' || $subject === 'mention' || $subject === 'chat' || $subject === 'reaction') {
+ if ($room->getLobbyState() !== Webinary::LOBBY_NONE &&
+ $participant instanceof Participant &&
+ !($participant->getPermissions() & Attendee::PERMISSIONS_LOBBY_IGNORE)) {
+ // User is blocked by the lobby, remove notification
+ throw new AlreadyProcessedException();
+ }
+
return $this->parseChatMessage($notification, $room, $participant, $l);
}
diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php
index 9742c2805..2cbc21f94 100644
--- a/lib/Service/ParticipantService.php
+++ b/lib/Service/ParticipantService.php
@@ -1340,6 +1340,28 @@ class ParticipantService {
->andWhere($query->expr()->eq('a.notification_calls', $query->createNamedParameter(Participant::NOTIFY_CALLS_ON)))
->andWhere($query->expr()->isNull('s.in_call'));
+ if ($room->getLobbyState() !== Webinary::LOBBY_NONE) {
+ // Filter out non-moderators and users without lobby permissions
+ $query->andWhere(
+ $query->expr()->orX(
+ $query->expr()->in('a.participant_type', $query->createNamedParameter(
+ [Participant::MODERATOR, Participant::OWNER],
+ IQueryBuilder::PARAM_INT_ARRAY
+ )),
+ $query->expr()->eq(
+ $query->expr()->castColumn(
+ $query->expr()->bitwiseAnd(
+ 'permissions',
+ Attendee::PERMISSIONS_LOBBY_IGNORE
+ ),
+ IQueryBuilder::PARAM_INT
+ ),
+ $query->createNamedParameter(Attendee::PERMISSIONS_LOBBY_IGNORE, IQueryBuilder::PARAM_INT)
+ )
+ )
+ );
+ }
+
$userIds = [];
$result = $query->executeQuery();
while ($row = $result->fetch()) {