diff --git a/dump.rdb b/dump.rdb
new file mode 100644
index 0000000000..f1cc0fcee0
Binary files /dev/null and b/dump.rdb differ
diff --git a/public/language/en-GB/notifications.json b/public/language/en-GB/notifications.json
index 2782fdaff9..365a243c2d 100644
--- a/public/language/en-GB/notifications.json
+++ b/public/language/en-GB/notifications.json
@@ -50,6 +50,7 @@
"user-flagged-user-dual": "%1 and %2 flagged a user profile (%3)",
"user-flagged-user-triple": "%1, %2 and %3 flagged a user profile (%4)",
"user-flagged-user-multiple": "%1, %2 and %3 others flagged a user profile (%4)",
+ "admin-posted-to" : "Instructor %1 has posted a reply to: %2",
"user-posted-to" : "%1 has posted a reply to: %2",
"user-posted-to-dual" : "%1 and %2 have posted replies to: %3",
"user-posted-to-triple" : "%1, %2 and %3 have posted replies to: %4",
diff --git a/public/src/client/account/settings.js b/public/src/client/account/settings.js
index 1d6f1c1652..a312b0af17 100644
--- a/public/src/client/account/settings.js
+++ b/public/src/client/account/settings.js
@@ -72,27 +72,40 @@ define('forum/account/settings', [
}
function saveSettings(settings) {
- api.put(`/users/${ajaxify.data.uid}/settings`, { settings }).then((newSettings) => {
- alerts.success('[[success:settings-saved]]');
- let languageChanged = false;
- for (const key in newSettings) {
- if (newSettings.hasOwnProperty(key)) {
- if (key === 'userLang' && config.userLang !== newSettings.userLang) {
- languageChanged = true;
- }
- if (key === 'bootswatchSkin') {
- savedSkin = newSettings.bootswatchSkin;
- config.bootswatchSkin = savedSkin === 'noskin' ? '' : savedSkin;
- } else if (config.hasOwnProperty(key)) {
- config[key] = newSettings[key];
- }
- }
- }
+ console.log('Logging Jullia Montejo');
+ api.put(`/users/${ajaxify.data.uid}/settings`, { settings }).then(handleNewSettings);
+ }
+
+ // Alerts the user that the settings have been saved and updates the configuration.
+ function handleNewSettings(newSettings) {
+ alerts.success('[[success:settings-saved]]');
+ processNewSettings(newSettings);
+ }
- if (languageChanged && parseInt(app.user.uid, 10) === parseInt(ajaxify.data.theirid, 10)) {
- window.location.reload();
+ // Processes the new settings and updates the configuration accordingly.
+ function processNewSettings(newSettings) {
+ for (const key in newSettings) {
+ if (newSettings.hasOwnProperty(key)) {
+ checkAndUpdateConfig(key, newSettings);
}
- });
+ }
+ }
+
+ // Updates the configuration based on the provided key and new settings.
+ function checkAndUpdateConfig(key, newSettings) {
+ if (key === 'userLang' && config.userLang !== newSettings.userLang) {
+ window.location.reload();
+ } else if (key === 'bootswatchSkin') {
+ updateSkin(newSettings.bootswatchSkin);
+ } else if (config.hasOwnProperty(key)) {
+ config[key] = newSettings[key];
+ }
+ }
+
+ // Updates the saved skin with the new skin.
+ function updateSkin(skin) {
+ savedSkin = skin;
+ config.bootswatchSkin = skin === 'noskin' ? '' : skin;
}
function toggleCustomRoute() {
@@ -162,4 +175,4 @@ define('forum/account/settings', [
};
return AccountSettings;
-});
+});
\ No newline at end of file
diff --git a/src/topics/create.js b/src/topics/create.js
index 0d6ee1bc19..44019f2222 100644
--- a/src/topics/create.js
+++ b/src/topics/create.js
@@ -167,19 +167,19 @@ module.exports = function (Topics) {
data = await plugins.hooks.fire('filter:topic.reply', data);
const { tid } = data;
const { uid } = data;
-
+
const [topicData, isAdmin] = await Promise.all([
Topics.getTopicData(tid),
privileges.users.isAdministrator(uid),
]);
-
+
await canReply(data, topicData);
-
+
data.cid = topicData.cid;
-
+
await guestHandleValid(data);
data.content = String(data.content || '').trimEnd();
-
+
if (!data.fromQueue && !isAdmin) {
await user.isReadyToPost(uid, data.cid);
Topics.checkContent(data.content);
@@ -187,41 +187,53 @@ module.exports = function (Topics) {
throw new Error(`[[error:not-enough-reputation-to-post-links, ${meta.config['min:rep:post-links']}]]`);
}
}
-
+
// For replies to scheduled topics, don't have a timestamp older than topic's itself
if (topicData.scheduled) {
data.timestamp = topicData.lastposttime + 1;
}
-
+
data.ip = data.req ? data.req.ip : null;
let postData = await posts.create(data);
postData = await onNewPost(postData, data);
-
+
const settings = await user.getSettings(uid);
if (uid > 0 && settings.followTopicsOnReply) {
await Topics.follow(postData.tid, uid);
}
-
+
if (parseInt(uid, 10)) {
user.setUserField(uid, 'lastonline', Date.now());
}
-
+
if (parseInt(uid, 10) || meta.config.allowGuestReplyNotifications) {
const { displayname } = postData.user;
+ // Ensure isAdmin is correctly set
+ const isAdmin = await privileges.users.isAdministrator(uid);
+
+ // Modify notification message based on admin status
+ let notificationMessage = translator.compile('notifications:user-posted-to', displayname, postData.topic.title);
+ console.log('isnotadmin');
+ if (isAdmin) {
+ console.log('isAdmin:', isAdmin);
+ notificationMessage = translator.compile('notifications:admin-posted-to', displayname, postData.topic.title);
+ }
+
Topics.notifyFollowers(postData, uid, {
type: 'new-reply',
- bodyShort: translator.compile('notifications:user-posted-to', displayname, postData.topic.title),
+ 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 });
-
+
return postData;
};
+
async function onNewPost(postData, data) {
const { tid, uid } = postData;