Skip to content

Commit 103bdb8

Browse files
authored
Merge pull request #145 from dozro/fix/headpat-message-event-type-fix
change msgtype to m.emote to be more standard compliant
2 parents 57cf8a2 + 399915d commit 103bdb8

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
sable: patch
3+
---
4+
5+
chang to more standard compliant msgtype `m.emote` for `/headpat` event

src/app/components/RenderMessageContent.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,15 @@ function RenderMessageContentInternal({
218218
}
219219

220220
if (msgType === MsgType.Emote) {
221+
if (content['fyi.cisnt.headpat']) {
222+
return (
223+
<MCuteEvent
224+
content={content}
225+
type={CuteEventType.Headpat}
226+
mentionedUserIds={content?.['m.mentions']?.user_ids}
227+
/>
228+
);
229+
}
221230
return (
222231
<MEmote
223232
displayName={displayName}
@@ -359,6 +368,7 @@ function RenderMessageContentInternal({
359368
mentionedUserIds={content?.['m.mentions']?.user_ids}
360369
/>
361370
);
371+
// as fallback to render older events where msgtype was set instead of m.emote with a custom property
362372
if (msgType === 'fyi.cisnt.headpat')
363373
return (
364374
<MCuteEvent

src/app/hooks/useCommands.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,11 +1375,12 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
13751375
exe: async (payload) => {
13761376
const target = payload.trim();
13771377
await mx.sendMessage(room.roomId, {
1378-
msgtype: 'fyi.cisnt.headpat',
1378+
msgtype: 'm.emote',
13791379
'm.mentions': {
13801380
user_ids: target ? [target] : [],
13811381
},
1382-
body: `*pat pat*`,
1382+
body: `pats ${target || 'you'}`,
1383+
'fyi.cisnt.headpat': true,
13831384
} as any);
13841385
},
13851386
},

0 commit comments

Comments
 (0)