mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 08:12:37 +01:00
modules/client/rooms/invite: Add invite commit / handler w/ central linkage.
This commit is contained in:
parent
59531912e4
commit
b90d4230ca
3 changed files with 58 additions and 1 deletions
|
@ -60,6 +60,7 @@ namespace ircd::m
|
|||
event::id::buf msghtml(const room &, const m::id::user &sender, const string_view &html, const string_view &alt = {}, const string_view &msgtype = "m.notice");
|
||||
event::id::buf notice(const room &, const m::id::user &sender, const string_view &body);
|
||||
event::id::buf notice(const room &, const string_view &body); // sender is @ircd
|
||||
event::id::buf invite(const room &, const m::id::user &target, const m::id::user &sender);
|
||||
event::id::buf leave(const room &, const m::id::user &);
|
||||
event::id::buf join(const room &, const m::id::user &);
|
||||
event::id::buf join(const id::room_alias &, const m::id::user &);
|
||||
|
|
15
ircd/m/m.cc
15
ircd/m/m.cc
|
@ -1248,6 +1248,21 @@ ircd::m::leave(const room &room,
|
|||
return function(room, user_id);
|
||||
}
|
||||
|
||||
ircd::m::event::id::buf
|
||||
ircd::m::invite(const room &room,
|
||||
const id::user &target,
|
||||
const id::user &sender)
|
||||
{
|
||||
using prototype = event::id::buf (const m::room &, const id::user &, const id::user &);
|
||||
|
||||
static import<prototype> function
|
||||
{
|
||||
"client_rooms", "invite__room_user"
|
||||
};
|
||||
|
||||
return function(room, target, sender);
|
||||
}
|
||||
|
||||
ircd::m::event::id::buf
|
||||
ircd::m::redact(const room &room,
|
||||
const id::user &sender,
|
||||
|
|
|
@ -12,18 +12,59 @@
|
|||
|
||||
using namespace ircd;
|
||||
|
||||
extern "C" m::event::id::buf
|
||||
invite__room_user(const m::room &,
|
||||
const m::user::id &target,
|
||||
const m::user::id &sender);
|
||||
|
||||
resource::response
|
||||
post__invite(client &client,
|
||||
const resource::request &request,
|
||||
const m::room::id &room_id)
|
||||
{
|
||||
const m::user::id &user_id
|
||||
const m::user::id &target
|
||||
{
|
||||
unquote(request.at("user_id"))
|
||||
};
|
||||
|
||||
const m::user::id &sender
|
||||
{
|
||||
request.user_id
|
||||
};
|
||||
|
||||
const auto event_id
|
||||
{
|
||||
invite__room_user(room_id, target, sender)
|
||||
};
|
||||
|
||||
return resource::response
|
||||
{
|
||||
client, http::OK
|
||||
};
|
||||
}
|
||||
|
||||
m::event::id::buf
|
||||
invite__room_user(const m::room &room,
|
||||
const m::user::id &target,
|
||||
const m::user::id &sender)
|
||||
{
|
||||
if(!exists(room))
|
||||
throw m::NOT_FOUND
|
||||
{
|
||||
"Not aware of room %s",
|
||||
string_view{room.room_id}
|
||||
};
|
||||
|
||||
json::iov event;
|
||||
json::iov content;
|
||||
const json::iov::push push[]
|
||||
{
|
||||
{ event, { "type", "m.room.member" }},
|
||||
{ event, { "sender", sender }},
|
||||
{ event, { "state_key", target }},
|
||||
{ event, { "membership", "invite" }},
|
||||
{ content, { "membership", "invite" }},
|
||||
};
|
||||
|
||||
return commit(room, event, content);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue