Skip to content

Commit

Permalink
Improve the sample user database
Browse files Browse the repository at this point in the history
  • Loading branch information
FarzadHayat committed Dec 10, 2024
1 parent 9487336 commit de29872
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions modules/ROOT/partials/plugin-apis/comments-apis.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,22 @@ For guidance on retrieving and verifying the `mentionedUids` array, refer to the

[source,js]
----
// Fake database of users
const users = {
"johndoe": "John Doe",
"janedoe": "Jane Doe",
"alicedoe": "Alice Doe",
// Sample user database
const userDb = {
"johnsmith": {
"id": "johnsmith",
"name": "John Smith",
"fullName": "John Smith",
"description": "Company Founder",
"image": "https://i.pravatar.cc/150?img=11"
},
"jennynichols": {
"id": "jennynichols",
"name": "Jenny Nichols",
"fullName": "Jenny Nichols",
"description": "Marketing Director",
"image": "https://i.pravatar.cc/150?img=10"
}
};
const comments = tinymce.activeEditor.plugins.tinycomments;
Expand All @@ -152,7 +163,7 @@ const events = eventLog.events;
const validatedEvents = JSON.parse(JSON.stringify(events));
validatedEvents.forEach((event) => {
// Filter out invalid users - change this to your own validation logic
event.mentionedUids = event.mentionedUids ? event.mentionedUids.filter((uid) => users[uid]) : undefined;
event.mentionedUids = event.mentionedUids ? event.mentionedUids.filter((uid) => userDb[uid]) : undefined;
});
const mentionedUsers = validatedEvents.flatMap(({ mentionedUids }) => mentionedUids || []);
Expand Down

0 comments on commit de29872

Please sign in to comment.