nodebb-plugin-link-preview 2.1.5 → 2.1.6

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
@@ -209,6 +209,7 @@ async function process(content, { type, pid, tid, attachments }) {
209
209
  // Start preview for cache misses, but continue for now so as to not block response
210
210
  if (cold.size) {
211
211
  const coldArr = Array.from(cold);
212
+ const failures = new Set();
212
213
  Promise.all(coldArr.map(preview)).then(async (previews) => {
213
214
  await Promise.all(previews.map(async (preview, idx) => {
214
215
  if (!preview) {
@@ -236,11 +237,19 @@ async function process(content, { type, pid, tid, attachments }) {
236
237
  break;
237
238
  }
238
239
  }
240
+ } else if (options.type === 'attachment') {
241
+ // Preview failed, put back in placeholders
242
+ failures.add(url);
239
243
  }
240
244
  }));
241
245
 
246
+ const placeholderHtml = Array.from(failures).reduce((html, cur) => {
247
+ html += `<p><a href="${cur}" rel="nofollow ugc">${cur}</a></p>`;
248
+ return html;
249
+ }, '');
242
250
  let content = $.html();
243
251
  content += attachmentHtml ? `\n\n<div class="row mt-3">${attachmentHtml}</div>` : '';
252
+ content += placeholderHtml ? `\n\n<div class="row mt-3"><div class="col-12 mt-3">${placeholderHtml}</div></div>` : '';
244
253
 
245
254
  // bust posts cache item
246
255
  if (pid) {
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "nodebb-plugin-link-preview",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "nodebb-plugin-link-preview",
9
- "version": "2.1.5",
9
+ "version": "2.1.6",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "cheerio": "^1.0.0-rc.12",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-link-preview",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "description": "A starter kit for quickly creating NodeBB plugins",
5
5
  "main": "library.js",
6
6
  "repository": {