Skip to content

Commit

Permalink
fix: don't display name of user who started conversation in members a…
Browse files Browse the repository at this point in the history
…dded message (#2882)

Filter out the initiator ID from the system usernames
Refactor initiator name to a variable and reuse
  • Loading branch information
musale authored Nov 28, 2023
1 parent 45a649f commit 88f711a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.prettierPath": "./node_modules/prettier",
"editor.codeActionsOnSave": {
"source.fixAll.tslint": true
"source.fixAll.tslint": "explicit"
},
"lit-html.tags": ["mgtHtml"],
"typescript.tsdk": "node_modules/typescript/lib",
Expand Down
14 changes: 9 additions & 5 deletions packages/mgt-chat/src/statefulClient/StatefulGraphChatClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,18 +610,22 @@ class StatefulGraphChatClient implements StatefulClient<GraphChatClient> {
awaits.push(getUserWithPhoto(this.graph, id));
}
const people = await Promise.all(awaits);
const userNames = userIds?.map(m => this.getUserName(m, people)).join(', ');
const userNames = userIds
?.filter(id => id !== initiatorId)
.map(m => this.getUserName(m, people))
.join(', ');
const initiatorUsername = this.getUserName(initiatorId, people);
switch (eventDetail['@odata.type']) {
case '#microsoft.graph.membersAddedEventMessageDetail':
messageContent = `${this.getUserName(initiatorId, people)} added ${userNames}`;
messageContent = `${initiatorUsername} added ${userNames}`;
break;
case '#microsoft.graph.membersDeletedEventMessageDetail':
messageContent = `${this.getUserName(initiatorId, people)} removed ${userNames}`;
messageContent = `${initiatorUsername} removed ${userNames}`;
break;
case '#microsoft.graph.chatRenamedEventMessageDetail':
messageContent = eventDetail.chatDisplayName
? `${this.getUserName(initiatorId, people)} renamed the chat to ${eventDetail.chatDisplayName}`
: `${this.getUserName(initiatorId, people)} removed the group name for this conversation`;
? `${initiatorUsername} renamed the chat to ${eventDetail.chatDisplayName}`
: `${initiatorUsername} removed the group name for this conversation`;
break;
// TODO: move this default case to a console.warn before release and emit an empty message
// it's here to help us catch messages we have't handled yet
Expand Down

0 comments on commit 88f711a

Please sign in to comment.