2019-01-04 02:21: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.
|
|
|
|
|
|
|
|
ircd::mapi::header
|
|
|
|
IRCD_MODULE
|
|
|
|
{
|
|
|
|
"Client Sync :Room Account Data"
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace ircd::m::sync
|
|
|
|
{
|
2019-01-10 05:39:12 +01:00
|
|
|
static void room_account_data_polylog_events_event(data &, const m::event &);
|
|
|
|
static void room_account_data_polylog_events(data &);
|
2019-01-10 22:19:07 +01:00
|
|
|
static void room_account_data_polylog(data &);
|
2019-01-10 05:39:12 +01:00
|
|
|
|
2019-01-04 02:21:02 +01:00
|
|
|
extern item room_account_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
decltype(ircd::m::sync::room_account_data)
|
|
|
|
ircd::m::sync::room_account_data
|
|
|
|
{
|
2019-01-09 00:10:06 +01:00
|
|
|
"rooms.account_data",
|
2019-01-04 02:21:02 +01:00
|
|
|
room_account_data_polylog
|
|
|
|
};
|
|
|
|
|
2019-01-10 22:19:07 +01:00
|
|
|
void
|
2019-01-04 02:21:02 +01:00
|
|
|
ircd::m::sync::room_account_data_polylog(data &data)
|
|
|
|
{
|
2019-01-09 00:10:06 +01:00
|
|
|
json::stack::object object
|
|
|
|
{
|
|
|
|
data.out
|
|
|
|
};
|
|
|
|
|
2019-01-10 05:39:12 +01:00
|
|
|
room_account_data_polylog_events(data);
|
2019-01-09 00:10:06 +01:00
|
|
|
}
|
|
|
|
|
2019-01-10 05:39:12 +01:00
|
|
|
void
|
|
|
|
ircd::m::sync::room_account_data_polylog_events(data &data)
|
2019-01-09 00:10:06 +01:00
|
|
|
{
|
|
|
|
json::stack::array array
|
|
|
|
{
|
|
|
|
data.out, "events"
|
|
|
|
};
|
|
|
|
|
2019-01-04 02:21:02 +01:00
|
|
|
const m::room::state state
|
|
|
|
{
|
|
|
|
data.user_room
|
|
|
|
};
|
|
|
|
|
2019-01-10 05:39:12 +01:00
|
|
|
assert(data.room);
|
2019-01-04 02:21:02 +01:00
|
|
|
char typebuf[288]; //TODO: room_account_data_typebuf_size
|
|
|
|
const auto type
|
|
|
|
{
|
|
|
|
m::user::_account_data_type(typebuf, data.room->room_id)
|
|
|
|
};
|
|
|
|
|
2019-01-10 05:39:12 +01:00
|
|
|
state.for_each(type, [&data]
|
2019-01-04 02:21:02 +01:00
|
|
|
(const m::event &event)
|
|
|
|
{
|
2019-01-10 05:39:12 +01:00
|
|
|
if(apropos(data, event))
|
|
|
|
room_account_data_polylog_events_event(data, event);
|
|
|
|
});
|
|
|
|
}
|
2019-01-04 02:21:02 +01:00
|
|
|
|
2019-01-10 05:39:12 +01:00
|
|
|
void
|
|
|
|
ircd::m::sync::room_account_data_polylog_events_event(data &data,
|
|
|
|
const m::event &event)
|
|
|
|
{
|
|
|
|
data.commit();
|
|
|
|
json::stack::object object
|
|
|
|
{
|
|
|
|
data.out
|
|
|
|
};
|
2019-01-04 02:21:02 +01:00
|
|
|
|
2019-01-10 05:39:12 +01:00
|
|
|
json::stack::member
|
|
|
|
{
|
|
|
|
object, "type", at<"state_key"_>(event)
|
|
|
|
};
|
2019-01-04 02:21:02 +01:00
|
|
|
|
2019-01-10 05:39:12 +01:00
|
|
|
json::stack::member
|
|
|
|
{
|
|
|
|
object, "content", at<"content"_>(event)
|
|
|
|
};
|
2019-01-04 02:21:02 +01:00
|
|
|
}
|