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>2021-02-12 00:12:23 +0300
committerJoas Schilling <coding@schilljs.com>2021-02-12 11:56:42 +0300
commit3606f14153d956d5513c2646d45a172bc0517376 (patch)
tree42cad6ab47fe9406a3c50d48a2874d0f593a4d47
parenteb3de685e567aeed2193313402e79cc99c91584d (diff)
Remove "guest/" from actorStores actorId, so it matches the API values
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--src/components/MessagesList/MessagesGroup/Message/MessagePart/Mention.vue7
-rw-r--r--src/components/Quote.vue7
-rw-r--r--src/components/SetGuestUsername.vue4
-rw-r--r--src/store/actorStore.js17
-rw-r--r--src/utils/temporaryMessage.js5
5 files changed, 12 insertions, 28 deletions
diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/Mention.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/Mention.vue
index a9b6fce03..d7928f3b1 100644
--- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/Mention.vue
+++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/Mention.vue
@@ -70,8 +70,13 @@ export default {
return this.type === 'guest'
},
isCurrentGuest() {
+ // On mention bubbles the id is actually "guest/ACTOR_ID" for guests
+ // This is to make sure guests can never collide with users,
+ // while storing them as "… @id …" in chat messages.
+ // So when comparing a guest we have to prefix "guest/"
+ // when comparing the id
return this.$store.getters.getActorType() === 'guests'
- && this.id === ('guest/' + this.$store.getters.getSessionHash())
+ && this.id === ('guest/' + this.$store.getters.getActorId())
},
isCurrentUser() {
return this.$store.getters.getActorType() === 'users'
diff --git a/src/components/Quote.vue b/src/components/Quote.vue
index 9e952484c..220181401 100644
--- a/src/components/Quote.vue
+++ b/src/components/Quote.vue
@@ -151,12 +151,7 @@ export default {
},
isOwnMessageQuoted() {
- let actorId = this.actorId
- if (this.actorType === 'guests') {
- actorId = 'guest/' + actorId
- }
-
- return actorId === this.$store.getters.getActorId()
+ return this.actorId === this.$store.getters.getActorId()
&& this.actorType === this.$store.getters.getActorType()
},
diff --git a/src/components/SetGuestUsername.vue b/src/components/SetGuestUsername.vue
index c1c1ff6e1..ae41f3fbb 100644
--- a/src/components/SetGuestUsername.vue
+++ b/src/components/SetGuestUsername.vue
@@ -111,7 +111,7 @@ export default {
this.$store.dispatch('setDisplayName', this.guestUserName)
this.$store.dispatch('forceGuestName', {
token: this.token,
- actorId: this.$store.getters.getActorId().substring(6),
+ actorId: this.$store.getters.getActorId(),
actorDisplayName: this.guestUserName,
})
await setGuestUserName(this.token, this.guestUserName)
@@ -125,7 +125,7 @@ export default {
this.$store.dispatch('setDisplayName', previousName)
this.$store.dispatch('forceGuestName', {
token: this.token,
- actorId: this.$store.getters.getActorId().substring(6),
+ actorId: this.$store.getters.getActorId(),
actorDisplayName: previousName,
})
console.debug(exception)
diff --git a/src/store/actorStore.js b/src/store/actorStore.js
index 076f0da95..8d75f8fb3 100644
--- a/src/store/actorStore.js
+++ b/src/store/actorStore.js
@@ -27,13 +27,11 @@
* If an as no userId, they are a guest and identified by actorType + sessionId.
*/
-import sha1 from 'crypto-js/sha1'
import { PARTICIPANT } from '../constants'
const state = {
userId: null,
sessionId: null,
- sessionHash: null,
actorId: null,
actorType: null,
displayName: '',
@@ -46,9 +44,6 @@ const getters = {
getSessionId: (state) => () => {
return state.sessionId
},
- getSessionHash: (state) => () => {
- return state.sessionHash
- },
getActorId: (state) => () => {
return state.actorId
},
@@ -59,14 +54,8 @@ const getters = {
return state.displayName
},
getParticipantIdentifier: (state) => () => {
- if (state.actorType === 'guests') {
- return {
- actorType: 'guests',
- sessionId: state.sessionId,
- }
- }
return {
- actorType: 'users',
+ actorType: state.actorType,
actorId: state.actorId,
}
},
@@ -91,7 +80,6 @@ const mutations = {
*/
setSessionId(state, sessionId) {
state.sessionId = sessionId
- state.sessionHash = sha1(sessionId)
},
/**
* Set the actorId
@@ -146,6 +134,7 @@ const actions = {
* @param {object} participant The participant data
* @param {int} participant.participantType The type of the participant
* @param {string} participant.sessionId The session id of the participant
+ * @param {string} participant.actorId The actor id of the participant
*/
setCurrentParticipant(context, participant) {
context.commit('setSessionId', participant.sessionId)
@@ -154,7 +143,7 @@ const actions = {
|| participant.participantType === PARTICIPANT.TYPE.GUEST_MODERATOR) {
context.commit('setUserId', null)
context.commit('setActorType', 'guests')
- context.commit('setActorId', 'guest/' + context.getters.getSessionHash())
+ context.commit('setActorId', participant.actorId)
// FIXME context.commit('setDisplayName', '')
}
},
diff --git a/src/utils/temporaryMessage.js b/src/utils/temporaryMessage.js
index 4b5027c95..07f7fe1cd 100644
--- a/src/utils/temporaryMessage.js
+++ b/src/utils/temporaryMessage.js
@@ -59,11 +59,6 @@ const createTemporaryMessage = (text, token, uploadId, index, file, localUrl) =>
referenceId: Hex.stringify(SHA1(tempId)),
})
- if (store.getters.getActorType() === 'guests') {
- // Strip off "guests/" from the sessionHash
- message.actorId = store.getters.getActorId().substring(6)
- }
-
/**
* If the current message is a quote-reply message, add the parent key to the
* temporary message object.