nodebb-plugin-mentions 4.0.1 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/library.js CHANGED
@@ -96,12 +96,12 @@ Mentions.notify = async function (data) {
96
96
  return;
97
97
  }
98
98
 
99
- const [topic, author, topicFollowers] = await Promise.all([
99
+ const [topic, userData, topicFollowers] = await Promise.all([
100
100
  Topics.getTopicFields(postData.tid, ['title', 'cid']),
101
- User.getUserField(postData.uid, 'username'),
101
+ User.getUserFields(postData.uid, ['username']),
102
102
  Mentions._settings.disableFollowedTopics === 'on' ? Topics.getFollowers(postData.tid) : [],
103
103
  ]);
104
-
104
+ const { displayname } = userData;
105
105
  const title = entitiesDecode(topic.title);
106
106
  const titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
107
107
 
@@ -129,7 +129,7 @@ Mentions.notify = async function (data) {
129
129
 
130
130
  const filteredUids = await filterUidsAlreadyMentioned(uids, postData.pid);
131
131
  if (filteredUids.length) {
132
- await sendNotificationToUids(postData, filteredUids, 'user', `[[notifications:user_mentioned_you_in, ${author}, ${titleEscaped}]]`);
132
+ await sendNotificationToUids(postData, filteredUids, 'user', `[[notifications:user_mentioned_you_in, ${displayname}, ${titleEscaped}]]`);
133
133
  await db.setAdd(`mentions:pid:${postData.pid}:uids`, filteredUids);
134
134
  }
135
135
 
@@ -139,7 +139,7 @@ Mentions.notify = async function (data) {
139
139
  const groupName = groupsToNotify[i].name;
140
140
  const groupMentionSent = await db.isSetMember(`mentions:pid:${postData.pid}:groups`, groupName);
141
141
  if (!groupMentionSent && memberUids.length) {
142
- await sendNotificationToUids(postData, memberUids, groupName, `[[notifications:user_mentioned_group_in, ${author} , ${groupName}, ${titleEscaped}]]`);
142
+ await sendNotificationToUids(postData, memberUids, groupName, `[[notifications:user_mentioned_group_in, ${displayname} , ${groupName}, ${titleEscaped}]]`);
143
143
  await db.setAdd(`mentions:pid:${postData.pid}:groups`, groupName);
144
144
  }
145
145
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-mentions",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "NodeBB Plugin that allows users to mention other users by prepending an '@' sign to their username",
5
5
  "main": "library.js",
6
6
  "scripts": {
@@ -31,9 +31,9 @@
31
31
  "xregexp": "^5.1.0"
32
32
  },
33
33
  "devDependencies": {
34
- "mocha": "10.0.0",
35
- "eslint": "8.23.0",
36
- "eslint-config-nodebb": "0.1.1",
37
- "eslint-plugin-import": "2.26.0"
34
+ "mocha": "10.2.0",
35
+ "eslint": "8.32.0",
36
+ "eslint-config-nodebb": "0.2.1",
37
+ "eslint-plugin-import": "2.27.5"
38
38
  }
39
39
  }
package/static/admin.js CHANGED
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
- /* globals $, app, socket, define */
4
-
5
3
  define('admin/plugins/mentions', ['settings', 'alerts'], function (Settings, alerts) {
6
-
7
- var ACP = {};
4
+ const ACP = {};
8
5
 
9
6
  ACP.init = function () {
10
7
  Settings.load('mentions', $('.mentions-settings'));
@@ -18,9 +15,10 @@ define('admin/plugins/mentions', ['settings', 'alerts'], function (Settings, ale
18
15
  alert_id: 'mentions-saved',
19
16
  title: 'Settings Saved',
20
17
  message: 'Please reload your NodeBB to apply these settings',
18
+ timeout: 5000,
21
19
  clickfn: function () {
22
20
  socket.emit('admin.reload');
23
- }
21
+ },
24
22
  });
25
23
  });
26
24
  });
@@ -34,4 +32,4 @@ define('admin/plugins/mentions', ['settings', 'alerts'], function (Settings, ale
34
32
  }
35
33
 
36
34
  return ACP;
37
- });
35
+ });
@@ -83,7 +83,7 @@ $(document).ready(function () {
83
83
  }
84
84
 
85
85
  // Format suggestions as 'avatar username (fullname)'
86
- const avatar = helpers.buildAvatar(user, 'sm');
86
+ const avatar = helpers.buildAvatar(user, '24px', true);
87
87
  const fullname = user.fullname ? `(${user.fullname})` : '';
88
88
  carry.push(`${avatar} ${user.username} ${helpers.escape(fullname)}`);
89
89
 
@@ -56,6 +56,4 @@
56
56
  </div>
57
57
  </form>
58
58
 
59
- <button id="save" class="floating-button mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored">
60
- <i class="material-icons">save</i>
61
- </button>
59
+ <!-- IMPORT admin/partials/save_button.tpl -->
@@ -1,23 +1,24 @@
1
- 'use strict';
2
-
3
-
4
- const db = module.parent.require('./database');
5
- const batch = module.parent.require('./batch');
6
- module.exports = {
7
- name: 'Delete mentions:sent:<pid> sorted sets',
8
- timestamp: Date.UTC(2021, 10, 2),
9
- method: async function () {
10
- const { progress } = this;
11
- const nextPid = await db.getObjectField('global', 'nextPid');
12
- const allPids = [];
13
- for (let pid = 1; pid < nextPid; ++ pid) {
14
- allPids.push(pid);
15
- }
16
- await batch.processArray(allPids, async (pids) => {
17
- progress.incr(pids.length);
18
- await db.deleteAll(pids.map(pid => `mentions:sent:${pid}`));
19
- }, {
20
- batch: 500,
21
- });
22
- },
1
+ 'use strict';
2
+
3
+
4
+ const db = module.parent.require('./database');
5
+ const batch = module.parent.require('./batch');
6
+ module.exports = {
7
+ name: 'Delete mentions:sent:<pid> sorted sets',
8
+ timestamp: Date.UTC(2021, 10, 2),
9
+ method: async function () {
10
+ const { progress } = this;
11
+ const nextPid = await db.getObjectField('global', 'nextPid');
12
+ const allPids = [];
13
+ for (let pid = 1; pid < nextPid; ++pid) {
14
+ allPids.push(pid);
15
+ }
16
+ progress.total = allPids.length;
17
+ await batch.processArray(allPids, async (pids) => {
18
+ progress.incr(pids.length);
19
+ await db.deleteAll(pids.map(pid => `mentions:sent:${pid}`));
20
+ }, {
21
+ batch: 500,
22
+ });
23
+ },
23
24
  };