nodebb-plugin-mentions 2.14.1 → 3.0.0

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.
Files changed (52) hide show
  1. package/.eslintrc +3 -0
  2. package/LICENSE +7 -7
  3. package/README.md +13 -13
  4. package/controllers.js +5 -9
  5. package/languages/ar/notifications.json +2 -2
  6. package/languages/bg/notifications.json +2 -2
  7. package/languages/bn/notifications.json +2 -2
  8. package/languages/da/notifications.json +2 -2
  9. package/languages/de/notifications.json +5 -5
  10. package/languages/el/notifications.json +2 -2
  11. package/languages/en@pirate/notifications.json +4 -4
  12. package/languages/en_GB/mentions.json +3 -3
  13. package/languages/en_GB/notifications.json +6 -6
  14. package/languages/en_US/notifications.json +4 -4
  15. package/languages/es/notifications.json +3 -3
  16. package/languages/et/notifications.json +2 -2
  17. package/languages/fa_IR/notifications.json +4 -4
  18. package/languages/fi/notifications.json +2 -2
  19. package/languages/fr/notifications.json +5 -5
  20. package/languages/gl/notifications.json +2 -2
  21. package/languages/he/notifications.json +2 -2
  22. package/languages/id/notifications.json +2 -2
  23. package/languages/it/notifications.json +3 -3
  24. package/languages/ja/notifications.json +4 -4
  25. package/languages/jbo/notifications.json +4 -4
  26. package/languages/ko/notifications.json +2 -2
  27. package/languages/lt/notifications.json +2 -2
  28. package/languages/ms/notifications.json +2 -2
  29. package/languages/nb/notifications.json +2 -2
  30. package/languages/nl/notifications.json +2 -2
  31. package/languages/pl/mentions.json +3 -3
  32. package/languages/pl/notifications.json +6 -6
  33. package/languages/pt-PT/notifications.json +6 -6
  34. package/languages/pt_BR/notifications.json +3 -3
  35. package/languages/ro/notifications.json +2 -2
  36. package/languages/rw/notifications.json +2 -2
  37. package/languages/sl/notifications.json +2 -2
  38. package/languages/sr/notifications.json +2 -2
  39. package/languages/sv/notifications.json +2 -2
  40. package/languages/tr/notifications.json +6 -6
  41. package/languages/vi/notifications.json +2 -2
  42. package/languages/zh-CN/mentions.json +3 -3
  43. package/languages/zh-CN/notifications.json +5 -5
  44. package/languages/zh_TW/notifications.json +2 -2
  45. package/lib/utility.js +6 -4
  46. package/library.js +200 -268
  47. package/package.json +8 -5
  48. package/plugin.json +30 -26
  49. package/static/admin.js +35 -35
  50. package/templates/admin/plugins/mentions.tpl +64 -64
  51. package/upgrades/mentions_delete_mentions_set_zset.js +21 -0
  52. package/.jshintrc +0 -86
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-mentions",
3
- "version": "2.14.1",
3
+ "version": "3.0.0",
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": {
@@ -25,12 +25,15 @@
25
25
  "compatibility": "^1.15.0"
26
26
  },
27
27
  "dependencies": {
28
- "async": "^2",
29
- "html-entities": "^1.2.1",
30
- "validator": "^9.1.1",
28
+ "html-entities": "^2.3.2",
29
+ "lodash": "4.17.21",
30
+ "validator": "^13.0.0",
31
31
  "xregexp": "^5.1.0"
32
32
  },
33
33
  "devDependencies": {
34
- "mocha": "9.1.2"
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
38
  }
36
39
  }
