nodebb-plugin-link-preview 2.1.2 → 2.1.4
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 +13 -5
- package/package.json +1 -1
- package/plugin.json +2 -1
- package/package-lock.json +0 -4889
package/library.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
-
const winston = require.main.require('winston');
|
|
7
6
|
const nconf = require.main.require('nconf');
|
|
8
7
|
const dns = require('dns');
|
|
9
8
|
|
|
@@ -12,7 +11,12 @@ const { load } = require('cheerio');
|
|
|
12
11
|
const { isURL } = require('validator');
|
|
13
12
|
|
|
14
13
|
const meta = require.main.require('./src/meta');
|
|
15
|
-
const
|
|
14
|
+
const cacheCreate = require.main.require('./src/cacheCreate');
|
|
15
|
+
const cache = cacheCreate({
|
|
16
|
+
name: 'link-preview',
|
|
17
|
+
max: 10000,
|
|
18
|
+
ttl: 0,
|
|
19
|
+
});
|
|
16
20
|
const posts = require.main.require('./src/posts');
|
|
17
21
|
const postsCache = require.main.require('./src/posts/cache');
|
|
18
22
|
const websockets = require.main.require('./src/socket.io');
|
|
@@ -21,7 +25,7 @@ const controllers = require('./lib/controllers');
|
|
|
21
25
|
|
|
22
26
|
const routeHelpers = require.main.require('./src/routes/helpers');
|
|
23
27
|
|
|
24
|
-
const plugin =
|
|
28
|
+
const plugin = module.exports;
|
|
25
29
|
|
|
26
30
|
plugin.init = async (params) => {
|
|
27
31
|
const { router /* , middleware , controllers */ } = params;
|
|
@@ -144,7 +148,7 @@ async function process(content, { type, pid, tid, attachments }) {
|
|
|
144
148
|
}
|
|
145
149
|
|
|
146
150
|
// ActivityPub attachments
|
|
147
|
-
if (attachment.hasOwnProperty('mediaType')) {
|
|
151
|
+
if (attachment.hasOwnProperty('mediaType') && attachment.mediaType) {
|
|
148
152
|
switch (true) {
|
|
149
153
|
case attachment.mediaType.startsWith('video/'): {
|
|
150
154
|
cache.set(`link-preview:${url}`, {
|
|
@@ -393,4 +397,8 @@ plugin.addAdminNavigation = (header) => {
|
|
|
393
397
|
return header;
|
|
394
398
|
};
|
|
395
399
|
|
|
396
|
-
|
|
400
|
+
plugin.filterAdminCacheGet = function (caches) {
|
|
401
|
+
caches['link-preview'] = cache;
|
|
402
|
+
return caches;
|
|
403
|
+
};
|
|
404
|
+
|
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
{ "hook": "filter:parse.post", "method": "onParse" },
|
|
10
10
|
{ "hook": "filter:parse.raw", "method": "onParse" },
|
|
11
11
|
{ "hook": "action:post.save", "method": "onPost" },
|
|
12
|
-
{ "hook": "action:post.edit", "method": "onPost" }
|
|
12
|
+
{ "hook": "action:post.edit", "method": "onPost" },
|
|
13
|
+
{ "hook": "filter:admin.cache.get", "method": "filterAdminCacheGet" }
|
|
13
14
|
],
|
|
14
15
|
"scss": [
|
|
15
16
|
"static/scss/link-preview.scss"
|