mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 10:19:21 -05:00
dedup all events
This commit is contained in:
parent
a1bf28b7f0
commit
6e341aebab
@ -42,6 +42,11 @@ angular.module('eventHandlerService', [])
|
|||||||
rooms: {} // will contain roomId: { messages:[], members:{userid1: event} }
|
rooms: {} // will contain roomId: { messages:[], members:{userid1: event} }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// used for dedupping events - could be expanded in future...
|
||||||
|
// FIXME: means that we leak memory over time (along with lots of the rest
|
||||||
|
// of the app, given we never try to reap memory yet)
|
||||||
|
var eventMap = {};
|
||||||
|
|
||||||
$rootScope.presence = {};
|
$rootScope.presence = {};
|
||||||
|
|
||||||
var initRoom = function(room_id) {
|
var initRoom = function(room_id) {
|
||||||
@ -156,42 +161,48 @@ angular.module('eventHandlerService', [])
|
|||||||
CALL_EVENT: CALL_EVENT,
|
CALL_EVENT: CALL_EVENT,
|
||||||
NAME_EVENT: NAME_EVENT,
|
NAME_EVENT: NAME_EVENT,
|
||||||
|
|
||||||
|
|
||||||
handleEvent: function(event, isLiveEvent) {
|
handleEvent: function(event, isLiveEvent) {
|
||||||
switch(event.type) {
|
if (eventMap[event.event_id]) {
|
||||||
case "m.room.create":
|
console.log("discarding duplicate event: " + JSON.stringify(event));
|
||||||
handleRoomCreate(event, isLiveEvent);
|
return;
|
||||||
break;
|
|
||||||
case "m.room.aliases":
|
|
||||||
handleRoomAliases(event, isLiveEvent);
|
|
||||||
break;
|
|
||||||
case "m.room.message":
|
|
||||||
handleMessage(event, isLiveEvent);
|
|
||||||
break;
|
|
||||||
case "m.room.member":
|
|
||||||
handleRoomMember(event, isLiveEvent);
|
|
||||||
break;
|
|
||||||
case "m.presence":
|
|
||||||
handlePresence(event, isLiveEvent);
|
|
||||||
break;
|
|
||||||
case 'm.room.ops_levels':
|
|
||||||
case 'm.room.send_event_level':
|
|
||||||
case 'm.room.add_state_level':
|
|
||||||
case 'm.room.join_rules':
|
|
||||||
case 'm.room.power_levels':
|
|
||||||
handlePowerLevels(event, isLiveEvent);
|
|
||||||
break;
|
|
||||||
case 'm.room.name':
|
|
||||||
handleRoomName(event, isLiveEvent);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.log("Unable to handle event type " + event.type);
|
|
||||||
console.log(JSON.stringify(event, undefined, 4));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type.indexOf('m.call.') === 0) {
|
if (event.type.indexOf('m.call.') === 0) {
|
||||||
handleCallEvent(event, isLiveEvent);
|
handleCallEvent(event, isLiveEvent);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
switch(event.type) {
|
||||||
|
case "m.room.create":
|
||||||
|
handleRoomCreate(event, isLiveEvent);
|
||||||
|
break;
|
||||||
|
case "m.room.aliases":
|
||||||
|
handleRoomAliases(event, isLiveEvent);
|
||||||
|
break;
|
||||||
|
case "m.room.message":
|
||||||
|
handleMessage(event, isLiveEvent);
|
||||||
|
break;
|
||||||
|
case "m.room.member":
|
||||||
|
handleRoomMember(event, isLiveEvent);
|
||||||
|
break;
|
||||||
|
case "m.presence":
|
||||||
|
handlePresence(event, isLiveEvent);
|
||||||
|
break;
|
||||||
|
case 'm.room.ops_levels':
|
||||||
|
case 'm.room.send_event_level':
|
||||||
|
case 'm.room.add_state_level':
|
||||||
|
case 'm.room.join_rules':
|
||||||
|
case 'm.room.power_levels':
|
||||||
|
handlePowerLevels(event, isLiveEvent);
|
||||||
|
break;
|
||||||
|
case 'm.room.name':
|
||||||
|
handleRoomName(event, isLiveEvent);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log("Unable to handle event type " + event.type);
|
||||||
|
console.log(JSON.stringify(event, undefined, 4));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// isLiveEvents determines whether notifications should be shown, whether
|
// isLiveEvents determines whether notifications should be shown, whether
|
||||||
|
Loading…
Reference in New Issue
Block a user