nodebb-plugin-link-preview 2.1.1 → 2.1.3

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
@@ -143,12 +143,27 @@ async function process(content, { type, pid, tid, attachments }) {
143
143
  return;
144
144
  }
145
145
 
146
- if (attachment.hasOwnProperty('mediaType') && attachment.mediaType.startsWith('video/')) { // ActivityPub
147
- cache.set(`link-preview:${url}`, {
148
- ...attachment,
149
- contentType: attachment.mediaType,
150
- mediaType: 'video',
151
- });
146
+ // ActivityPub attachments
147
+ if (attachment.hasOwnProperty('mediaType') && attachment.mediaType) {
148
+ switch (true) {
149
+ case attachment.mediaType.startsWith('video/'): {
150
+ cache.set(`link-preview:${url}`, {
151
+ ...attachment,
152
+ contentType: attachment.mediaType,
153
+ mediaType: 'video',
154
+ });
155
+ break;
156
+ }
157
+
158
+ case attachment.mediaType.startsWith('image/'): {
159
+ cache.set(`link-preview:${url}`, {
160
+ ...attachment,
161
+ contentType: attachment.mediaType,
162
+ mediaType: 'image',
163
+ });
164
+ break;
165
+ }
166
+ }
152
167
  }
153
168
 
154
169
  const type = _type || 'attachment';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-link-preview",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "A starter kit for quickly creating NodeBB plugins",
5
5
  "main": "library.js",
6
6
  "repository": {