package/plugin.json CHANGED
@@ -1,27 +1,31 @@
1
- {
2
- "id": "nodebb-plugin-mentions",
3
- "name": "Username Mentions",
4
- "description": "NodeBB Plugin that allows users to mention other users by prepending an '@' sign to their username",
5
- "url": "https://github.com/julianlam/nodebb-plugin-mentions",
6
- "library": "./library.js",
7
- "hooks": [
8
- { "hook": "static:app.load", "method": "init" },
9
- { "hook": "filter:admin.header.build", "method": "addAdminNavigation" },
10
- { "hook": "filter:parse.post", "method": "parsePost" },
11
- { "hook": "filter:parse.raw", "method": "parseRaw" },
12
- { "hook": "action:post.save", "method": "notify" },
13
- { "hook": "action:post.edit", "method": "notify" },
14
- { "hook": "filter:notifications.addFilters", "method": "addFilters" },
15
- { "hook": "filter:user.notificationTypes", "method": "notificationTypes" },
16
- { "hook": "filter:users.addFields", "method": "addFields" }
17
- ],
18
- "scripts": [
19
- "static/autofill.js"
20
- ],
21
- "acpScripts": [
22
- "static/admin.js"
23
- ],
24
- "languages": "languages",
25
- "defaultLang": "en_GB",
26
- "templates": "templates"
1
+ {
2
+ "id": "nodebb-plugin-mentions",
3
+ "name": "Username Mentions",
4
+ "description": "NodeBB Plugin that allows users to mention other users by prepending an '@' sign to their username",
5
+ "url": "https://github.com/julianlam/nodebb-plugin-mentions",
6
+ "library": "./library.js",
7
+ "upgrades": [
8
+ "upgrades/mentions_delete_mentions_set_zset.js"
9
+ ],
10
+ "hooks": [
11
+ { "hook": "static:app.load", "method": "init" },
12
+ { "hook": "filter:admin.header.build", "method": "addAdminNavigation" },
13
+ { "hook": "filter:parse.post", "method": "parsePost" },
14
+ { "hook": "filter:parse.raw", "method": "parseRaw" },
15
+ { "hook": "action:post.save", "method": "notify" },
16
+ { "hook": "action:post.edit", "method": "notify" },
17
+ { "hook": "action:post.purge", "method": "actionPostPurge" },
18
+ { "hook": "filter:notifications.addFilters", "method": "addFilters" },
19
+ { "hook": "filter:user.notificationTypes", "method": "notificationTypes" },
20
+ { "hook": "filter:users.addFields", "method": "addFields" }
21
+ ],
22
+ "scripts": [
23
+ "static/autofill.js"
24
+ ],
25
+ "acpScripts": [
26
+ "static/admin.js"
27
+ ],
28
+ "languages": "languages",
29
+ "defaultLang": "en_GB",
30
+ "templates": "templates"
27
31
  }
package/static/admin.js CHANGED
@@ -1,36 +1,36 @@
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
+ /* 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;
36
36
  });
@@ -1,65 +1,65 @@
1
- <form role="form" class="mentions-settings">
2
- <div class="row">
3
- <div class="col-sm-2 col-xs-12 settings-header">General</div>
4
- <div class="col-sm-10 col-xs-12">
5
- <div class="form-group">
6
- <div class="checkbox">
7
- <label for="autofillGroups" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
8
- <input type="checkbox" class="mdl-switch__input" id="autofillGroups" name="autofillGroups" />
9
- <span class="mdl-switch__label">Allow mentioning User Groups</span>
10
- </label>
11
- </div>
12
- </div>
13
- <div class="form-group">
14
- <div class="checkbox">
15
- <label for="overrideIgnores" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
16
- <input type="checkbox" class="mdl-switch__input" id="overrideIgnores" name="overrideIgnores" />
17
- <span class="mdl-switch__label">Notify recipients of mentions even if topic is explictly ignored</span>
18
- </label>
19
- </div>
20
- </div>
21
- <div class="form-group">
22
- <label for="disableGroupMentions">Select groups you wish to disable mentions</label>
23
- <select class="form-control" id="disableGroupMentions" name="disableGroupMentions" multiple>
24
- <!-- BEGIN groups -->
25
- <option value="{groups.displayName}">{groups.displayName}</option>
26
- <!-- END groups -->
27
- </select>
28
- </div>
29
- <div class="form-group">
30
- <label for="display">Mentions will display ...</label>
31
- <select class="form-control" id="display" name="display">
32
- <option value="">... as written</option>
33
- <option value="fullname">... as user&apos;s full name (if set)</option>
34
- <option value="username">... as user&apos;s username</option>
35
- </select>
36
- </div>
37
- </div>
38
- </div>
39
-
40
- <div class="row">
41
- <div class="col-sm-2 col-xs-12 settings-header">Restrictions</div>
42
- <div class="col-sm-10 col-xs-12">
43
- <div class="form-group">
44
- <div class="checkbox">
45
- <label for="disableFollowedTopics" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
46
- <input type="checkbox" class="mdl-switch__input" id="disableFollowedTopics" name="disableFollowedTopics" />
47
- <span class="mdl-switch__label">Disable mentions for followed topics</span>
48
- </label>
49
- </div>
50
- </div>
51
- <div class="form-group">
52
- <div class="checkbox">
53
- <label for="privilegedDirectReplies" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
54
- <input type="checkbox" class="mdl-switch__input" id="privilegedDirectReplies" name="privilegedDirectReplies" />
55
- <span class="mdl-switch__label">Restrict mentions to privileged users (mods, global mods, administrators), unless it is a direct reply to a post</span>
56
- </label>
57
- </div>
58
- </div>
59
- </div>
60
- </div>
61
- </form>
62
-
63
- <button id="save" class="floating-button mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored">
64
- <i class="material-icons">save</i>
1
+ <form role="form" class="mentions-settings">
2
+ <div class="row">
3
+ <div class="col-sm-2 col-xs-12 settings-header">General</div>
4
+ <div class="col-sm-10 col-xs-12">
5
+ <div class="form-group">
6
+ <div class="checkbox">
7
+ <label for="autofillGroups" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
8
+ <input type="checkbox" class="mdl-switch__input" id="autofillGroups" name="autofillGroups" />
9
+ <span class="mdl-switch__label">Allow mentioning User Groups</span>
10
+ </label>
11
+ </div>
12
+ </div>
13
+ <div class="form-group">
14
+ <div class="checkbox">
15
+ <label for="overrideIgnores" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
16
+ <input type="checkbox" class="mdl-switch__input" id="overrideIgnores" name="overrideIgnores" />
17
+ <span class="mdl-switch__label">Notify recipients of mentions even if topic is explictly ignored</span>
18
+ </label>
19
+ </div>
20
+ </div>
21
+ <div class="form-group">
22
+ <label for="disableGroupMentions">Select groups you wish to disable mentions</label>
23
+ <select class="form-control" id="disableGroupMentions" name="disableGroupMentions" multiple>
24
+ <!-- BEGIN groups -->
25
+ <option value="{groups.displayName}">{groups.displayName}</option>
26
+ <!-- END groups -->
27
+ </select>
28
+ </div>
29
+ <div class="form-group">
30
+ <label for="display">Mentions will display ...</label>
31
+ <select class="form-control" id="display" name="display">
32
+ <option value="">... as written</option>
33
+ <option value="fullname">... as user&apos;s full name (if set)</option>
34
+ <option value="username">... as user&apos;s username</option>
35
+ </select>
36
+ </div>
37
+ </div>
38
+ </div>
39
+
40
+ <div class="row">
41
+ <div class="col-sm-2 col-xs-12 settings-header">Restrictions</div>
42
+ <div class="col-sm-10 col-xs-12">
43
+ <div class="form-group">
44
+ <div class="checkbox">
45
+ <label for="disableFollowedTopics" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
46
+ <input type="checkbox" class="mdl-switch__input" id="disableFollowedTopics" name="disableFollowedTopics" />
47
+ <span class="mdl-switch__label">Disable mentions for followed topics</span>
48
+ </label>
49
+ </div>
50
+ </div>
51
+ <div class="form-group">
52
+ <div class="checkbox">
53
+ <label for="privilegedDirectReplies" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
54
+ <input type="checkbox" class="mdl-switch__input" id="privilegedDirectReplies" name="privilegedDirectReplies" />
55
+ <span class="mdl-switch__label">Restrict mentions to privileged users (mods, global mods, administrators), unless it is a direct reply to a post</span>
56
+ </label>
57
+ </div>
58
+ </div>
59
+ </div>
60
+ </div>
61
+ </form>
62
+
63
+ <button id="save" class="floating-button mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored">
64
+ <i class="material-icons">save</i>
65
65
  </button>
@@ -0,0 +1,21 @@
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 nextPid = await db.getObjectField('global', 'nextPid');
11
+ const allPids = [];
12
+ for (let pid = 1; pid < nextPid; ++ pid) {
13
+ allPids.push(pid);
14
+ }
15
+ await batch.processArray(allPids, async (pids) => {
16
+ await db.deleteAll(pids.map(pid => `mentions:sent:${pid}`));
17
+ }, {
18
+ batch: 500,
19
+ });
20
+ },
21
+ };
package/.jshintrc DELETED
@@ -1,86 +0,0 @@
1
- {
2
- // JSHint Default Configuration File (as on JSHint website)
3
- // See http://jshint.com/docs/ for more details
4
-
5
- "maxerr" : 50, // {int} Maximum error before stopping
6
-
7
- // Enforcing
8
- "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
9
- "camelcase" : false, // true: Identifiers must be in camelCase
10
- "curly" : true, // true: Require {} for every new block or scope
11
- "eqeqeq" : true, // true: Require triple equals (===) for comparison
12
- "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
13
- "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
14
- "indent" : 4, // {int} Number of spaces to use for indentation
15
- "latedef" : false, // true: Require variables/functions to be defined before being used
16
- "newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()`
17
- "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
18
- "noempty" : true, // true: Prohibit use of empty blocks
19
- "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
20
- "plusplus" : false, // true: Prohibit use of `++` & `--`
21
- "quotmark" : false, // Quotation mark consistency:
22
- // false : do nothing (default)
23
- // true : ensure whatever is used is consistent
24
- // "single" : require single quotes
25
- // "double" : require double quotes
26
- "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
27
- "unused" : true, // true: Require all defined variables be used
28
- "strict" : true, // true: Requires all functions run in ES5 Strict Mode
29
- "trailing" : false, // true: Prohibit trailing whitespaces
30
- "maxparams" : false, // {int} Max number of formal params allowed per function
31
- "maxdepth" : false, // {int} Max depth of nested blocks (within functions)
32
- "maxstatements" : false, // {int} Max number statements per function
33
- "maxcomplexity" : false, // {int} Max cyclomatic complexity per function
34
- "maxlen" : false, // {int} Max number of characters per line
35
-
36
- // Relaxing
37
- "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
38
- "boss" : false, // true: Tolerate assignments where comparisons would be expected
39
- "debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
40
- "eqnull" : false, // true: Tolerate use of `== null`
41
- "es5" : false, // true: Allow ES5 syntax (ex: getters and setters)
42
- "esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
43
- "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
44
- // (ex: `for each`, multiple try/catch, function expression…)
45
- "evil" : false, // true: Tolerate use of `eval` and `new Function()`
46
- "expr" : false, // true: Tolerate `ExpressionStatement` as Programs
47
- "funcscope" : false, // true: Tolerate defining variables inside control statements"
48
- "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
49
- "iterator" : false, // true: Tolerate using the `__iterator__` property
50
- "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
51
- "laxbreak" : false, // true: Tolerate possibly unsafe line breakings
52
- "laxcomma" : false, // true: Tolerate comma-first style coding
53
- "loopfunc" : false, // true: Tolerate functions being defined in loops
54
- "multistr" : false, // true: Tolerate multi-line strings
55
- "proto" : false, // true: Tolerate using the `__proto__` property
56
- "scripturl" : false, // true: Tolerate script-targeted URLs
57
- "smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment
58
- "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
59
- "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
60
- "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
61
- "validthis" : false, // true: Tolerate using this in a non-constructor function
62
-
63
- // Environments
64
- "browser" : true, // Web Browser (window, document, etc)
65
- "couch" : false, // CouchDB
66
- "devel" : true, // Development/debugging (alert, confirm, etc)
67
- "dojo" : false, // Dojo Toolkit
68
- "jquery" : true, // jQuery
69
- "mootools" : false, // MooTools
70
- "node" : true, // Node.js
71
- "nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
72
- "prototypejs" : false, // Prototype and Scriptaculous
73
- "rhino" : false, // Rhino
74
- "worker" : false, // Web Workers
75
- "wsh" : false, // Windows Scripting Host
76
- "yui" : false, // Yahoo User Interface
77
-
78
- // Legacy
79
- "nomen" : false, // true: Prohibit dangling `_` in variables
80
- "onevar" : false, // true: Allow only one `var` statement per function
81
- "passfail" : false, // true: Stop on first error
82
- "white" : false, // true: Check against strict whitespace and indentation rules
83
-
84
- // Custom Globals
85
- "globals" : {} // additional predefined global variables
86
- }