Patch up Matrix.Event.RoomCanonicalAlias
* Require an empty state key
This commit is contained in:
parent
a68afb1efb
commit
be2220b079
@ -24,15 +24,24 @@
|
|||||||
* as suggestion to users which alias to use to advertise the room.
|
* as suggestion to users which alias to use to advertise the room.
|
||||||
*/
|
*/
|
||||||
public class Matrix.Event.RoomCanonicalAlias : Matrix.Event.State {
|
public class Matrix.Event.RoomCanonicalAlias : Matrix.Event.State {
|
||||||
|
/**
|
||||||
|
* The canonical alias.
|
||||||
|
*/
|
||||||
public string? canonical_alias { get; set; default = null; }
|
public string? canonical_alias { get; set; default = null; }
|
||||||
|
|
||||||
protected override void
|
protected override void
|
||||||
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.canonical_alias event is non-empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((node = content_root.get_member("alias")) != null) {
|
if ((node = content_root.get_member("alias")) != null) {
|
||||||
_canonical_alias = node.get_string();
|
_canonical_alias = node.get_string();
|
||||||
@ -48,6 +57,11 @@ public class Matrix.Event.RoomCanonicalAlias : 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 generate a m.room.canonical_alias event with a non-empty state_key");
|
||||||
|
}
|
||||||
|
|
||||||
if (_canonical_alias != null) {
|
if (_canonical_alias != null) {
|
||||||
content_root.set_string_member("alias", _canonical_alias);
|
content_root.set_string_member("alias", _canonical_alias);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user