mirror of
https://github.com/matrix-construct/construct
synced 2024-11-13 21:41:06 +01:00
56 lines
1.1 KiB
C++
56 lines
1.1 KiB
C++
// Matrix Construct
|
|
//
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
// Copyright (C) 2016-2019 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
|
|
get__event(client &client,
|
|
const resource::request &request,
|
|
const m::room::id &room_id)
|
|
{
|
|
if(request.parv.size() < 3)
|
|
throw m::NEED_MORE_PARAMS
|
|
{
|
|
"event_id path parameter required"
|
|
};
|
|
|
|
m::event::id::buf event_id
|
|
{
|
|
url::decode(event_id, request.parv[2])
|
|
};
|
|
|
|
const m::room room
|
|
{
|
|
room_id, event_id
|
|
};
|
|
|
|
if(!room.visible(request.user_id))
|
|
throw m::ACCESS_DENIED
|
|
{
|
|
"You are not permitted to view the room at this event"
|
|
};
|
|
|
|
const m::event::fetch event
|
|
{
|
|
event_id
|
|
};
|
|
|
|
const json::strung buffer
|
|
{
|
|
event
|
|
};
|
|
|
|
return resource::response
|
|
{
|
|
client, json::object{buffer}
|
|
};
|
|
}
|