` +
+ `
${sanitizeCustomHtml(bodyModifText)}
` +
+ `
${safeHtml}
` +
+ `
`;
+ }
+ let content;
+ // handle privacy stuff
+ if (isPrivate) {
+ // if the message is from a private room, we should strip any media or mentions to avoid leaking information to the target room
+ // we can still include the original message content in the body of the message, so we'll just use a fallback text/plain content with the original message body
+ content = {
+ ...mEvent.getContent(),
+ body: newBodyPlain,
+ format: 'org.matrix.custom.html',
+ formatted_body: newBodyHtml,
+ 'moe.sable.message.forward': {
+ v: 1,
+ is_forwarded: true,
+ original_timestamp: mEvent.getTs(),
+ original_event_private: true,
+ } satisfies ForwardMeta,
+ };
+ } else {
+ content = {
+ ...mEvent.getContent(),
+ body: newBodyPlain,
+ format: 'org.matrix.custom.html',
+ formatted_body: newBodyHtml,
+ 'm.relates_to': {
+ rel_type: 'm.reference',
+ event_id: eventId,
+ },
+ 'moe.sable.message.forward': {
+ v: 1,
+ is_forwarded: true,
+ original_timestamp: mEvent.getTs(),
+ original_room_id: room.roomId,
+ original_event_id: eventId,
+ original_event_private: false,
+ } satisfies ForwardMeta,
+ };
+ }
+
+ try {
+ mx.sendEvent(targetRoom.roomId, null, eventType, content as unknown as SendEventContent).then(
+ () => setIsForwardSuccess(true)
+ );
+ } catch {
+ setIsForwardSuccess(false);
+ setIsForwardError(true);
+ }
+ };
+
+ return (
+