FIX: Do not add mentioned groups as mentioned users (#21867)

When a user type a message with mentions, the autocomplete popup 
may suggest users or groups. We were adding all these object to 
the `currentMessage.mentionedUsers` collection, while we should 
have been adding only users. A group added to that collection led to 
the error later when trying to update user status on mentions.
This commit is contained in:
Andrei Prigorshnev 2023-06-01 15:55:59 +04:00 committed by GitHub
parent 89b18b21ec
commit bb21476f68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 4 deletions

View File

@ -415,6 +415,11 @@ export default class ChatComposer extends Component {
}
}
#addMentionedUser(userData) {
const user = User.create(userData);
this.currentMessage.mentionedUsers.set(user.id, user);
}
#applyUserAutocomplete($textarea) {
if (!this.siteSettings.enable_mentions) {
return;
@ -426,10 +431,12 @@ export default class ChatComposer extends Component {
width: "100%",
treatAsTextarea: true,
autoSelectFirstSuggestion: true,
transformComplete: (userData) => {
const user = User.create(userData);
this.currentMessage.mentionedUsers.set(user.id, user);
return user.username || user.name;
transformComplete: (obj) => {
if (obj.isUser) {
this.#addMentionedUser(obj);
}
return obj.username || obj.name;
},
dataSource: (term) => {
return userSearch({ term, includeGroups: true }).then((result) => {