nodebb-plugin-mentions 3.0.2 → 3.0.6
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 +6 -4
- package/package.json +5 -5
- package/plugin.json +3 -3
- package/static/.eslintrc +3 -0
- package/static/admin.js +36 -35
- package/static/autofill.js +18 -14
package/library.js
CHANGED
|
@@ -170,10 +170,12 @@ async function getGroupsToNotify(matches) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
Mentions.actionPostPurge = async (hookData) => {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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.
|
|
3
|
+
"version": "3.0.6",
|
|
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": "9.
|
|
35
|
-
"eslint": "8.
|
|
36
|
-
"eslint-config-nodebb": "0.
|
|
37
|
-
"eslint-plugin-import": "2.25.
|
|
34
|
+
"mocha": "9.2.0",
|
|
35
|
+
"eslint": "8.9.0",
|
|
36
|
+
"eslint-config-nodebb": "0.1.1",
|
|
37
|
+
"eslint-plugin-import": "2.25.4"
|
|
38
38
|
}
|
|
39
39
|
}
|
package/plugin.json
CHANGED
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"scripts": [
|
|
23
23
|
"static/autofill.js"
|
|
24
24
|
],
|
|
25
|
-
"
|
|
26
|
-
"static/admin.js"
|
|
27
|
-
|
|
25
|
+
"modules": {
|
|
26
|
+
"../admin/plugins/mentions.js": "./static/admin.js"
|
|
27
|
+
},
|
|
28
28
|
"languages": "languages",
|
|
29
29
|
"defaultLang": "en_GB",
|
|
30
30
|
"templates": "templates"
|
package/static/.eslintrc
ADDED
package/static/admin.js
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
$('input#autofillGroups').
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
});
|
package/static/autofill.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* globals socket, app */
|
|
3
1
|
|
|
2
|
+
'use strict';
|
|
4
3
|
|
|
5
|
-
$(document).ready(function() {
|
|
4
|
+
$(document).ready(function () {
|
|
6
5
|
let groupList = [];
|
|
7
6
|
let localUserList = [];
|
|
8
7
|
|
|
9
|
-
$(window).on('composer:autocomplete:init chat:autocomplete:init', function(ev, data) {
|
|
8
|
+
$(window).on('composer:autocomplete:init chat:autocomplete:init', function (ev, data) {
|
|
10
9
|
loadTopicUsers(data.element);
|
|
11
10
|
|
|
12
11
|
if (!groupList.length) {
|
|
@@ -30,7 +29,7 @@ $(document).ready(function() {
|
|
|
30
29
|
socket.emit('plugins.mentions.userSearch', {
|
|
31
30
|
query: term,
|
|
32
31
|
composerObj: composer.posts[uuid],
|
|
33
|
-
}, function(err, users) {
|
|
32
|
+
}, function (err, users) {
|
|
34
33
|
if (err) {
|
|
35
34
|
return callback([]);
|
|
36
35
|
}
|
|
@@ -40,7 +39,7 @@ $(document).ready(function() {
|
|
|
40
39
|
// Add groups that start with the search term
|
|
41
40
|
const groupMentions = groupList.filter(function (groupName) {
|
|
42
41
|
return groupName.toLocaleLowerCase().startsWith(term.toLocaleLowerCase());
|
|
43
|
-
}).sort(function(a, b) {
|
|
42
|
+
}).sort(function (a, b) {
|
|
44
43
|
return a.toLocaleLowerCase() > b.toLocaleLowerCase() ? 1 : -1;
|
|
45
44
|
});
|
|
46
45
|
// Add group mentions at the bottom of dropdown
|
|
@@ -59,24 +58,24 @@ $(document).ready(function() {
|
|
|
59
58
|
mention.find('span').remove();
|
|
60
59
|
return '@' + slugify(mention.text(), true) + ' ';
|
|
61
60
|
},
|
|
62
|
-
cache: true
|
|
61
|
+
cache: true,
|
|
63
62
|
};
|
|
64
63
|
|
|
65
64
|
data.strategies.push(strategy);
|
|
66
65
|
});
|
|
67
66
|
|
|
68
|
-
$(window).on('action:composer.loaded', function(
|
|
67
|
+
$(window).on('action:composer.loaded', function (ev, data) {
|
|
69
68
|
const composer = $('#cmp-uuid-' + data.post_uuid + ' .write');
|
|
70
69
|
composer.attr('data-mentions', '1');
|
|
71
70
|
});
|
|
72
71
|
|
|
73
|
-
function sortUsers
|
|
72
|
+
function sortUsers(users) {
|
|
74
73
|
return users.sort(function (user1, user2) {
|
|
75
74
|
return user1.username.toLocaleLowerCase() > user2.username.toLocaleLowerCase() ? 1 : -1;
|
|
76
75
|
});
|
|
77
76
|
}
|
|
78
77
|
|
|
79
|
-
function usersToMentions
|
|
78
|
+
function usersToMentions(users, helpers) {
|
|
80
79
|
return users.reduce(function (carry, user) {
|
|
81
80
|
// Don't add current user to suggestions
|
|
82
81
|
if (app.user.username && app.user.username === user.username) {
|
|
@@ -93,7 +92,7 @@ $(document).ready(function() {
|
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
function loadTopicUsers(element) {
|
|
96
|
-
require(['composer'], function (composer) {
|
|
95
|
+
require(['composer', 'alerts'], function (composer, alerts) {
|
|
97
96
|
const composerEl = element.parents('.composer').get(0);
|
|
98
97
|
if (!composerEl) {
|
|
99
98
|
return;
|
|
@@ -110,18 +109,23 @@ $(document).ready(function() {
|
|
|
110
109
|
socket.emit('plugins.mentions.getTopicUsers', {
|
|
111
110
|
tid: composerObj.tid,
|
|
112
111
|
}, function (err, users) {
|
|
112
|
+
if (err) {
|
|
113
|
+
return alerts.error(err);
|
|
114
|
+
}
|
|
113
115
|
localUserList = users;
|
|
114
116
|
});
|
|
115
117
|
});
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
function loadGroupList() {
|
|
119
|
-
socket.emit('plugins.mentions.listGroups', function(err, groupNames) {
|
|
121
|
+
socket.emit('plugins.mentions.listGroups', function (err, groupNames) {
|
|
120
122
|
if (err) {
|
|
121
|
-
|
|
123
|
+
require(['alerts'], function (alerts) {
|
|
124
|
+
alerts.error(err);
|
|
125
|
+
});
|
|
126
|
+
return;
|
|
122
127
|
}
|
|
123
128
|
groupList = groupNames;
|
|
124
129
|
});
|
|
125
130
|
}
|
|
126
|
-
|
|
127
131
|
});
|