Patch up Matrix.Event.RoomCreate

* Require an empty state key
This commit is contained in:
Gergely Polonkai 2016-03-09 15:24:24 +01:00 committed by Gergely Polonkai
parent be2220b079
commit 3fe5b57d1c

View File

@ -38,9 +38,15 @@ public class Matrix.Event.RoomCreate : Matrix.Event.State {
from_json(Json.Node json_data)
throws Matrix.Error
{
var content_root = json_data.get_object()
.get_member("content").get_object();
Json.Node? node;
var root = json_data.get_object();
var content_root = root.get_member("content").get_object();
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.create event is non-empty");
}
}
if ((node = content_root.get_member("creator")) != null) {
_creator = node.get_string();
@ -61,7 +67,12 @@ public class Matrix.Event.RoomCreate : Matrix.Event.State {
{
if (_creator == null) {
throw new Matrix.Error.INCOMPLETE(
"Won't send a m.room.create event without a creator key");
"Won't generate a m.room.create event without a creator key");
}
if (state_key != "") {
throw new Matrix.Error.INCOMPLETE(
"Won't generater a m.root.create event with a non-empty state_key");
}
var content_root = json_data.get_object()