Patch up Matrix.Event.RoomName

* Require an empty state_key
This commit is contained in:
Gergely Polonkai 2016-03-09 15:59:35 +01:00 committed by Gergely Polonkai
parent 9be25a5d61
commit 75ab5512f1

View File

@ -33,9 +33,15 @@ public class Matrix.Event.RoomName : Matrix.Event.State {
from_json(Json.Node json_data) from_json(Json.Node json_data)
throws Matrix.Error throws Matrix.Error
{ {
var content_root = json_data.get_object() var root = json_data.get_object();
.get_member("content").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.name event is non-empty");
}
}
if ((node = content_root.get_member("name")) != null) { if ((node = content_root.get_member("name")) != null) {
_name = node.get_string(); _name = node.get_string();
@ -53,6 +59,11 @@ public class Matrix.Event.RoomName : Matrix.Event.State {
var content_root = json_data.get_object() var content_root = json_data.get_object()
.get_member("content").get_object(); .get_member("content").get_object();
if (_state_key != "") {
throw new Matrix.Error.INCOMPLETE(
"Won't send a m.room.name with a non-empty state key");
}
if (_name == null) { if (_name == null) {
throw new Matrix.Error.INCOMPLETE( throw new Matrix.Error.INCOMPLETE(
"Won't send a m.room.name event without a name"); "Won't send a m.room.name event without a name");