mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-13 10:40:28 +03:00
added support for sending reaction
This commit is contained in:
parent
ebac0db0df
commit
fa85e61d6f
6 changed files with 376 additions and 294 deletions
|
|
@ -189,19 +189,7 @@ async function invite(roomId, userId) {
|
|||
}
|
||||
}
|
||||
|
||||
async function redact(roomId, eventId, reason) {
|
||||
const mx = initMatrix.matrixClient;
|
||||
|
||||
try {
|
||||
await mx.redactEvent(roomId, eventId, undefined, typeof reason === 'undefined' ? undefined : { reason });
|
||||
return true;
|
||||
} catch (e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
join, leave,
|
||||
create, invite,
|
||||
redact,
|
||||
};
|
||||
|
|
|
|||
33
src/client/action/roomTimeline.js
Normal file
33
src/client/action/roomTimeline.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import initMatrix from '../initMatrix';
|
||||
|
||||
async function redactEvent(roomId, eventId, reason) {
|
||||
const mx = initMatrix.matrixClient;
|
||||
|
||||
try {
|
||||
await mx.redactEvent(roomId, eventId, undefined, typeof reason === 'undefined' ? undefined : { reason });
|
||||
return true;
|
||||
} catch (e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function sendReaction(roomId, toEventId, reaction) {
|
||||
const mx = initMatrix.matrixClient;
|
||||
|
||||
try {
|
||||
await mx.sendEvent(roomId, 'm.reaction', {
|
||||
'm.relates_to': {
|
||||
event_id: toEventId,
|
||||
key: reaction,
|
||||
rel_type: 'm.annotation',
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
redactEvent,
|
||||
sendReaction,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue