From 45409428e6b4105d23fa8aae1f0db9739f3e27f6 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 6 Dec 2020 14:42:34 -0800 Subject: [PATCH] modules/client/sync/rooms: Assertions for membership query on membership event. --- modules/client/sync/rooms.cc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/client/sync/rooms.cc b/modules/client/sync/rooms.cc index 562edef81..5e5d39700 100644 --- a/modules/client/sync/rooms.cc +++ b/modules/client/sync/rooms.cc @@ -59,7 +59,8 @@ ircd::m::sync::rooms_linear(data &data) { json::get<"room_id"_>(*data.event)? m::membership(membuf, room, data.user): - string_view{} + + string_view{} }; const scope_restore their_membership @@ -67,6 +68,23 @@ ircd::m::sync::rooms_linear(data &data) data.membership, membership }; + const bool is_own_membership + { + json::get<"room_id"_>(*data.event) + && json::get<"type"_>(*data.event) == "m.room.member" + && json::get<"state_key"_>(*data.event) == data.user.user_id + }; + + const bool is_own_join + { + is_own_membership + && membership == "join" + }; + + //assert(!is_own_join || m::membership(*data.event) == "join"); + assert(!is_own_join || !!m::membership(membuf, room, data.user)); + assert(is_own_join || !json::get<"room_id"_>(*data.event) || m::exists(room)); + if(should_ignore(data)) return false;