0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 00:32:35 +01:00

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

modules/client/rooms/redact: renamespacing.
This commit is contained in:
Jason Volk 2018-02-22 19:50:48 -08:00
parent 99239c8b95
commit 44ff77a03f
3 changed files with 59 additions and 36 deletions

View file

@ -328,3 +328,19 @@ ircd::m::leave(const room &room,
return function(room, user_id);
}
ircd::m::event::id::buf
ircd::m::redact(const room &room,
const id::user &sender,
const id::event &event_id,
const string_view &reason)
{
using prototype = event::id::buf (const m::room &, const id::user &, const id::event &, const string_view &);
static import<prototype> function
{
"client_rooms", "redact__"
};
return function(room, sender, event_id, reason);
}

View file

@ -50,32 +50,6 @@ ircd::m::message(const room &room,
return send(room, sender, "m.room.message", contents);
}
ircd::m::event::id::buf
ircd::m::redact(const room &room,
const m::id::user &sender,
const m::id::event &event_id,
const string_view &reason)
{
json::iov event;
json::iov::push push[]
{
{ event, { "type", "m.room.redaction" }},
{ event, { "sender", sender }},
{ event, { "redacts", event_id }},
};
json::iov content;
json::iov::set_if _reason
{
content, !empty(reason),
{
"reason", reason
}
};
return commit(room, event, content);
}
ircd::m::event::id::buf
ircd::m::send(const room &room,
const m::id::user &sender,

View file

@ -10,26 +10,33 @@
#include "rooms.h"
using namespace ircd::m;
using namespace ircd;
extern "C" event::id::buf
redact__(const room &room,
const id::user &sender,
const id::event &event_id,
const string_view &reason);
resource::response
put__redact(client &client,
const resource::request &request,
const m::room::id &room_id)
const room::id &room_id)
{
if(request.parv.size() < 3)
throw m::NEED_MORE_PARAMS
throw NEED_MORE_PARAMS
{
"event_id parameter missing"
};
m::event::id::buf redacts
event::id::buf redacts
{
url::decode(request.parv[2], redacts)
};
if(request.parv.size() < 4)
throw m::NEED_MORE_PARAMS
throw NEED_MORE_PARAMS
{
"txnid parameter missing"
};
@ -39,7 +46,7 @@ put__redact(client &client,
request.parv[3]
};
const m::room room
const room room
{
room_id
};
@ -51,7 +58,7 @@ put__redact(client &client,
const auto event_id
{
redact(room, request.user_id, redacts, reason)
redact__(room, request.user_id, redacts, reason)
};
return resource::response
@ -66,20 +73,20 @@ put__redact(client &client,
resource::response
post__redact(client &client,
const resource::request &request,
const m::room::id &room_id)
const room::id &room_id)
{
if(request.parv.size() < 3)
throw m::NEED_MORE_PARAMS
throw NEED_MORE_PARAMS
{
"event_id parameter missing"
};
m::event::id::buf redacts
event::id::buf redacts
{
url::decode(request.parv[2], redacts)
};
const m::room room
const room room
{
room_id
};
@ -102,3 +109,29 @@ post__redact(client &client,
}
};
}
event::id::buf
redact__(const room &room,
const id::user &sender,
const id::event &event_id,
const string_view &reason)
{
json::iov event;
const json::iov::push push[]
{
{ event, { "type", "m.room.redaction" }},
{ event, { "sender", sender }},
{ event, { "redacts", event_id }},
};
json::iov content;
const json::iov::set_if _reason
{
content, !empty(reason),
{
"reason", reason
}
};
return commit(room, event, content);
}