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 <213943+nickvergessen@users.noreply.github.com>2022-04-25 22:05:22 +0300
committerGitHub <noreply@github.com>2022-04-25 22:05:22 +0300
commit2ad2aad8b9c1d5bab1ebfe9b30d2095fc5980478 (patch)
tree3364018025ca8632fbdb7e5ce9c73f4d4ab68f40
parente69c1252bdf890cb2bcffdc4a214531cc9f6c964 (diff)
parentb73eb9fb0497718cc46dbe10674da58aa1bbf8f3 (diff)
Merge pull request #7205 from nextcloud/fix-reactions-endpoints-not-accessible-by-guests
Fix reactions endpoints not accessible by guests
-rw-r--r--lib/Controller/ReactionController.php6
-rw-r--r--src/components/MessagesList/MessagesGroup/Message/Message.vue17
-rw-r--r--src/store/guestNameStore.js8
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php1
-rw-r--r--tests/integration/features/reaction/react.feature16
5 files changed, 41 insertions, 7 deletions
diff --git a/lib/Controller/ReactionController.php b/lib/Controller/ReactionController.php
index d55be4dbc..779af9730 100644
--- a/lib/Controller/ReactionController.php
+++ b/lib/Controller/ReactionController.php
@@ -45,7 +45,7 @@ class ReactionController extends AEnvironmentAwareController {
}
/**
- * @NoAdminRequired
+ * @PublicPage
* @RequireParticipant
* @RequireReadWriteConversation
* @RequireModeratorOrNoLobby
@@ -75,7 +75,7 @@ class ReactionController extends AEnvironmentAwareController {
}
/**
- * @NoAdminRequired
+ * @PublicPage
* @RequireParticipant
* @RequireReadWriteConversation
* @RequireModeratorOrNoLobby
@@ -103,7 +103,7 @@ class ReactionController extends AEnvironmentAwareController {
}
/**
- * @NoAdminRequired
+ * @PublicPage
* @RequireParticipant
* @RequireReadWriteConversation
* @RequireModeratorOrNoLobby
diff --git a/src/components/MessagesList/MessagesGroup/Message/Message.vue b/src/components/MessagesList/MessagesGroup/Message/Message.vue
index 612b8de11..a58212cac 100644
--- a/src/components/MessagesList/MessagesGroup/Message/Message.vue
+++ b/src/components/MessagesList/MessagesGroup/Message/Message.vue
@@ -190,6 +190,7 @@ import EmojiPicker from '@nextcloud/vue/dist/Components/EmojiPicker'
import EmoticonOutline from 'vue-material-design-icons/EmoticonOutline.vue'
import Popover from '@nextcloud/vue/dist/Components/Popover'
import { showError, showSuccess, showWarning, TOAST_DEFAULT_TIMEOUT } from '@nextcloud/dialogs'
+import { ATTENDEE } from '../../../../constants'
export default {
name: 'Message',
@@ -738,12 +739,26 @@ export default {
&& list[item].actorId === this.$store.getters.getActorId()) {
summary.unshift(t('spreed', 'You'))
} else {
- summary.push(list[item].actorDisplayName)
+ summary.push(this.getDisplayNameForReaction(list[item]))
}
}
return summary.join(', ')
},
+
+ getDisplayNameForReaction(reaction) {
+ const displayName = reaction.actorDisplayName.trim()
+
+ if (reaction.actorType === ATTENDEE.ACTOR_TYPE.GUESTS) {
+ return this.$store.getters.getGuestNameWithGuestSuffix(this.token, reaction.actorId)
+ }
+
+ if (displayName === '') {
+ return t('spreed', 'Deleted user')
+ }
+
+ return displayName
+ },
},
}
</script>
diff --git a/src/store/guestNameStore.js b/src/store/guestNameStore.js
index 94f39acc5..48da79d9d 100644
--- a/src/store/guestNameStore.js
+++ b/src/store/guestNameStore.js
@@ -39,6 +39,14 @@ const getters = {
}
return t('spreed', 'Guest')
},
+
+ getGuestNameWithGuestSuffix: (state, getters) => (token, actorId) => {
+ const displayName = getters.getGuestName(token, actorId)
+ if (displayName === t('spreed', 'Guest')) {
+ return displayName
+ }
+ return t('spreed', '{guest} (guest)', { guest: displayName })
+ },
}
const mutations = {
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index fd722589a..23a22880b 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -2300,6 +2300,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$result = array_map(static function ($reaction, $list) use ($expected): array {
$list = array_map(function ($reaction) {
unset($reaction['timestamp']);
+ $reaction['actorId'] = ($reaction['actorType'] === 'guests') ? self::$sessionIdToUser[$reaction['actorId']] : (string) $reaction['actorId'];
return $reaction;
}, $list);
Assert::assertArrayHasKey($reaction, $expected, 'Not expected reaction: ' . $reaction);
diff --git a/tests/integration/features/reaction/react.feature b/tests/integration/features/reaction/react.feature
index 7c9613e8b..d53b044e0 100644
--- a/tests/integration/features/reaction/react.feature
+++ b/tests/integration/features/reaction/react.feature
@@ -25,11 +25,14 @@ Feature: reaction/react
| users | participant1 | participant1-displayname | 👍 |
| users | participant2 | participant2-displayname | 👍 |
And user "participant1" react with "🚀" on message "Message 1" to room "room" with 201
+ Then user "guest" joins room "room" with 200 (v4)
+ And user "guest" react with "👤" on message "Message 1" to room "room" with 201
Then user "participant1" sees the following messages in room "room" with 200
- | room | actorType | actorId | actorDisplayName | message | messageParameters | reactions | reactionsSelf |
- | room | users | participant1 | participant1-displayname | Message 1 | [] | {"👍":2,"🚀":1} | ["👍","🚀"] |
+ | room | actorType | actorId | actorDisplayName | message | messageParameters | reactions | reactionsSelf |
+ | room | users | participant1 | participant1-displayname | Message 1 | [] | {"👍":2,"👤":1,"🚀":1} | ["👍","🚀"] |
Then user "participant1" sees the following system messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | systemMessage |
+ | room | guests | guest | | reaction |
| room | users | participant1 | participant1-displayname | reaction |
| room | users | participant1 | participant1-displayname | reaction |
| room | users | participant2 | participant2-displayname | reaction |
@@ -66,17 +69,24 @@ Feature: reaction/react
And user "participant2" react with "👍" on message "Message 1" to room "room" with 201
| actorType | actorId | actorDisplayName | reaction |
| users | participant2 | participant2-displayname | 👍 |
+ Then user "guest" joins room "room" with 200 (v4)
+ And user "guest" react with "👤" on message "Message 1" to room "room" with 201
Then user "participant1" sees the following messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | reactions |
- | room | users | participant1 | participant1-displayname | Message 1 | [] | {"👍":1} |
+ | room | users | participant1 | participant1-displayname | Message 1 | [] | {"👤":1,"👍":1} |
And user "participant2" delete react with "👍" on message "Message 1" to room "room" with 200
| actorType | actorId | actorDisplayName | reaction |
+ | guests | guest | | 👤 |
+ And user "guest" delete react with "👤" on message "Message 1" to room "room" with 200
+ | actorType | actorId | actorDisplayName | reaction |
Then user "participant1" sees the following messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | reactions |
| room | users | participant1 | participant1-displayname | Message 1 | [] | [] |
Then user "participant1" sees the following system messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | systemMessage |
+ | room | guests | guest | | reaction_revoked |
| room | users | participant2 | participant2-displayname | reaction_revoked |
+ | room | guests | guest | | reaction_deleted |
| room | users | participant2 | participant2-displayname | reaction_deleted |
| room | users | participant1 | participant1-displayname | user_added |
| room | users | participant1 | participant1-displayname | conversation_created |