Add event handler for m.room.aliases events
This commit is contained in:
parent
f48eaf4c88
commit
0aaab4af7e
1
.gitignore
vendored
1
.gitignore
vendored
@ -61,3 +61,4 @@ Makefile.in
|
||||
/src/namespace-info.c
|
||||
/src/matrix-event-room-topic.c
|
||||
/src/matrix-event-typing.c
|
||||
/src/matrix-event-room-aliases.c
|
||||
|
@ -31,6 +31,7 @@ libmatrix_glib_0_0_la_VALA_SOURCES = \
|
||||
matrix-event-room-message.vala \
|
||||
matrix-event-room-topic.vala \
|
||||
matrix-event-typing.vala \
|
||||
matrix-event-room-aliases.vala \
|
||||
$(NULL)
|
||||
|
||||
AM_CPPFLAGS += \
|
||||
|
70
src/matrix-event-room-aliases.vala
Normal file
70
src/matrix-event-room-aliases.vala
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.aliases event.
|
||||
*
|
||||
* This event is sent by a homeserver directly to inform of changes to
|
||||
* the list of aliases it knows about for that room.
|
||||
*
|
||||
* The state_key for this event is set to the homeserver which owns
|
||||
* the room alias.
|
||||
*
|
||||
* The entire set of known aliases for the room is the union of all
|
||||
* the m.room.aliases events, one for each homeserver. Clients should
|
||||
* check the validity of any room alias given in this list before
|
||||
* presenting it to the user as trusted fact. The lists given by this
|
||||
* event should be considered simply as advice on which aliases might
|
||||
* exist, for which the client can perform the lookup to confirm
|
||||
* whether it receives the correct room ID.
|
||||
*/
|
||||
public class Matrix.Event.RoomAliases : Matrix.Event.State {
|
||||
private List<string>? _aliases = null;
|
||||
|
||||
/**
|
||||
* A list of room aliases.
|
||||
*/
|
||||
public List<string>? aliases {
|
||||
get {
|
||||
return _aliases;
|
||||
}
|
||||
|
||||
set {
|
||||
_aliases = value.copy();
|
||||
}
|
||||
|
||||
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("aliases")) != null) {
|
||||
_aliases = null;
|
||||
|
||||
node.get_array().foreach_element((ary, idx, member_node) => {
|
||||
_aliases.prepend(member_node.get_string());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -167,6 +167,9 @@ matrix_event_types_ctor(void)
|
||||
matrix_event_register_type("m.typing",
|
||||
MATRIX_EVENT_TYPE_TYPING,
|
||||
NULL);
|
||||
matrix_event_register_type("m.room.aliases",
|
||||
MATRIX_EVENT_TYPE_ROOM_ALIASES,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user