Skip to content

Commit be7ddd3

Browse files
author
Farzad Hayatbakhsh
committed
Validate mentionedUids in each of the events
1 parent b7c4555 commit be7ddd3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

modules/ROOT/partials/plugin-apis/comments-apis.adoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ The `mentionedUids` array captures any string following the `@` symbol without v
128128

129129
[source,js]
130130
----
131+
// Fake database of users
132+
const users = {
133+
"user1": "John Doe",
134+
"user2": "Jane Doe",
135+
"user3": "Alice Doe",
136+
};
137+
131138
const comments = tinymce.activeEditor.plugins.tinycomments;
132139
133140
console.log(comments.getEventLog());
@@ -137,6 +144,10 @@ console.log(comments.getEventLog(
137144
138145
const eventLog = comments.getEventLog();
139146
const events = eventLog.events;
147+
// Ensure that the mentioned users are valid users in the database
148+
events.forEach((event) => {
149+
event.mentionedUids = event.mentionedUids ? event.mentionedUids.filter((uid) => users[uid]) : undefined;
150+
});
140151
const mentionedUsers = events.flatMap(({ mentionedUids }) => mentionedUids || []);
141152
console.log(mentionedUsers);
142153

0 commit comments

Comments
 (0)