mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
SYWEB-98: Handle incoming m.room.redaction events.
UI for redactions is now complete.
This commit is contained in:
parent
6d4617960d
commit
c2f2e26ec5
@ -172,6 +172,17 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
|
||||
};
|
||||
|
||||
var handleMessage = function(event, isLiveEvent) {
|
||||
// Check for empty event content
|
||||
var hasContent = false;
|
||||
for (var prop in event.content) {
|
||||
hasContent = true;
|
||||
break;
|
||||
}
|
||||
if (!hasContent) {
|
||||
// empty json object is a redacted event, so ignore.
|
||||
return;
|
||||
}
|
||||
|
||||
if (isLiveEvent) {
|
||||
if (event.user_id === matrixService.config().user_id &&
|
||||
(event.content.msgtype === "m.text" || event.content.msgtype === "m.emote") ) {
|
||||
@ -336,6 +347,31 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
|
||||
}
|
||||
};
|
||||
|
||||
var handleRedaction = function(event, isLiveEvent) {
|
||||
if (!isLiveEvent) {
|
||||
// we have nothing to remove, so just ignore it.
|
||||
console.log("Received redacted event: "+JSON.stringify(event));
|
||||
return;
|
||||
}
|
||||
|
||||
// we need to remove something possibly: do we know the redacted
|
||||
// event ID?
|
||||
if (eventMap[event.redacts]) {
|
||||
// remove event from list of messages in this room.
|
||||
var eventList = $rootScope.events.rooms[event.room_id].messages;
|
||||
for (var i=0; i<eventList.length; i++) {
|
||||
if (eventList[i].event_id === event.redacts) {
|
||||
console.log("Removing event " + event.redacts);
|
||||
eventList.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// broadcast the redaction so controllers can nuke this
|
||||
console.log("Redacted an event.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index of the event in $rootScope.events.rooms[room_id].messages
|
||||
* @param {type} room_id the room id
|
||||
@ -497,6 +533,9 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
|
||||
case 'm.room.topic':
|
||||
handleRoomTopic(event, isLiveEvent, isStateEvent);
|
||||
break;
|
||||
case 'm.room.redaction':
|
||||
handleRedaction(event, isLiveEvent);
|
||||
break;
|
||||
default:
|
||||
console.log("Unable to handle event type " + event.type);
|
||||
console.log(JSON.stringify(event, undefined, 4));
|
||||
|
Loading…
Reference in New Issue
Block a user