Skip to content

Commit 4d104fc

Browse files
committed
Support rendering image reactions for mxc keys
Beeper clients only use an mxc url as reaction key when sending image reactions, instead of properly setting the url field.
1 parent f064216 commit 4d104fc

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/customisations/models/IMediaEventContent.ts

+7
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ export function prepEventContentAsMedia(content: Partial<IMediaEventContent>): I
100100
mxc: content.file.url,
101101
file: content.file,
102102
};
103+
} else if (content["m.relates_to"]?.key?.startsWith("mxc://")) {
104+
// Fallback to key, since some clients only set the key to the mxc:// url while omitting the actual url field for reactions
105+
return {
106+
thumbnail,
107+
mxc: content["m.relates_to"]?.key,
108+
file: content.file,
109+
};
103110
}
104111

105112
throw new Error("Invalid file provided: cannot determine MXC URI. Has it been redacted?");

src/utils/MediaEventHelper.ts

+4
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ export class MediaEventHelper implements IDestroyable {
118118
const mediaMsgTypes: string[] = [MsgType.Video, MsgType.Audio, MsgType.Image, MsgType.File];
119119
if (mediaMsgTypes.includes(content.msgtype!)) return true;
120120
if (typeof content.url === "string") return true;
121+
if (event.getType() === EventType.Reaction && content["m.relates_to"]?.key?.startsWith("mxc://")) {
122+
// Some clients only send mxc url as key, without setting the url field
123+
return true;
124+
}
121125

122126
// Finally, it's probably not media
123127
return false;

0 commit comments

Comments
 (0)