@nodebb/nodebb-plugin-reactions 3.1.6 → 3.1.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 CHANGED
@@ -52,6 +52,15 @@ async function parseReaction(name) {
52
52
  return '';
53
53
  }
54
54
 
55
+ async function isValidReaction(name) {
56
+ // Allow local emoji
57
+ if (nameToEmoji(name) || helpers.getEmojiTable()[helpers.getEmojiAliases()[name]]) {
58
+ return true;
59
+ }
60
+ // Allow cached custom emoji (shortcode:hostname is the emoji:ap:lookup field key)
61
+ return db.isObjectField('emoji:ap:lookup', name);
62
+ }
63
+
55
64
  const ReactionsPlugin = module.exports;
56
65
 
57
66
  ReactionsPlugin.init = async function (params) {
@@ -703,7 +712,7 @@ SocketPlugins.reactions = {
703
712
  throw new Error('[[error:not-logged-in]]');
704
713
  }
705
714
 
706
- if (!nameToEmoji(data.reaction)) {
715
+ if (!(await isValidReaction(data.reaction))) {
707
716
  throw new Error('[[reactions:error.invalid-reaction]]');
708
717
  }
709
718
 
@@ -715,7 +724,7 @@ SocketPlugins.reactions = {
715
724
  throw new Error('[[error:not-logged-in]]');
716
725
  }
717
726
 
718
- if (!nameToEmoji(data.reaction)) {
727
+ if (!(await isValidReaction(data.reaction))) {
719
728
  throw new Error('[[reactions:error.invalid-reaction]]');
720
729
  }
721
730
 
@@ -727,7 +736,7 @@ SocketPlugins.reactions = {
727
736
  throw new Error('[[error:not-logged-in]]');
728
737
  }
729
738
 
730
- if (!nameToEmoji(data.reaction)) {
739
+ if (!(await isValidReaction(data.reaction))) {
731
740
  throw new Error('[[reactions:error.invalid-reaction]]');
732
741
  }
733
742
 
@@ -807,7 +816,7 @@ SocketPlugins.reactions = {
807
816
  throw new Error('[[error:not-logged-in]]');
808
817
  }
809
818
 
810
- if (!nameToEmoji(data.reaction)) {
819
+ if (!(await isValidReaction(data.reaction))) {
811
820
  throw new Error('[[reactions:error.invalid-reaction]]');
812
821
  }
813
822
 
@@ -839,7 +848,7 @@ SocketPlugins.reactions = {
839
848
  if (!socket.uid) {
840
849
  throw new Error('[[error:not-logged-in]]');
841
850
  }
842
- if (!nameToEmoji(data.reaction)) {
851
+ if (!(await isValidReaction(data.reaction))) {
843
852
  throw new Error('[[reactions:error.invalid-reaction]]');
844
853
  }
845
854
  let set;
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "nodebb-plugin-reactions",
3
- "version": "3.1.6",
3
+ "version": "3.1.7",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "nodebb-plugin-reactions",
9
- "version": "3.1.6",
9
+ "version": "3.1.7",
10
10
  "license": "MIT",
11
11
  "devDependencies": {
12
12
  "eslint": "10.6.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodebb/nodebb-plugin-reactions",
3
- "version": "3.1.6",
3
+ "version": "3.1.7",
4
4
  "nbbpm": {
5
5
  "compatibility": "^4.16.0"
6
6
  },