@nodebb/nodebb-plugin-reactions 2.1.11 → 2.1.12
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 +20 -8
- package/package.json +1 -1
package/library.js
CHANGED
|
@@ -11,13 +11,25 @@ const websockets = require.main.require('./src/socket.io/index');
|
|
|
11
11
|
const SocketPlugins = require.main.require('./src/socket.io/plugins');
|
|
12
12
|
|
|
13
13
|
const emojiParser = require.main.require('nodebb-plugin-emoji/build/lib/parse.js');
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
|
|
15
|
+
let emojiTable = null;
|
|
16
|
+
let emojiAliases = null;
|
|
16
17
|
|
|
17
18
|
const DEFAULT_MAX_EMOTES = 4;
|
|
18
19
|
|
|
20
|
+
function nameToEmoji(name) {
|
|
21
|
+
if (!emojiTable) {
|
|
22
|
+
emojiTable = require.main.require('nodebb-plugin-emoji/build/emoji/table.json');
|
|
23
|
+
}
|
|
24
|
+
return emojiTable[name];
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
function parse(name) {
|
|
20
|
-
|
|
28
|
+
if (!emojiAliases) {
|
|
29
|
+
emojiAliases = require.main.require('nodebb-plugin-emoji/build/emoji/aliases.json');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return emojiParser.buildEmoji(nameToEmoji(name) || emojiTable[emojiAliases[name]], '');
|
|
21
33
|
}
|
|
22
34
|
|
|
23
35
|
const ReactionsPlugin = module.exports;
|
|
@@ -295,7 +307,7 @@ SocketPlugins.reactions = {
|
|
|
295
307
|
throw new Error('[[error:not-logged-in]]');
|
|
296
308
|
}
|
|
297
309
|
|
|
298
|
-
if (!
|
|
310
|
+
if (!nameToEmoji(data.reaction)) {
|
|
299
311
|
throw new Error('[[reactions:error.invalid-reaction]]');
|
|
300
312
|
}
|
|
301
313
|
|
|
@@ -349,7 +361,7 @@ SocketPlugins.reactions = {
|
|
|
349
361
|
throw new Error('[[error:not-logged-in]]');
|
|
350
362
|
}
|
|
351
363
|
|
|
352
|
-
if (!
|
|
364
|
+
if (!nameToEmoji(data.reaction)) {
|
|
353
365
|
throw new Error('[[reactions:error.invalid-reaction]]');
|
|
354
366
|
}
|
|
355
367
|
|
|
@@ -387,7 +399,7 @@ SocketPlugins.reactions = {
|
|
|
387
399
|
throw new Error('[[error:not-logged-in]]');
|
|
388
400
|
}
|
|
389
401
|
|
|
390
|
-
if (!
|
|
402
|
+
if (!nameToEmoji(data.reaction)) {
|
|
391
403
|
throw new Error('[[reactions:error.invalid-reaction]]');
|
|
392
404
|
}
|
|
393
405
|
|
|
@@ -438,7 +450,7 @@ SocketPlugins.reactions = {
|
|
|
438
450
|
throw new Error('[[error:not-logged-in]]');
|
|
439
451
|
}
|
|
440
452
|
|
|
441
|
-
if (!
|
|
453
|
+
if (!nameToEmoji(data.reaction)) {
|
|
442
454
|
throw new Error('[[reactions:error.invalid-reaction]]');
|
|
443
455
|
}
|
|
444
456
|
|
|
@@ -470,7 +482,7 @@ SocketPlugins.reactions = {
|
|
|
470
482
|
if (!socket.uid) {
|
|
471
483
|
throw new Error('[[error:not-logged-in]]');
|
|
472
484
|
}
|
|
473
|
-
if (!
|
|
485
|
+
if (!nameToEmoji(data.reaction)) {
|
|
474
486
|
throw new Error('[[reactions:error.invalid-reaction]]');
|
|
475
487
|
}
|
|
476
488
|
let set = '';
|