diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2021-07-15 19:52:45 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-15 19:52:45 +0300 |
commit | ddda9be34bd14f8ccf14521a6e100870493cd4b3 (patch) | |
tree | 17577d776d8046d0a07c0ac463d0197565e6b052 /lib | |
parent | 92007d579d2bdb44f4297ebc43ca54f4a953d851 (diff) | |
parent | e736c8a609ddca9ffca5a2319d854ae8b59e676b (diff) |
Merge pull request #5667 from nextcloud/enh/noid/matterbridge-set-names
Show name for bridged messages
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Chat/MessageParser.php | 7 | ||||
-rw-r--r-- | lib/Controller/ChatController.php | 6 | ||||
-rw-r--r-- | lib/MatterbridgeManager.php | 1 | ||||
-rw-r--r-- | lib/Model/Attendee.php | 1 |
4 files changed, 14 insertions, 1 deletions
diff --git a/lib/Chat/MessageParser.php b/lib/Chat/MessageParser.php index b29c54f5b..ff944c2f4 100644 --- a/lib/Chat/MessageParser.php +++ b/lib/Chat/MessageParser.php @@ -26,6 +26,7 @@ namespace OCA\Talk\Chat; use OCA\Talk\Events\ChatMessageEvent; use OCA\Talk\Exceptions\ParticipantNotFoundException; +use OCA\Talk\MatterbridgeManager; use OCA\Talk\Model\Attendee; use OCA\Talk\Model\Message; use OCA\Talk\Participant; @@ -73,10 +74,14 @@ class MessageParser { protected function setActor(Message $message): void { $comment = $message->getComment(); + $actorId = $comment->getActorId(); $displayName = ''; if ($comment->getActorType() === Attendee::ACTOR_USERS) { $user = $this->userManager->get($comment->getActorId()); $displayName = $user instanceof IUser ? $user->getDisplayName() : $comment->getActorId(); + } elseif ($comment->getActorType() === Attendee::ACTOR_BRIDGED) { + $displayName = $comment->getActorId(); + $actorId = MatterbridgeManager::BRIDGE_BOT_USERID; } elseif ($comment->getActorType() === Attendee::ACTOR_GUESTS) { if (isset($guestNames[$comment->getActorId()])) { $displayName = $this->guestNames[$comment->getActorId()]; @@ -94,7 +99,7 @@ class MessageParser { $message->setActor( $comment->getActorType(), - $comment->getActorId(), + $actorId, $displayName ); } diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index af9e13b31..2e22a1cd9 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -160,6 +160,9 @@ class ChatController extends AEnvironmentAwareController { if ($actorDisplayName) { $this->guestManager->updateName($this->room, $this->participant, $actorDisplayName); } + } elseif ($this->userId === MatterbridgeManager::BRIDGE_BOT_USERID && $actorDisplayName) { + $actorType = Attendee::ACTOR_BRIDGED; + $actorId = str_replace(["/", "\""], "", $actorDisplayName); } else { $actorType = Attendee::ACTOR_USERS; $actorId = $this->userId; @@ -553,6 +556,9 @@ class ChatController extends AEnvironmentAwareController { $attendee = $this->participant->getAttendee(); $isOwnMessage = $message->getActorType() === $attendee->getActorType() && $message->getActorId() === $attendee->getActorId(); + + // Special case for if the message is a bridged message, then the message is the bridge bot's message. + $isOwnMessage = $isOwnMessage || ($message->getActorType() === Attendee::ACTOR_BRIDGED && $attendee->getActorId() === MatterbridgeManager::BRIDGE_BOT_USERID); if (!$isOwnMessage && (!$this->participant->hasModeratorPermissions(false) || $this->room->getType() === Room::ONE_TO_ONE_CALL)) { diff --git a/lib/MatterbridgeManager.php b/lib/MatterbridgeManager.php index 2c48b5aaf..2297e528a 100644 --- a/lib/MatterbridgeManager.php +++ b/lib/MatterbridgeManager.php @@ -387,6 +387,7 @@ class MatterbridgeManager { $serverUrl = $part['server']; } else { $serverUrl = preg_replace('/\/+$/', '', $this->urlGenerator->getAbsoluteURL('')); + $content .= " SeparateDisplayName = true" ."\n"; // TODO remove that //$serverUrl = preg_replace('/https:/', 'http:', $serverUrl); } diff --git a/lib/Model/Attendee.php b/lib/Model/Attendee.php index 5a758d4ae..6f7b083a5 100644 --- a/lib/Model/Attendee.php +++ b/lib/Model/Attendee.php @@ -58,6 +58,7 @@ class Attendee extends Entity { public const ACTOR_GUESTS = 'guests'; public const ACTOR_EMAILS = 'emails'; public const ACTOR_CIRCLES = 'circles'; + public const ACTOR_BRIDGED = 'bridged'; public const PUBLISHING_PERMISSIONS_NONE = 0; public const PUBLISHING_PERMISSIONS_AUDIO = 1; |