0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 18:22:50 +01:00

modules/client/join: Add relevant user profile values to join event iov.

This commit is contained in:
Jason Volk 2018-03-22 16:28:43 -07:00
parent 7bfd050131
commit faefd5dd64
2 changed files with 46 additions and 0 deletions

View file

@ -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);

View file

@ -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);
}