Browse Source
Merge pull request #10640 from nextcloud/fix/10631/fix-forwarded-mentions
fix(messagesStore) - Mentions in forwarded messages
pull/10672/head
Dorra
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
10 additions and
4 deletions
-
src/store/messagesStore.js
-
src/store/messagesStore.spec.js
|
|
|
@ -1306,7 +1306,8 @@ const actions = { |
|
|
|
for (const key in message.messageParameters) { |
|
|
|
if (key.startsWith('mention')) { |
|
|
|
const mention = message.messageParameters[key] |
|
|
|
message.message = message.message.replace(`{${key}}`, `@${mention.name}`) |
|
|
|
const mentionString = key.includes('mention-call') ? `**${mention.name}**` : `@"${mention.id}"` |
|
|
|
message.message = message.message.replace(`{${key}}`, mentionString) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1935,7 +1935,7 @@ describe('messagesStore', () => { |
|
|
|
messageToBeForwarded = { |
|
|
|
id: 1, |
|
|
|
token: TOKEN, |
|
|
|
message: 'Hello {mention-user1}, {mention-user2}', |
|
|
|
message: 'Hello {mention-user1}, {mention-user2}, and {mention-call1}', |
|
|
|
messageParameters: { |
|
|
|
'mention-user1': { |
|
|
|
id: 'taylor', |
|
|
|
@ -1943,15 +1943,20 @@ describe('messagesStore', () => { |
|
|
|
type: 'user', |
|
|
|
}, |
|
|
|
'mention-user2': { |
|
|
|
id: 'adam', |
|
|
|
id: 'adam driver', |
|
|
|
name: 'Adam', |
|
|
|
type: 'user', |
|
|
|
}, |
|
|
|
'mention-call1': { |
|
|
|
id: TOKEN, |
|
|
|
name: 'Team X', |
|
|
|
type: 'call', |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
targetToken = 'token-2' |
|
|
|
messageExpected = cloneDeep(messageToBeForwarded) |
|
|
|
messageExpected.message = 'Hello @Taylor, @Adam' |
|
|
|
messageExpected.message = 'Hello @"taylor", @"adam driver", and **Team X**' |
|
|
|
messageExpected.token = targetToken |
|
|
|
|
|
|
|
// Act
|
|
|
|
|