nodebb-plugin-mentions 3.0.4 → 3.0.7
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 +2 -1
- package/package.json +4 -4
- package/plugin.json +3 -3
- package/static/.eslintrc +3 -0
- package/static/autofill.js +15 -14
package/library.js
CHANGED
|
@@ -388,7 +388,8 @@ async function stripDisallowedFullnames(users) {
|
|
|
388
388
|
|
|
389
389
|
SocketPlugins.mentions.getTopicUsers = async (socket, data) => {
|
|
390
390
|
const uids = await Topics.getUids(data.tid);
|
|
391
|
-
|
|
391
|
+
let users = await User.getUsers(uids);
|
|
392
|
+
users = users.filter(u => u && u.userslug);
|
|
392
393
|
if (Meta.config.hideFullname) {
|
|
393
394
|
return users;
|
|
394
395
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-mentions",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
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.1
|
|
35
|
-
"eslint": "8.
|
|
34
|
+
"mocha": "9.2.1",
|
|
35
|
+
"eslint": "8.10.0",
|
|
36
36
|
"eslint-config-nodebb": "0.1.1",
|
|
37
|
-
"eslint-plugin-import": "2.25.
|
|
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/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,21 +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) {
|
|
122
124
|
alerts.error(err);
|
|
123
|
-
})
|
|
125
|
+
});
|
|
124
126
|
return;
|
|
125
127
|
}
|
|
126
128
|
groupList = groupNames;
|
|
127
129
|
});
|
|
128
130
|
}
|
|
129
|
-
|
|
130
131
|
});
|