From a68afb1efbfc074c5e914e24edcadb6a6c2f280b Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 9 Mar 2016 15:12:48 +0100 Subject: [PATCH] Patch up Matrix.Event.RoomAvatar * Require an empty state key --- src/matrix-event-room-avatar.vala | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/matrix-event-room-avatar.vala b/src/matrix-event-room-avatar.vala index 49efdbc..322d032 100644 --- a/src/matrix-event-room-avatar.vala +++ b/src/matrix-event-room-avatar.vala @@ -47,10 +47,20 @@ public class Matrix.Event.RoomAvatar : Matrix.Event.State { from_json(Json.Node json_data) throws Matrix.Error { - var content_root = json_data.get_object() - .get_member("content").get_object(); + var root = json_data.get_object(); + var content_root = root.get_member("content").get_object(); Json.Node? node; + if (Config.DEBUG) { + if ((node = root.get_member("state_key")) != null) { + var sk = node.get_string(); + + if (sk != "") { + warning("state_key of a m.room.avatar event is non-empty"); + } + } + } + if ((node = content_root.get_member("url")) != null) { _url = node.get_string(); } else { @@ -131,8 +141,13 @@ public class Matrix.Event.RoomAvatar : Matrix.Event.State { "Won't generate a m.room.avatar event without url"); } - var content_root = json_data.get_object() - .get_member("content").get_object(); + var root = json_data.get_object(); + var content_root = root.get_member("content").get_object(); + + if (_state_key != "") { + throw new Matrix.Error.INCOMPLETE( + "Won't generate a m.room.avatar event with a non-empty state_key"); + } content_root.set_string_member("url", _url);