nodebb-plugin-mentions 3.0.0 → 3.0.4

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
@@ -170,10 +170,12 @@ async function getGroupsToNotify(matches) {
170
170
  }
171
171
 
172
172
  Mentions.actionPostPurge = async (hookData) => {
173
- await db.deleteAll([
174
- `mentions:pid:${hookData.postData.pid}:uids`,
175
- `mentions:pid:${hookData.postData.pid}:groups`,
176
- ]);
173
+ if (hookData && hookData.post) {
174
+ await db.deleteAll([
175
+ `mentions:pid:${hookData.post.pid}:uids`,
176
+ `mentions:pid:${hookData.post.pid}:groups`,
177
+ ]);
178
+ }
177
179
  };
178
180
 
179
181
  async function filterUidsAlreadyMentioned(uids, pid) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-mentions",
3
- "version": "3.0.0",
3
+ "version": "3.0.4",
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": {
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "mocha": "9.1.3",
35
- "eslint": "8.1.0",
36
- "eslint-config-nodebb": "^0.0.3",
37
- "eslint-plugin-import": "^2.24.2"
35
+ "eslint": "8.4.0",
36
+ "eslint-config-nodebb": "0.1.1",
37
+ "eslint-plugin-import": "2.25.3"
38
38
  }
39
39
  }
package/static/admin.js CHANGED
@@ -1,36 +1,37 @@
1
- 'use strict';
2
- /* globals $, app, socket */
3
-
4
- define('admin/plugins/mentions', ['settings'], function (Settings) {
5
-
6
- var ACP = {};
7
-
8
- ACP.init = function () {
9
- Settings.load('mentions', $('.mentions-settings'));
10
-
11
- $(window).on('action:admin.settingsLoaded', applyDefaults);
12
-
13
- $('#save').on('click', function () {
14
- Settings.save('mentions', $('.mentions-settings'), function () {
15
- app.alert({
16
- type: 'success',
17
- alert_id: 'mentions-saved',
18
- title: 'Settings Saved',
19
- message: 'Please reload your NodeBB to apply these settings',
20
- clickfn: function () {
21
- socket.emit('admin.reload');
22
- }
23
- });
24
- });
25
- });
26
- };
27
-
28
- function applyDefaults() {
29
- if (!ajaxify.data.settings || !ajaxify.data.settings.hasOwnProperty('autofillGroups')) {
30
- $('input#autofillGroups').parents('.mdl-switch').toggleClass('is-checked', false);
31
- $('input#autofillGroups').prop('checked', false);
32
- }
33
- }
34
-
35
- return ACP;
1
+ 'use strict';
2
+
3
+ /* globals $, app, socket, define */
4
+
5
+ define('admin/plugins/mentions', ['settings', 'alerts'], function (Settings, alerts) {
6
+
7
+ var ACP = {};
8
+
9
+ ACP.init = function () {
10
+ Settings.load('mentions', $('.mentions-settings'));
11
+
12
+ $(window).on('action:admin.settingsLoaded', applyDefaults);
13
+
14
+ $('#save').on('click', function () {
15
+ Settings.save('mentions', $('.mentions-settings'), function () {
16
+ alerts.alert({
17
+ type: 'success',
18
+ alert_id: 'mentions-saved',
19
+ title: 'Settings Saved',
20
+ message: 'Please reload your NodeBB to apply these settings',
21
+ clickfn: function () {
22
+ socket.emit('admin.reload');
23
+ }
24
+ });
25
+ });
26
+ });
27
+ };
28
+
29
+ function applyDefaults() {
30
+ if (!ajaxify.data.settings || !ajaxify.data.settings.hasOwnProperty('autofillGroups')) {
31
+ $('input#autofillGroups').parents('.mdl-switch').toggleClass('is-checked', false);
32
+ $('input#autofillGroups').prop('checked', false);
33
+ }
34
+ }
35
+
36
+ return ACP;
36
37
  });
@@ -118,7 +118,10 @@ $(document).ready(function() {
118
118
  function loadGroupList() {
119
119
  socket.emit('plugins.mentions.listGroups', function(err, groupNames) {
120
120
  if (err) {
121
- return app.alertError(err.message);
121
+ require(['alerts'], function (alerts) {
122
+ alerts.error(err);
123
+ })
124
+ return;
122
125
  }
123
126
  groupList = groupNames;
124
127
  });
@@ -7,12 +7,14 @@ module.exports = {
7
7
  name: 'Delete mentions:sent:<pid> sorted sets',
8
8
  timestamp: Date.UTC(2021, 10, 2),
9
9
  method: async function () {
10
+ const { progress } = this;
10
11
  const nextPid = await db.getObjectField('global', 'nextPid');
11
12
  const allPids = [];
12
13
  for (let pid = 1; pid < nextPid; ++ pid) {
13
14
  allPids.push(pid);
14
15
  }
15
16
  await batch.processArray(allPids, async (pids) => {
17
+ progress.incr(pids.length);
16
18
  await db.deleteAll(pids.map(pid => `mentions:sent:${pid}`));
17
19
  }, {
18
20
  batch: 500,