@nodebb/nodebb-plugin-reactions 3.1.4 → 3.1.5
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 +29 -8
- package/package-lock.json +2 -2
- package/package.json +1 -1
package/library.js
CHANGED
|
@@ -36,19 +36,40 @@ async function parseReaction(name, sourceUrl) {
|
|
|
36
36
|
return emojiParser.buildEmoji(emoji, '');
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
// Try to find the custom emoji: first by source URL hostname, then by scanning emoji:ap:lookup
|
|
40
|
+
let hostname = null;
|
|
39
41
|
if (typeof sourceUrl === 'string') {
|
|
40
42
|
try {
|
|
41
|
-
|
|
42
|
-
const hostname = url.hostname;
|
|
43
|
-
const metadata = await activitypub.emoji.getEmoji(name, hostname);
|
|
44
|
-
if (metadata) {
|
|
45
|
-
const proxyUrl = activitypub.emoji.getProxyUrl(name, hostname);
|
|
46
|
-
return `<img class="not-responsive emoji" src="${proxyUrl}" title=":${name}:" />`;
|
|
47
|
-
}
|
|
43
|
+
hostname = new URL(sourceUrl).hostname;
|
|
48
44
|
} catch (e) {
|
|
49
|
-
// Not a valid URL
|
|
45
|
+
// Not a valid URL (e.g. numeric pid)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let metadata = null;
|
|
50
|
+
if (hostname) {
|
|
51
|
+
metadata = await activitypub.emoji.getEmoji(name, hostname);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Fallback: scan emoji:ap:lookup for any entry matching this shortcode
|
|
55
|
+
if (!metadata) {
|
|
56
|
+
const allKeys = await db.getObjectKeys('emoji:ap:lookup');
|
|
57
|
+
if (allKeys && allKeys.length > 0) {
|
|
58
|
+
const matchKey = allKeys.find(k => k.startsWith(`${name}:`));
|
|
59
|
+
if (matchKey) {
|
|
60
|
+
const idx = matchKey.indexOf(':');
|
|
61
|
+
if (idx !== -1) {
|
|
62
|
+
hostname = matchKey.slice(idx + 1);
|
|
63
|
+
metadata = await activitypub.emoji.getEmoji(name, hostname);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
50
66
|
}
|
|
51
67
|
}
|
|
68
|
+
|
|
69
|
+
if (metadata) {
|
|
70
|
+
const proxyUrl = activitypub.emoji.getProxyUrl(name, hostname);
|
|
71
|
+
return `<img class="not-responsive emoji" src="${proxyUrl}" title=":${name}:" />`;
|
|
72
|
+
}
|
|
52
73
|
return '';
|
|
53
74
|
}
|
|
54
75
|
|
package/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-reactions",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "nodebb-plugin-reactions",
|
|
9
|
-
"version": "3.1.
|
|
9
|
+
"version": "3.1.5",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"eslint": "10.6.0",
|