Skip to content

Commit de29872

Browse files
author
Farzad Hayatbakhsh
committed
Improve the sample user database
1 parent 9487336 commit de29872

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,22 @@ For guidance on retrieving and verifying the `mentionedUids` array, refer to the
131131

132132
[source,js]
133133
----
134-
// Fake database of users
135-
const users = {
136-
"johndoe": "John Doe",
137-
"janedoe": "Jane Doe",
138-
"alicedoe": "Alice Doe",
134+
// Sample user database
135+
const userDb = {
136+
"johnsmith": {
137+
"id": "johnsmith",
138+
"name": "John Smith",
139+
"fullName": "John Smith",
140+
"description": "Company Founder",
141+
"image": "https://i.pravatar.cc/150?img=11"
142+
},
143+
"jennynichols": {
144+
"id": "jennynichols",
145+
"name": "Jenny Nichols",
146+
"fullName": "Jenny Nichols",
147+
"description": "Marketing Director",
148+
"image": "https://i.pravatar.cc/150?img=10"
149+
}
139150
};
140151
141152
const comments = tinymce.activeEditor.plugins.tinycomments;
@@ -152,7 +163,7 @@ const events = eventLog.events;
152163
const validatedEvents = JSON.parse(JSON.stringify(events));
153164
validatedEvents.forEach((event) => {
154165
// Filter out invalid users - change this to your own validation logic
155-
event.mentionedUids = event.mentionedUids ? event.mentionedUids.filter((uid) => users[uid]) : undefined;
166+
event.mentionedUids = event.mentionedUids ? event.mentionedUids.filter((uid) => userDb[uid]) : undefined;
156167
});
157168
158169
const mentionedUsers = validatedEvents.flatMap(({ mentionedUids }) => mentionedUids || []);

0 commit comments

Comments
 (0)