summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2021-07-15 18:52:45 +0200
committerGitHub <noreply@github.com>2021-07-15 18:52:45 +0200
commitddda9be34bd14f8ccf14521a6e100870493cd4b3 (patch)
tree17577d776d8046d0a07c0ac463d0197565e6b052
parent92007d579d2bdb44f4297ebc43ca54f4a953d851 (diff)
parente736c8a609ddca9ffca5a2319d854ae8b59e676b (diff)
Merge pull request #5667 from nextcloud/enh/noid/matterbridge-set-names
Show name for bridged messages
-rw-r--r--docs/constants.md1
-rw-r--r--lib/Chat/MessageParser.php7
-rw-r--r--lib/Controller/ChatController.php6
-rw-r--r--lib/MatterbridgeManager.php1
-rw-r--r--lib/Model/Attendee.php1
-rw-r--r--src/components/MessagesList/MessagesGroup/AuthorAvatar.vue6
-rw-r--r--src/components/MessagesList/MessagesList.vue8
-rw-r--r--src/constants.js1
8 files changed, 26 insertions, 5 deletions
diff --git a/docs/constants.md b/docs/constants.md
index 0946ee557..da857907a 100644
--- a/docs/constants.md
+++ b/docs/constants.md
@@ -67,6 +67,7 @@ title: Constants
* `users` - Logged-in users
* `guests` - Guest users (attendee type `guests` and `emails`)
* `bots` - Used by commands (actor-id is the used `/command`) and the changelog conversation (actor-id is `changelog`)
+* `bridged` - Users whose messages are bridged in by the [Matterbridge integration](matterbridge.md)
## Signaling modes
* `internal` No external signaling server is used
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;
diff --git a/src/components/MessagesList/MessagesGroup/AuthorAvatar.vue b/src/components/MessagesList/MessagesGroup/AuthorAvatar.vue
index f8bd7b4a7..1dde6510c 100644
--- a/src/components/MessagesList/MessagesGroup/AuthorAvatar.vue
+++ b/src/components/MessagesList/MessagesGroup/AuthorAvatar.vue
@@ -47,6 +47,7 @@
<script>
import Avatar from '@nextcloud/vue/dist/Components/Avatar'
+import { ATTENDEE } from '../../../constants'
export default {
name: 'AuthorAvatar',
@@ -73,7 +74,7 @@ export default {
return this.authorType === 'bots' && this.authorId === 'changelog'
},
isUser() {
- return this.authorType === 'users'
+ return this.authorType === 'users' || this.authorType === ATTENDEE.ACTOR_TYPE.BRIDGED
},
isDeletedUser() {
return this.authorType === 'deleted_users'
@@ -89,7 +90,8 @@ export default {
disableMenu() {
// disable the menu if accessing the conversation as guest
- return this.$store.getters.getActorType() === 'guests'
+ // or the message sender is a bridged user
+ return this.$store.getters.getActorType() === 'guests' || this.authorType === ATTENDEE.ACTOR_TYPE.BRIDGED
},
},
}
diff --git a/src/components/MessagesList/MessagesList.vue b/src/components/MessagesList/MessagesList.vue
index 1783247f9..cfafc4a07 100644
--- a/src/components/MessagesList/MessagesList.vue
+++ b/src/components/MessagesList/MessagesList.vue
@@ -304,12 +304,14 @@ export default {
* @param {string} message1.id The ID of the new message
* @param {string} message1.actorType Actor type of the new message
* @param {string} message1.actorId Actor id of the new message
+ * @param {string} message1.actorDisplayName Actor displayname of the new message
* @param {string} message1.systemMessage System message content of the new message
* @param {int} message1.timestamp Timestamp of the new message
* @param {null|object} message2 The previous message
* @param {string} message2.id The ID of the second message
* @param {string} message2.actorType Actor type of the previous message
* @param {string} message2.actorId Actor id of the previous message
+ * @param {string} message2.actorDisplayName Actor display name of previous message
* @param {string} message2.systemMessage System message content of the previous message
* @param {int} message2.timestamp Timestamp of the second message
* @returns {boolean} Boolean if the messages should be grouped or not
@@ -333,8 +335,10 @@ export default {
}
if (!message1IsSystem // System messages are grouped independent from author
- && (message1.actorType !== message2.actorType // Otherwise the type and id need to match
- || message1.actorId !== message2.actorId)) {
+ && ((message1.actorType !== message2.actorType // Otherwise the type and id need to match
+ || message1.actorId !== message2.actorId)
+ || (message1.actorType === ATTENDEE.ACTOR_TYPE.BRIDGED // Or, if the message is bridged, display names also need to match
+ && message1.actorDisplayName !== message2.actorDisplayName))) {
return false
}
diff --git a/src/constants.js b/src/constants.js
index 0a51cee3d..a1c384644 100644
--- a/src/constants.js
+++ b/src/constants.js
@@ -54,6 +54,7 @@ export const ATTENDEE = {
GROUPS: 'groups',
CIRCLES: 'circles',
BOTS: 'bots',
+ BRIDGED: 'bridged',
},
BRIDGE_BOT_ID: 'bridge-bot',
CHANGELOG_BOT_ID: 'changelog',