Skip to content

Commit

Permalink
Merge pull request #25 from CMU-313/jullia/instructor-notif-ft
Browse files Browse the repository at this point in the history
updated src/topics/create.js and notifications.json to handle course faculty notifications.
  • Loading branch information
mhli1260 authored Sep 25, 2024
2 parents 4c14ce8 + f63f393 commit 75ac75d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 10 deletions.
Binary file modified dump.rdb
Binary file not shown.
1 change: 1 addition & 0 deletions public/language/ar/notifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"user-flagged-user-dual": "<strong>%1</strong> and <strong>%2</strong> flagged a user profile (%3)",
"user-flagged-user-triple": "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> flagged a user profile (%4)",
"user-flagged-user-multiple": "<strong>%1</strong>, <strong>%2</strong> and %3 others flagged a user profile (%4)",
"admin-posted-to": "<strong>[COURSE FACULTY] %1</strong> أضاف ردًا إلى: <strong>%2</strong>",
"user-posted-to": "<strong>%1</strong> أضاف ردا إلى: <strong>%2</strong>",
"user-posted-to-dual": "<strong>%1</strong> and <strong>%2</strong> have posted replies to: <strong>%3</strong>",
"user-posted-to-triple": "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> have posted replies to: <strong>%4</strong>",
Expand Down
1 change: 1 addition & 0 deletions public/language/en-GB/notifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"user-flagged-user-dual": "<strong>%1</strong> and <strong>%2</strong> flagged a user profile (%3)",
"user-flagged-user-triple": "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> flagged a user profile (%4)",
"user-flagged-user-multiple": "<strong>%1</strong>, <strong>%2</strong> and %3 others flagged a user profile (%4)",
"admin-posted-to" : "<strong>[COURSE FACULTY] %1</strong> has posted a reply to: <strong>%2</strong>",
"user-posted-to" : "<strong>%1</strong> has posted a reply to: <strong>%2</strong>",
"user-posted-to-dual" : "<strong>%1</strong> and <strong>%2</strong> have posted replies to: <strong>%3</strong>",
"user-posted-to-triple" : "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> have posted replies to: <strong>%4</strong>",
Expand Down
1 change: 1 addition & 0 deletions public/language/en-US/notifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"user-flagged-user-dual": "<strong>%1</strong> and <strong>%2</strong> flagged a user profile (%3)",
"user-flagged-user-triple": "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> flagged a user profile (%4)",
"user-flagged-user-multiple": "<strong>%1</strong>, <strong>%2</strong> and %3 others flagged a user profile (%4)",
"admin-posted-to" : "<strong>[COURSE FACULTY] %1</strong> has posted a reply to: <strong>%2</strong>",
"user-posted-to": "<strong>%1</strong> has posted a reply to: <strong>%2</strong>",
"user-posted-to-dual": "<strong>%1</strong> and <strong>%2</strong> have posted replies to: <strong>%3</strong>",
"user-posted-to-triple": "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> have posted replies to: <strong>%4</strong>",
Expand Down
1 change: 1 addition & 0 deletions public/language/es/notifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"user-flagged-user-dual": "<strong>%1</strong> y <strong>%2</strong> reportaron el perfil (%3)",
"user-flagged-user-triple": "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> flagged a user profile (%4)",
"user-flagged-user-multiple": "<strong>%1</strong>, <strong>%2</strong> and %3 others flagged a user profile (%4)",
"admin-posted-to" : "<strong>[COURSE FACULTY] %1</strong> ha respondido a: <strong>%2</strong>",
"user-posted-to": "<strong>%1</strong> ha respondido a: <strong>%2</strong>",
"user-posted-to-dual": "<strong>%1</strong> y <strong>%2</strong> han respondido a <strong>%3</strong>",
"user-posted-to-triple": "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> have posted replies to: <strong>%4</strong>",
Expand Down
1 change: 1 addition & 0 deletions public/language/fr/notifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"user-flagged-user-dual": "<strong>%1</strong> et <strong>%2</strong> ont signalé un profil utilisateur (%3)",
"user-flagged-user-triple": "<strong>%1</strong>, <strong>%2</strong> et <strong>%3</strong> ont signalé un profil utilisateur (%4)",
"user-flagged-user-multiple": "<strong>%1</strong>, <strong>%2</strong> et %3 autres ont signalé un profil utilisateur (%4)",
"admin-posted-to": "<strong>[COURSE FACULTY] %1</strong> a répondu à : <strong>%2</strong>",
"user-posted-to": "<strong>%1</strong> a répondu à : <strong>%2</strong>",
"user-posted-to-dual": "<strong>%1</strong> et <strong>%2</strong> ont posté une réponse à : <strong>%3</strong>",
"user-posted-to-triple": "<strong>%1</strong>, <strong>%2</strong> et <strong>%3</strong> ont publié des réponses à : <strong>%4</strong>",
Expand Down
40 changes: 30 additions & 10 deletions src/topics/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,38 @@ module.exports = function (Topics) {
if (parseInt(uid, 10) || meta.config.allowGuestReplyNotifications) {
const { displayname } = postData.user;

Topics.notifyFollowers(postData, uid, {
type: 'new-reply',
bodyShort: translator.compile('notifications:user-posted-to', displayname, postData.topic.title),
nid: `new_post:tid:${postData.topic.tid}:pid:${postData.pid}:uid:${uid}`,
mergeId: `notifications:user-posted-to|${postData.topic.tid}`,
});
}
// Checks if the user is an admin
const isAdmin = await privileges.users.isAdministrator(uid);
let notificationMessage;

if (isAdmin) {
// Handles admin/instructor notification separately so it doesn't get bundled with
// notifications of non-admin replies.
// It does this by using a different notification ID and merge ID for admin replies.
notificationMessage = translator.compile('notifications:admin-posted-to', displayname, postData.topic.title);
Topics.notifyFollowers(postData, uid, {
type: 'new-reply',
bodyShort: notificationMessage,
nid: `admin_post:tid:${postData.topic.tid}:pid:${postData.pid}:uid:${uid}`,
mergeId: `notifications:admin-posted-to|${postData.topic.tid}`,
});
} else {
// This code handles non-admin replies, allowing bundling.
notificationMessage = translator.compile('notifications:user-posted-to', displayname, postData.topic.title);

Topics.notifyFollowers(postData, uid, {
type: 'new-reply',
bodyShort: notificationMessage,
nid: `new_post:tid:${postData.topic.tid}:pid:${postData.pid}:uid:${uid}`,
mergeId: `notifications:user-posted-to|${postData.topic.tid}`,
});
}

analytics.increment(['posts', `posts:byCid:${data.cid}`]);
plugins.hooks.fire('action:topic.reply', { post: _.clone(postData), data: data });
analytics.increment(['posts', `posts:byCid:${data.cid}`]);
plugins.hooks.fire('action:topic.reply', { post: _.clone(postData), data: data });

return postData;
return postData;
}
};

async function onNewPost(postData, data) {
Expand Down

0 comments on commit 75ac75d

Please sign in to comment.