Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Federation attachment URL for audio and video files #16430

Merged
merged 10 commits into from
May 4, 2020
10 changes: 8 additions & 2 deletions app/federation/server/endpoints/dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,16 @@ const eventHandlers = {
// Update the message's file
denormalizedMessage.file._id = upload._id;

// Update the message's attachments
// Update the message's attachments dependent on type
for (const attachment of denormalizedMessage.attachments) {
attachment.title_link = attachment.title_link.replace(oldUploadId, upload._id);
attachment.image_url = attachment.image_url.replace(oldUploadId, upload._id);
if (/^image\/.+/.test(denormalizedMessage.file.type)) {
attachment.image_url = attachment.image_url.replace(oldUploadId, upload._id);
} else if (/^audio\/.+/.test(denormalizedMessage.file.type)) {
attachment.audio_url = attachment.audio_url.replace(oldUploadId, upload._id);
} else if (/^video\/.+/.test(denormalizedMessage.file.type)) {
attachment.video_url = attachment.video_url.replace(oldUploadId, upload._id);
}
}
}

Expand Down