mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 16:33:53 +01:00
modules/client/rooms/leave: Add missing m::leave definition.
This commit is contained in:
parent
fd9097cfd4
commit
4d491340b6
2 changed files with 59 additions and 1 deletions
|
@ -4545,7 +4545,7 @@ ircd::m::leave(const room &room,
|
|||
|
||||
static mods::import<prototype> function
|
||||
{
|
||||
"client_rooms", "leave__room_user"
|
||||
"client_rooms", "ircd::m::leave"
|
||||
};
|
||||
|
||||
return function(room, user_id);
|
||||
|
|
|
@ -39,3 +39,61 @@ post__leave(client &client,
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
event::id::buf
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::leave(const room &room,
|
||||
const id::user &user_id)
|
||||
{
|
||||
if(!exists(room))
|
||||
return {};
|
||||
|
||||
json::iov event;
|
||||
json::iov content;
|
||||
const json::iov::push push[]
|
||||
{
|
||||
{ event, { "type", "m.room.member" }},
|
||||
{ event, { "sender", user_id }},
|
||||
{ event, { "state_key", user_id }},
|
||||
{ content, { "membership", "leave" }},
|
||||
};
|
||||
|
||||
const m::user user{user_id};
|
||||
const m::user::profile profile{user};
|
||||
|
||||
char displayname_buf[256];
|
||||
const string_view displayname
|
||||
{
|
||||
profile.get(displayname_buf, "displayname")
|
||||
};
|
||||
|
||||
char avatar_url_buf[256];
|
||||
const string_view avatar_url
|
||||
{
|
||||
profile.get(avatar_url_buf, "avatar_url")
|
||||
};
|
||||
|
||||
const json::iov::add _displayname
|
||||
{
|
||||
content, !empty(displayname),
|
||||
{
|
||||
"displayname", [&displayname]() -> json::value
|
||||
{
|
||||
return displayname;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const json::iov::add _avatar_url
|
||||
{
|
||||
content, !empty(avatar_url),
|
||||
{
|
||||
"avatar_url", [&avatar_url]() -> json::value
|
||||
{
|
||||
return avatar_url;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return commit(room, event, content);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue