mirror of
https://github.com/matrix-construct/construct
synced 2024-11-02 11:58:53 +01:00
5b088551ae
modules/client/sync: Consolidate header.
93 lines
1.7 KiB
C++
93 lines
1.7 KiB
C++
// 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
|
|
{
|
|
static bool rooms_ephemeral_events_polylog(data &);
|
|
static bool rooms_ephemeral_polylog(data &);
|
|
static bool rooms_ephemeral_linear(data &);
|
|
extern item rooms_ephemeral;
|
|
}
|
|
|
|
ircd::mapi::header
|
|
IRCD_MODULE
|
|
{
|
|
"Client Sync :Rooms Ephemeral"
|
|
};
|
|
|
|
decltype(ircd::m::sync::rooms_ephemeral)
|
|
ircd::m::sync::rooms_ephemeral
|
|
{
|
|
"rooms.ephemeral",
|
|
rooms_ephemeral_polylog,
|
|
rooms_ephemeral_linear,
|
|
{
|
|
{ "phased", true }
|
|
}
|
|
};
|
|
|
|
bool
|
|
ircd::m::sync::rooms_ephemeral_linear(data &data)
|
|
{
|
|
bool ret{false};
|
|
m::sync::for_each("rooms.ephemeral", [&data, &ret]
|
|
(item &item)
|
|
{
|
|
json::stack::checkpoint checkpoint
|
|
{
|
|
*data.out
|
|
};
|
|
|
|
if(item.linear(data))
|
|
ret = true;
|
|
else
|
|
checkpoint.rollback();
|
|
|
|
return true;
|
|
});
|
|
|
|
return ret;
|
|
}
|
|
|
|
bool
|
|
ircd::m::sync::rooms_ephemeral_polylog(data &data)
|
|
{
|
|
return rooms_ephemeral_events_polylog(data);
|
|
}
|
|
|
|
bool
|
|
ircd::m::sync::rooms_ephemeral_events_polylog(data &data)
|
|
{
|
|
json::stack::array array
|
|
{
|
|
*data.out, "events"
|
|
};
|
|
|
|
bool ret{false};
|
|
m::sync::for_each("rooms.ephemeral", [&data, &ret]
|
|
(item &item)
|
|
{
|
|
json::stack::checkpoint checkpoint
|
|
{
|
|
*data.out
|
|
};
|
|
|
|
if(item.polylog(data))
|
|
{
|
|
ret = true;
|
|
data.out->invalidate_checkpoints();
|
|
}
|
|
else checkpoint.rollback();
|
|
|
|
return true;
|
|
});
|
|
|
|
return ret;
|
|
}
|