Node.js based forum software built for the modern web
fix: simpler logic for parsing peertube objects, #14220
Julian Lam2523d95b4f61
diff --git a/install/package.json b/install/package.jsonindex 2b3fb43297..dfe7ea2001 100644--- a/install/package.json+++ b/install/package.json@@ -103,7 +103,7 @@"nodebb-plugin-dbsearch": "6.5.0","nodebb-plugin-emoji": "6.0.6","nodebb-plugin-emoji-android": "4.1.1",- "nodebb-plugin-link-preview": "2.2.4",+ "nodebb-plugin-link-preview": "2.2.5","nodebb-plugin-markdown": "13.2.4","nodebb-plugin-mentions": "4.8.18","nodebb-plugin-spam-be-gone": "2.3.2",@@ -205,4 +205,4 @@"url": "https://github.com/barisusakli"}]-}\ No newline at end of file+}diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.jsindex 7510771695..1245eb4e50 100644--- a/src/activitypub/mocks.js+++ b/src/activitypub/mocks.js@@ -44,7 +44,7 @@ const sanitizeConfig = {Mocks._normalize = async (object) => {// Normalized incoming AP objects into expected types for easier mocking- let { type, attributedTo, url, image, mediaType, content, source, attachment, cc } = object;+ let { id, type, uuid, attributedTo, url, image, mediaType, content, source, attachment, cc } = object;switch (true) { // non-string attributedTo handlingcase Array.isArray(attributedTo): {@@ -113,26 +113,16 @@ Mocks._normalize = async (object) => {if (url) { // Handle url arrayif (Array.isArray(url)) {// Special handling for Video type (from PeerTube specifically)- if (type === 'Video') {- const stream = url.reduce((memo, { type, mediaType, tag }) => {- if (!memo) {- if (type === 'Link' && mediaType === 'application/x-mpegURL') {- memo = tag.reduce((memo, { type, mediaType, href, width, height }) => {- if (!memo && (type === 'Link' && mediaType === 'video/mp4')) {- memo = { mediaType, href, width, height };- }-- return memo;- }, null);- }- }-- return memo;- }, null);-- if (stream) {+ if (type === 'Video' && !!uuid) {+ try {+ const { protocol, hostname } = new URL(id);attachment = attachment || [];- attachment.push(stream);+ attachment.push({+ mediaType: 'text/plain',+ href: `${protocol}//${hostname}/videos/embed/${uuid}`,+ });+ } catch (e) {+ // noop}}