From 4a5aef0a102d0689e39546134c77bcbf1e287538 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 9 Mar 2016 16:21:32 +0100 Subject: [PATCH] Patch up Matrix.Event.RoomTopic * Require an empty state_key --- src/matrix-event-room-topic.vala | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/matrix-event-room-topic.vala b/src/matrix-event-room-topic.vala index 7e8f76f..bf56409 100644 --- a/src/matrix-event-room-topic.vala +++ b/src/matrix-event-room-topic.vala @@ -36,7 +36,13 @@ public class Matrix.Event.RoomTopic : Matrix.Event.State { { var root = json_data.get_object(); var content_root = root.get_member("content").get_object(); - Json.Node? node; + Json.Node? node = null; + + if (Config.DEBUG && ((node = root.get_member("state_key")) != null)) { + if (node.get_string() != "") { + warning("state_key of a m.room.topic event is non-empty"); + } + } if ((node = content_root.get_member("topic")) != null) { _topic = node.get_string(); @@ -54,6 +60,11 @@ public class Matrix.Event.RoomTopic : Matrix.Event.State { 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.topic event with a non-empty state_key"); + } + if (_topic != null) { content_root.set_string_member("topic", _topic); }