Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-03-02 16:20:47 +0300
committerJoas Schilling <coding@schilljs.com>2022-03-08 14:11:06 +0300
commitb78ce0709a8493d61746b6690b43f07b5f564d3b (patch)
treead8aa89d29d82b44150889c59146671e5d24c439
parentdcc6291e0948140ff232b1b3c8b864ec6fec75e8 (diff)
Emit a event so the HPB can send the update to the participantsbugfix/noid/combine-multiple-system-messages-updates
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/Chat/ChatManager.php1
-rw-r--r--lib/Service/ParticipantService.php5
-rw-r--r--lib/Signaling/Listener.php58
3 files changed, 30 insertions, 34 deletions
diff --git a/lib/Chat/ChatManager.php b/lib/Chat/ChatManager.php
index a2d5416f7..9209f9342 100644
--- a/lib/Chat/ChatManager.php
+++ b/lib/Chat/ChatManager.php
@@ -57,6 +57,7 @@ use OCP\Notification\IManager as INotificationManager;
class ChatManager {
public const EVENT_BEFORE_SYSTEM_MESSAGE_SEND = self::class . '::preSendSystemMessage';
public const EVENT_AFTER_SYSTEM_MESSAGE_SEND = self::class . '::postSendSystemMessage';
+ public const EVENT_AFTER_MULTIPLE_SYSTEM_MESSAGE_SEND = self::class . '::postSendMultipleSystemMessage';
public const EVENT_BEFORE_MESSAGE_SEND = self::class . '::preSendMessage';
public const EVENT_AFTER_MESSAGE_SEND = self::class . '::postSendMessage';
diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php
index 3e3cd8d74..044054bf2 100644
--- a/lib/Service/ParticipantService.php
+++ b/lib/Service/ParticipantService.php
@@ -26,10 +26,12 @@ namespace OCA\Talk\Service;
use OCA\Circles\CirclesManager;
use OCA\Circles\Model\Circle;
use OCA\Circles\Model\Member;
+use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Config;
use OCA\Talk\Events\AddParticipantsEvent;
use OCA\Talk\Events\AttendeesAddedEvent;
use OCA\Talk\Events\AttendeesRemovedEvent;
+use OCA\Talk\Events\ChatEvent;
use OCA\Talk\Events\EndCallForEveryoneEvent;
use OCA\Talk\Events\JoinRoomGuestEvent;
use OCA\Talk\Events\JoinRoomUserEvent;
@@ -445,6 +447,9 @@ class ParticipantService {
$lastMessageCache->remove($room->getToken());
$unreadCountCache = $this->cacheFactory->createDistributed('talk/unreadcount');
$unreadCountCache->clear($room->getId() . '-');
+
+ $event = new ChatEvent($room, $message);
+ $this->dispatcher->dispatch(ChatManager::EVENT_AFTER_MULTIPLE_SYSTEM_MESSAGE_SEND, $event);
}
public function getHighestPermissionAttendee(Room $room): ?Attendee {
diff --git a/lib/Signaling/Listener.php b/lib/Signaling/Listener.php
index 2d603e2af..2452729f8 100644
--- a/lib/Signaling/Listener.php
+++ b/lib/Signaling/Listener.php
@@ -27,7 +27,6 @@ use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Config;
use OCA\Talk\Events\AddParticipantsEvent;
use OCA\Talk\Events\ChatEvent;
-use OCA\Talk\Events\ChatParticipantEvent;
use OCA\Talk\Events\EndCallForEveryoneEvent;
use OCA\Talk\Events\ModifyEveryoneEvent;
use OCA\Talk\Events\ModifyParticipantEvent;
@@ -36,7 +35,6 @@ use OCA\Talk\Events\RemoveParticipantEvent;
use OCA\Talk\Events\RemoveUserEvent;
use OCA\Talk\Events\RoomEvent;
use OCA\Talk\GuestManager;
-use OCA\Talk\Model\Session;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
@@ -323,39 +321,31 @@ class Listener {
$notifier->participantsModified($event->getRoom(), $sessionIds);
}
});
- $dispatcher->addListener(ChatManager::EVENT_AFTER_MESSAGE_SEND, static function (ChatParticipantEvent $event) {
- if (self::isUsingInternalSignaling()) {
- return;
- }
- /** @var BackendNotifier $notifier */
- $notifier = \OC::$server->get(BackendNotifier::class);
-
- $room = $event->getRoom();
- $message = [
- 'type' => 'chat',
- 'chat' => [
- 'refresh' => true,
- ],
- ];
- $notifier->sendRoomMessage($room, $message);
- });
- $dispatcher->addListener(ChatManager::EVENT_AFTER_SYSTEM_MESSAGE_SEND, static function (ChatEvent $event) {
- if (self::isUsingInternalSignaling()) {
- return;
- }
-
- /** @var BackendNotifier $notifier */
- $notifier = \OC::$server->get(BackendNotifier::class);
+ $dispatcher->addListener(ChatManager::EVENT_AFTER_MESSAGE_SEND, [self::class, 'notifyUsersViaExternalSignalingToRefreshTheChat']);
+ $dispatcher->addListener(ChatManager::EVENT_AFTER_SYSTEM_MESSAGE_SEND, [self::class, 'notifyUsersViaExternalSignalingToRefreshTheChat']);
+ $dispatcher->addListener(ChatManager::EVENT_AFTER_MULTIPLE_SYSTEM_MESSAGE_SEND, [self::class, 'notifyUsersViaExternalSignalingToRefreshTheChat']);
+ }
- $room = $event->getRoom();
- $message = [
- 'type' => 'chat',
- 'chat' => [
- 'refresh' => true,
- ],
- ];
- $notifier->sendRoomMessage($room, $message);
- });
+ public static function notifyUsersViaExternalSignalingToRefreshTheChat(ChatEvent $event): void {
+ if (self::isUsingInternalSignaling()) {
+ return;
+ }
+
+ if ($event->shouldSkipLastActivityUpdate()) {
+ return;
+ }
+
+ /** @var BackendNotifier $notifier */
+ $notifier = \OC::$server->get(BackendNotifier::class);
+
+ $room = $event->getRoom();
+ $message = [
+ 'type' => 'chat',
+ 'chat' => [
+ 'refresh' => true,
+ ],
+ ];
+ $notifier->sendRoomMessage($room, $message);
}
}