2018-02-22 00:22:04 +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"
|
|
|
|
|
|
|
|
using namespace ircd;
|
|
|
|
|
|
|
|
resource::response
|
|
|
|
post__forget(client &client,
|
|
|
|
const resource::request &request,
|
|
|
|
const m::room::id &room_id)
|
|
|
|
{
|
2019-03-08 01:05:38 +01:00
|
|
|
const m::room room
|
|
|
|
{
|
|
|
|
room_id
|
|
|
|
};
|
|
|
|
|
|
|
|
const m::user::room user_room
|
|
|
|
{
|
|
|
|
request.user_id
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto event_idx
|
|
|
|
{
|
|
|
|
user_room.get(std::nothrow, "ircd.member", room_id)
|
|
|
|
};
|
|
|
|
|
|
|
|
if(!event_idx)
|
|
|
|
throw m::NOT_FOUND
|
|
|
|
{
|
|
|
|
"No user membership found for room %s.",
|
|
|
|
string_view{room_id}
|
|
|
|
};
|
|
|
|
|
2019-09-18 20:37:34 +02:00
|
|
|
if(m::membership(event_idx, m::membership_positive))
|
2019-03-08 01:05:38 +01:00
|
|
|
throw m::error
|
|
|
|
{
|
2019-09-18 20:37:34 +02:00
|
|
|
http::UNPROCESSABLE_ENTITY, "M_MEMBERSHIP_POSITIVE",
|
|
|
|
"You must leave or be banned from the room to forget it."
|
2019-03-08 01:05:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const auto event_id
|
|
|
|
{
|
|
|
|
m::event_id(event_idx)
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto redact_id
|
|
|
|
{
|
|
|
|
redact(user_room, request.user_id, event_id, "forget")
|
|
|
|
};
|
|
|
|
|
2018-02-22 00:22:04 +01:00
|
|
|
return resource::response
|
|
|
|
{
|
|
|
|
client, http::OK
|
|
|
|
};
|
|
|
|
}
|