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

ircd:Ⓜ️ Move join() definition to modules/client/rooms/join.

This commit is contained in:
Jason Volk 2018-02-22 15:52:43 -08:00
parent 09519174e2
commit 116b6e12a6
3 changed files with 47 additions and 9 deletions

View file

@ -316,3 +316,25 @@ ircd::m::create(const id::room &room_id,
return function(room_id, creator, parent, type);
}
ircd::m::event::id::buf
ircd::m::join(const room &room,
const id::user &user_id)
{
static const auto modname
{
"client_rooms_join.so"
};
static const auto symname
{
"join__room_user"
};
using prototype = event::id::buf (const m::room &, const id::user &);
static mods::import<prototype> function;
if(unlikely(!function))
function = { modules.at(modname), symname };
return function(room, user_id);
}

View file

@ -10,13 +10,6 @@
#include <ircd/m/m.h>
ircd::m::event::id::buf
ircd::m::join(const room &room,
const m::id::user &user_id)
{
return membership(room, user_id, "join");
}
ircd::m::event::id::buf
ircd::m::leave(const room &room,
const m::id::user &user_id)

View file

@ -10,19 +10,24 @@
#include "rooms.h"
using namespace ircd::m;
using namespace ircd;
extern "C" event::id::buf
join__room_user(const room &room,
const id::user &user_id);
resource::response
post__join(client &client,
const resource::request &request,
const m::room::id &room_id)
const room::id &room_id)
{
const string_view &third_party_signed
{
unquote(request["third_party_signed"])
};
m::join(room_id, request.user_id);
join__room_user(room_id, request.user_id);
return resource::response
{
@ -32,3 +37,21 @@ post__join(client &client,
}
};
}
event::id::buf
join__room_user(const room &room,
const id::user &user_id)
{
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 }},
{ event, { "membership", "join" }},
{ content, { "membership", "join" }},
};
return commit(room, event, content);
}