2018-02-16 01:07:02 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
#include "rooms.h"
|
|
|
|
|
2018-02-23 04:50:48 +01:00
|
|
|
using namespace ircd::m;
|
2018-02-16 01:07:02 +01:00
|
|
|
using namespace ircd;
|
|
|
|
|
|
|
|
resource::response
|
|
|
|
put__redact(client &client,
|
|
|
|
const resource::request &request,
|
2018-02-23 04:50:48 +01:00
|
|
|
const room::id &room_id)
|
2018-02-16 01:07:02 +01:00
|
|
|
{
|
|
|
|
if(request.parv.size() < 3)
|
2018-02-23 04:50:48 +01:00
|
|
|
throw NEED_MORE_PARAMS
|
2018-02-16 01:07:02 +01:00
|
|
|
{
|
|
|
|
"event_id parameter missing"
|
|
|
|
};
|
|
|
|
|
2018-02-23 04:50:48 +01:00
|
|
|
event::id::buf redacts
|
2018-02-16 01:07:02 +01:00
|
|
|
{
|
2018-12-07 01:41:47 +01:00
|
|
|
url::decode(redacts, request.parv[2])
|
2018-02-16 01:07:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
if(request.parv.size() < 4)
|
2018-02-23 04:50:48 +01:00
|
|
|
throw NEED_MORE_PARAMS
|
2018-02-16 01:07:02 +01:00
|
|
|
{
|
|
|
|
"txnid parameter missing"
|
|
|
|
};
|
|
|
|
|
|
|
|
const string_view &txnid
|
|
|
|
{
|
|
|
|
request.parv[3]
|
|
|
|
};
|
|
|
|
|
2018-02-23 04:50:48 +01:00
|
|
|
const room room
|
2018-02-16 01:07:02 +01:00
|
|
|
{
|
|
|
|
room_id
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto &reason
|
|
|
|
{
|
|
|
|
unquote(request["reason"])
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto event_id
|
|
|
|
{
|
2019-09-16 19:55:23 +02:00
|
|
|
m::redact(room, request.user_id, redacts, reason)
|
2018-02-16 01:07:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
return resource::response
|
|
|
|
{
|
|
|
|
client, json::members
|
|
|
|
{
|
|
|
|
{ "event_id", event_id }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2018-02-16 01:26:17 +01:00
|
|
|
|
|
|
|
resource::response
|
|
|
|
post__redact(client &client,
|
|
|
|
const resource::request &request,
|
2018-02-23 04:50:48 +01:00
|
|
|
const room::id &room_id)
|
2018-02-16 01:26:17 +01:00
|
|
|
{
|
|
|
|
if(request.parv.size() < 3)
|
2018-02-23 04:50:48 +01:00
|
|
|
throw NEED_MORE_PARAMS
|
2018-02-16 01:26:17 +01:00
|
|
|
{
|
|
|
|
"event_id parameter missing"
|
|
|
|
};
|
|
|
|
|
2018-02-23 04:50:48 +01:00
|
|
|
event::id::buf redacts
|
2018-02-16 01:26:17 +01:00
|
|
|
{
|
2018-12-07 01:41:47 +01:00
|
|
|
url::decode(redacts, request.parv[2])
|
2018-02-16 01:26:17 +01:00
|
|
|
};
|
|
|
|
|
2018-02-23 04:50:48 +01:00
|
|
|
const room room
|
2018-02-16 01:26:17 +01:00
|
|
|
{
|
|
|
|
room_id
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto &reason
|
|
|
|
{
|
|
|
|
unquote(request["reason"])
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto event_id
|
|
|
|
{
|
2019-09-16 19:55:23 +02:00
|
|
|
m::redact(room, request.user_id, redacts, reason)
|
2018-02-16 01:26:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
return resource::response
|
|
|
|
{
|
|
|
|
client, json::members
|
|
|
|
{
|
|
|
|
{ "event_id", event_id }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|