Browse Source

Add a flag to messages if they can be replied to

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/2497/head
Joas Schilling 6 years ago
parent
commit
3496c7faaa
No known key found for this signature in database GPG Key ID: 7076EA9751AACDDA
  1. 4
      docs/capabilities.md
  2. 1
      docs/chat.md
  3. 1
      lib/Capabilities.php
  4. 2
      lib/Controller/ChatController.php
  5. 2
      lib/Controller/RoomController.php
  6. 12
      src/components/MessagesList/MessagesGroup/Message/Message.vue
  7. 2
      tests/php/CapabilitiesTest.php

4
docs/capabilities.md

@ -37,3 +37,7 @@ title: Capabilities
* `chat-read-marker` - The chat can be optionally marked read by clients manually, independent from the loading of the chat messages.
* `webinary-lobby` - See [Webinary management](webinary.md) for technical details.
* `start-call-flag` - Only moderators or users might be able to start calls.
## 8.0
* `chat-replies` - Normal chat messages can now be replied to. Check the `isReplyable` parameter on the message object.

1
docs/chat.md

@ -43,6 +43,7 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`
`timestamp` | int | Timestamp in seconds and UTC time zone
`systemMessage` | string | empty for normal chat message or the type of the system message (untranslated)
`messageType` | string | Currently known types are `comment`, `system` and `command`
`isReplyable` | bool | True if the user can post a reply to this message (only available with `chat-replies` capability)
`message` | string | Message string with placeholders (see [Rich Object String](https://github.com/nextcloud/server/issues/1706))
`messageParameters` | array | Message parameters for `message` (see [Rich Object String](https://github.com/nextcloud/server/issues/1706))

1
lib/Capabilities.php

@ -81,6 +81,7 @@ class Capabilities implements IPublicCapability {
'chat-read-marker',
'webinary-lobby',
'start-call-flag',
'chat-replies',
],
'config' => [
'chat' => [

2
lib/Controller/ChatController.php

@ -377,6 +377,8 @@ class ChatController extends AEnvironmentAwareController {
'messageParameters' => $message->getMessageParameters(),
'systemMessage' => $message->getMessageType() === 'system' ? $message->getMessageRaw() : '',
'messageType' => $message->getMessageType(),
'isReplyable' => $message->getMessageType() !== 'system' &&
($message->getActorType() === 'users' || $message->getActorType() === 'guests'),
];
}

2
lib/Controller/RoomController.php

@ -348,6 +348,8 @@ class RoomController extends AEnvironmentAwareController {
'messageParameters' => $message->getMessageParameters(),
'systemMessage' => $message->getMessageType() === 'system' ? $message->getMessageRaw() : '',
'messageType' => $message->getMessageType(),
'isReplyable' => $message->getMessageType() !== 'system' &&
($message->getActorType() === 'users' || $message->getActorType() === 'guests'),
];
}

12
src/components/MessagesList/MessagesGroup/Message/Message.vue

@ -159,6 +159,13 @@ export default {
type: Boolean,
required: true,
},
/**
* Specifies if the message can be replied to.
*/
isReplyable: {
type: Boolean,
required: true,
},
/**
* The conversation token.
*/
@ -193,11 +200,6 @@ export default {
return this.parent && this.$store.getters.message(this.token, this.parent)
},
isReplyable() {
return (this.actorType === 'users' || this.actorType === 'guests')
&& !this.systemMessage
},
isSingleEmoji() {
const regex = emojiRegex()
let match

2
tests/php/CapabilitiesTest.php

@ -92,6 +92,7 @@ class CapabilitiesTest extends TestCase {
'chat-read-marker',
'webinary-lobby',
'start-call-flag',
'chat-replies',
],
'config' => [
'chat' => [
@ -148,6 +149,7 @@ class CapabilitiesTest extends TestCase {
'chat-read-marker',
'webinary-lobby',
'start-call-flag',
'chat-replies',
],
'config' => [
'chat' => [

Loading…
Cancel
Save