58 lines
1.8 KiB
Vala
58 lines
1.8 KiB
Vala
/*
|
|
* This file is part of matrix-glib-sdk
|
|
*
|
|
* matrix-glib-sdk is free software: you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation, either
|
|
* version 3 of the License, or (at your option) any later version.
|
|
*
|
|
* matrix-glib-sdk is distributed in the hope that it will be
|
|
* useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with matrix-glib-sdk. If not, see
|
|
* <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/**
|
|
* Class to hold a m.room.canonical_alias event
|
|
*
|
|
* This event is used to inform the room about which alias should be
|
|
* considered the canonical one. This could be for display purposes or
|
|
* as suggestion to users which alias to use to advertise the room.
|
|
*/
|
|
public class Matrix.Event.RoomCanonicalAlias : Matrix.Event.State {
|
|
public string? canonical_alias { get; set; default = null; }
|
|
|
|
protected override void
|
|
from_json(Json.Node json_data)
|
|
throws Matrix.Error
|
|
{
|
|
var content_root = json_data.get_object()
|
|
.get_member("content").get_object();
|
|
Json.Node? node;
|
|
|
|
if ((node = content_root.get_member("alias")) != null) {
|
|
_canonical_alias = node.get_string();
|
|
}
|
|
|
|
base.from_json(json_data);
|
|
}
|
|
|
|
protected override void
|
|
to_json(Json.Node json_data)
|
|
throws Matrix.Error
|
|
{
|
|
var content_root = json_data.get_object()
|
|
.get_member("content").get_object();
|
|
|
|
if (_canonical_alias != null) {
|
|
content_root.set_string_member("alias", _canonical_alias);
|
|
}
|
|
|
|
base.to_json(json_data);
|
|
}
|
|
}
|