From faefd5dd6475b4b93cb06ffea5d18ab644662ab4 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 22 Mar 2018 16:28:43 -0700 Subject: [PATCH] modules/client/join: Add relevant user profile values to join event iov. --- modules/client/join.cc | 23 +++++++++++++++++++++++ modules/client/rooms/join.cc | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/modules/client/join.cc b/modules/client/join.cc index 9ec88cfa0..8aec28c7c 100644 --- a/modules/client/join.cc +++ b/modules/client/join.cc @@ -173,6 +173,29 @@ bootstrap(const m::room::alias &room_alias, { event, { "room_id", room_id }}, }; + const m::user user + { + user_id + }; + + char displayname_buf[256]; + const string_view displayname + { + user.profile(displayname_buf, "displayname") + }; + + char avatar_url_buf[256]; + const string_view avatar_url + { + user.profile(avatar_url_buf, "avatar_url") + }; + + const json::iov::add_if add_if[] + { + { content, !empty(displayname), { "displayname", displayname }}, + { content, !empty(avatar_url), { "avatar_url", avatar_url }}, + }; + m::vm::opts opts; opts.non_conform.set(m::event::conforms::MISSING_MEMBERSHIP); opts.non_conform.set(m::event::conforms::MISSING_PREV_STATE); diff --git a/modules/client/rooms/join.cc b/modules/client/rooms/join.cc index 858169ab8..ae5b1ebb5 100644 --- a/modules/client/rooms/join.cc +++ b/modules/client/rooms/join.cc @@ -60,5 +60,28 @@ join__room_user(const room &room, { content, { "membership", "join" }}, }; + const m::user user + { + user_id + }; + + char displayname_buf[256]; + const string_view displayname + { + user.profile(displayname_buf, "displayname") + }; + + char avatar_url_buf[256]; + const string_view avatar_url + { + user.profile(avatar_url_buf, "avatar_url") + }; + + const json::iov::add_if add_if[] + { + { content, !empty(displayname), { "displayname", displayname }}, + { content, !empty(avatar_url), { "avatar_url", avatar_url }}, + }; + return commit(room, event, content); }