Node.js based forum software built for the modern web
fix: adjust Peertube-specific handling to shove mp4 into post attachments, #13324
Julian Lam799b08db3a6f
diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.jsindex b569768f98..f2a8446d4a 100644--- a/src/activitypub/mocks.js+++ b/src/activitypub/mocks.js@@ -42,7 +42,7 @@ const sanitizeConfig = {Mocks._normalize = async (object) => {// Normalized incoming AP objects into expected types for easier mocking- let { attributedTo, url, image, content, source } = object;+ let { type, attributedTo, url, image, content, source, attachment } = object;switch (true) { // non-string attributedTo handlingcase Array.isArray(attributedTo): {@@ -102,6 +102,30 @@ 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 }) => {+ if (!memo && (type === 'Link' && mediaType === 'video/mp4')) {+ memo = { type, mediaType, href };+ }++ return memo;+ }, null);+ }+ }++ return memo;+ }, null);++ if (stream) {+ attachment = attachment || [];+ attachment.push(stream);+ }+ }+url = url.reduce((valid, cur) => {if (typeof cur === 'string') {valid.push(cur);@@ -126,6 +150,7 @@ Mocks._normalize = async (object) => {sourceContent,image,url,+ attachment,};};@@ -332,7 +357,7 @@ Mocks.post = async (objects) => {attributedTo: uid,inReplyTo: toPid,published, updated, name, content, sourceContent,- type, to, cc, audience, attachment, tag, image,+ to, cc, audience, attachment, tag, image,} = object;await activitypub.actors.assert(uid);@@ -346,11 +371,6 @@ Mocks.post = async (objects) => {let edited = new Date(updated);edited = Number.isNaN(edited.valueOf()) ? undefined : edited;- if (type === 'Video') {- attachment = attachment || [];- attachment.push({ url });- }-const payload = {uid,pid,