2019-01-09 00:10:06 +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.
|
|
|
|
|
|
|
|
namespace ircd::m::sync
|
|
|
|
{
|
2019-02-24 20:59:53 +01:00
|
|
|
static bool rooms_ephemeral_events_polylog(data &);
|
|
|
|
static bool rooms_ephemeral_polylog(data &);
|
|
|
|
static bool rooms_ephemeral_linear(data &);
|
2019-01-09 00:10:06 +01:00
|
|
|
extern item rooms_ephemeral;
|
|
|
|
}
|
|
|
|
|
2019-09-09 21:05:53 +02:00
|
|
|
ircd::mapi::header
|
|
|
|
IRCD_MODULE
|
|
|
|
{
|
|
|
|
"Client Sync :Rooms Ephemeral"
|
|
|
|
};
|
|
|
|
|
2019-01-09 00:10:06 +01:00
|
|
|
decltype(ircd::m::sync::rooms_ephemeral)
|
|
|
|
ircd::m::sync::rooms_ephemeral
|
|
|
|
{
|
|
|
|
"rooms.ephemeral",
|
|
|
|
rooms_ephemeral_polylog,
|
2019-08-17 13:02:00 +02:00
|
|
|
rooms_ephemeral_linear,
|
|
|
|
{
|
2020-05-29 06:31:28 +02:00
|
|
|
{ "phased", true },
|
|
|
|
{ "prefetch", true },
|
2019-08-17 13:02:00 +02:00
|
|
|
}
|
2019-01-09 00:10:06 +01:00
|
|
|
};
|
|
|
|
|
2019-02-24 20:59:53 +01:00
|
|
|
bool
|
2019-01-09 00:10:06 +01:00
|
|
|
ircd::m::sync::rooms_ephemeral_linear(data &data)
|
|
|
|
{
|
2019-03-28 03:32:54 +01:00
|
|
|
bool ret{false};
|
|
|
|
m::sync::for_each("rooms.ephemeral", [&data, &ret]
|
2019-02-27 02:34:07 +01:00
|
|
|
(item &item)
|
|
|
|
{
|
|
|
|
json::stack::checkpoint checkpoint
|
|
|
|
{
|
|
|
|
*data.out
|
|
|
|
};
|
|
|
|
|
|
|
|
if(item.linear(data))
|
2019-03-28 03:32:54 +01:00
|
|
|
ret = true;
|
|
|
|
else
|
|
|
|
checkpoint.rollback();
|
2019-02-27 02:34:07 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
});
|
2019-03-28 03:32:54 +01:00
|
|
|
|
|
|
|
return ret;
|
2019-01-09 00:10:06 +01:00
|
|
|
}
|
|
|
|
|
2019-02-24 20:59:53 +01:00
|
|
|
bool
|
2019-01-09 00:10:06 +01:00
|
|
|
ircd::m::sync::rooms_ephemeral_polylog(data &data)
|
|
|
|
{
|
2019-02-24 20:59:53 +01:00
|
|
|
return rooms_ephemeral_events_polylog(data);
|
2019-01-09 00:10:06 +01:00
|
|
|
}
|
|
|
|
|
2019-02-24 20:59:53 +01:00
|
|
|
bool
|
2019-01-09 00:10:06 +01:00
|
|
|
ircd::m::sync::rooms_ephemeral_events_polylog(data &data)
|
|
|
|
{
|
|
|
|
json::stack::array array
|
|
|
|
{
|
2019-02-27 00:50:58 +01:00
|
|
|
*data.out, "events"
|
2019-01-09 00:10:06 +01:00
|
|
|
};
|
|
|
|
|
2019-02-24 20:59:53 +01:00
|
|
|
bool ret{false};
|
|
|
|
m::sync::for_each("rooms.ephemeral", [&data, &ret]
|
2019-01-09 00:10:06 +01:00
|
|
|
(item &item)
|
|
|
|
{
|
2019-02-24 20:59:53 +01:00
|
|
|
json::stack::checkpoint checkpoint
|
|
|
|
{
|
2019-02-27 00:50:58 +01:00
|
|
|
*data.out
|
2019-02-24 20:59:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
if(item.polylog(data))
|
2019-03-30 23:02:18 +01:00
|
|
|
{
|
2019-02-24 20:59:53 +01:00
|
|
|
ret = true;
|
2019-03-30 23:02:18 +01:00
|
|
|
data.out->invalidate_checkpoints();
|
|
|
|
}
|
|
|
|
else checkpoint.rollback();
|
2019-02-24 20:59:53 +01:00
|
|
|
|
2019-01-09 00:10:06 +01:00
|
|
|
return true;
|
|
|
|
});
|
2019-02-24 20:59:53 +01:00
|
|
|
|
|
|
|
return ret;
|
2019-01-09 00:10:06 +01:00
|
|
|
}
|