nodebb-plugin-mentions 4.8.15 → 4.8.17
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 +4 -0
- package/package.json +2 -2
- package/static/autofill.js +38 -47
package/library.js
CHANGED
|
@@ -587,6 +587,10 @@ async function stripDisallowedFullnames(users) {
|
|
|
587
587
|
*/
|
|
588
588
|
|
|
589
589
|
SocketPlugins.mentions.getTopicUsers = async (socket, data) => {
|
|
590
|
+
const canRead = await privileges.topics.can('read', data.tid, socket.uid);
|
|
591
|
+
if (!canRead) {
|
|
592
|
+
throw new Error('[[error:no-privileges]]');
|
|
593
|
+
}
|
|
590
594
|
const uids = await Topics.getUids(data.tid);
|
|
591
595
|
let users = await User.getUsers(uids);
|
|
592
596
|
users = users.filter(u => u && u.userslug);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-mentions",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.17",
|
|
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
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"html-entities": "^2.3.2",
|
|
29
|
-
"lodash": "4.17.
|
|
29
|
+
"lodash": "4.17.23",
|
|
30
30
|
"validator": "^13.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
package/static/autofill.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
$(document).ready(function () {
|
|
5
|
-
let groupList
|
|
5
|
+
let groupList;
|
|
6
|
+
let localUserList;
|
|
6
7
|
let categoryList;
|
|
7
8
|
const categorySlugMap = new Map();
|
|
8
|
-
let localUserList = [];
|
|
9
9
|
let helpers;
|
|
10
10
|
|
|
11
11
|
function showAlert(type, message) {
|
|
@@ -15,15 +15,14 @@ $(document).ready(function () {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
$(window).on('composer:autocomplete:init chat:autocomplete:init', function (ev, data) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
18
|
+
// load the data for lists on focus of textarea element
|
|
19
|
+
data.element.one('focus', async function () {
|
|
20
|
+
await Promise.all([
|
|
21
|
+
loadTopicUsers(data.element),
|
|
22
|
+
groupList ? Promise.resolve() : loadGroupList(),
|
|
23
|
+
categoryList ? Promise.resolve() : loadCategoryList(),
|
|
24
|
+
]);
|
|
25
|
+
});
|
|
27
26
|
|
|
28
27
|
let slugify;
|
|
29
28
|
const strategy = {
|
|
@@ -135,56 +134,48 @@ $(document).ready(function () {
|
|
|
135
134
|
}
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
function loadTopicUsers(element) {
|
|
139
|
-
require(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (ajaxify.data.template.topic) {
|
|
150
|
-
return ajaxify.data.tid;
|
|
137
|
+
async function loadTopicUsers(element) {
|
|
138
|
+
const composer = await app.require('composer');
|
|
139
|
+
function findTid() {
|
|
140
|
+
const composerEl = element.parents('.composer').get(0);
|
|
141
|
+
if (composerEl) {
|
|
142
|
+
const uuid = composerEl.getAttribute('data-uuid');
|
|
143
|
+
const composerObj = composer.posts[uuid];
|
|
144
|
+
if (composerObj && composerObj.tid) {
|
|
145
|
+
return composerObj.tid;
|
|
151
146
|
}
|
|
152
|
-
return null;
|
|
153
147
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (!tid) {
|
|
157
|
-
localUserList = [];
|
|
158
|
-
return;
|
|
148
|
+
if (ajaxify.data.template.topic) {
|
|
149
|
+
return ajaxify.data.tid;
|
|
159
150
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const tid = findTid();
|
|
155
|
+
if (!tid) {
|
|
156
|
+
localUserList = [];
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
localUserList = await socket.emit('plugins.mentions.getTopicUsers', {
|
|
160
|
+
tid: tid,
|
|
161
|
+
}).catch(err => showAlert('error', err));
|
|
169
162
|
}
|
|
170
163
|
|
|
171
164
|
async function loadGroupList() {
|
|
172
165
|
groupList = await socket.emit('plugins.mentions.listGroups');
|
|
173
166
|
const [translator, helpers] = await app.require(['translator', 'helpers']);
|
|
174
167
|
await Promise.all(groupList.map(async (group) => {
|
|
175
|
-
group.memberCount = 12312313;
|
|
176
168
|
const key = translator.compile('groups:x-members', helpers.formattedNumber(group.memberCount));
|
|
177
169
|
group.memberCountText = await translator.translate(key);
|
|
178
170
|
}));
|
|
179
171
|
}
|
|
180
172
|
|
|
181
|
-
function loadCategoryList() {
|
|
182
|
-
require(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
});
|
|
173
|
+
async function loadCategoryList() {
|
|
174
|
+
const api = await app.require('api');
|
|
175
|
+
const { categories } = await api.get('/categories');
|
|
176
|
+
categoryList = categories;
|
|
177
|
+
categories.forEach((category) => {
|
|
178
|
+
categorySlugMap.set(category.name.toLowerCase(), category.handle);
|
|
188
179
|
});
|
|
189
180
|
}
|
|
190
181
|
});
|