From 602e91da40cf64b851c44da4806e2bc9dcc72d86 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 16 Mar 2017 16:29:55 +0000 Subject: [PATCH] Update event redaction to keep sender and origin_server_ts Required for fixing https://github.com/matrix-org/matrix-js-sdk/issues/387 --- src/models/event.js | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/models/event.js b/src/models/event.js index 93729a31fa6..10d8a4345f6 100644 --- a/src/models/event.js +++ b/src/models/event.js @@ -406,31 +406,18 @@ utils.extend(module.exports.MatrixEvent.prototype, { }); -/* http://matrix.org/docs/spec/r0.0.1/client_server.html#redactions says: +/* _REDACT_KEEP_KEY_MAP gives the keys we keep when an event is redacted * - * the server should strip off any keys not in the following list: - * event_id - * type - * room_id - * user_id - * state_key - * prev_state - * content - * [we keep 'unsigned' as well, since that is created by the local server] + * This is specified here: + * http://matrix.org/speculator/spec/HEAD/client_server/unstable.html#redactions * - * The content object should also be stripped of all keys, unless it is one of - * one of the following event types: - * m.room.member allows key membership - * m.room.create allows key creator - * m.room.join_rules allows key join_rule - * m.room.power_levels allows keys ban, events, events_default, kick, - * redact, state_default, users, users_default. - * m.room.aliases allows key aliases + * Also: + * - We keep 'unsigned' since that is created by the local server + * - We keep user_id for backwards-compat with v1 */ -// a map giving the keys we keep when an event is redacted const _REDACT_KEEP_KEY_MAP = [ - 'event_id', 'type', 'room_id', 'user_id', 'state_key', 'prev_state', - 'content', 'unsigned', + 'event_id', 'type', 'room_id', 'user_id', 'sender', 'state_key', 'prev_state', + 'content', 'unsigned', 'origin_server_ts', ].reduce(function(ret, val) { ret[val] = 1; return ret; }, {});