0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-29 08:13:46 +02:00

modules/client/sync: Preliminary groups sync module stub.

This commit is contained in:
Jason Volk 2020-07-30 13:22:36 -07:00
parent f12d197a32
commit 748c7730b1
3 changed files with 110 additions and 0 deletions

View file

@ -155,6 +155,7 @@ ircd::m::matrix::module_names
"client_sync_account_data",
"client_sync_device_lists",
"client_sync_device_one_time_keys_count",
"client_sync_groups",
"client_sync_presence",
"client_sync_to_device",
"client_sync_rooms_account_data",

View file

@ -438,6 +438,7 @@ client_module_LTLIBRARIES += \
client_client_sync_account_data_la_SOURCES = client/sync/account_data.cc
client_client_sync_presence_la_SOURCES = client/sync/presence.cc
client_client_sync_rooms_la_SOURCES = client/sync/rooms.cc
client_client_sync_groups_la_SOURCES = client/sync/groups.cc
client_client_sync_to_device_la_SOURCES = client/sync/to_device.cc
client_client_sync_device_lists_la_SOURCES = client/sync/device_lists.cc
client_client_sync_device_one_time_keys_count_la_SOURCES = client/sync/device_one_time_keys_count.cc
@ -446,6 +447,7 @@ client_module_LTLIBRARIES += \
client/client_sync_account_data.la \
client/client_sync_presence.la \
client/client_sync_rooms.la \
client/client_sync_groups.la \
client/client_sync_to_device.la \
client/client_sync_device_lists.la \
client/client_sync_device_one_time_keys_count.la \

View file

@ -0,0 +1,107 @@
// The Construct
//
// Copyright (C) The Construct Developers, Authors & Contributors
// Copyright (C) 2016-2020 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 _groups_polylog(data &, const string_view &membership);
static bool groups_polylog(data &);
static bool _groups_linear(data &, const string_view &membership);
static bool groups_linear(data &);
extern item groups;
}
ircd::mapi::header
IRCD_MODULE
{
"Client Sync :Groups"
};
decltype(ircd::m::sync::groups)
ircd::m::sync::groups
{
"groups",
groups_polylog,
groups_linear,
};
bool
ircd::m::sync::groups_linear(data &data)
{
assert(data.event);
const m::room room
{
json::get<"room_id"_>(*data.event)?
m::room::id{json::get<"room_id"_>(*data.event)}:
m::room::id{}
};
const scope_restore their_room
{
data.room, &room
};
char membuf[room::MEMBERSHIP_MAX_SIZE];
const string_view &membership
{
data.room?
m::membership(membuf, room, data.user):
string_view{}
};
const scope_restore their_membership
{
data.membership, membership
};
bool ret{false};
return ret;
}
bool
ircd::m::sync::groups_polylog(data &data)
{
bool ret{false};
ret |= _groups_polylog(data, "join");
if(ret)
return ret;
ret |= _groups_polylog(data, "invite");
if(ret)
return ret;
ret |= _groups_polylog(data, "leave");
if(ret)
return ret;
return ret;
}
bool
ircd::m::sync::_groups_polylog(data &data,
const string_view &membership)
{
const scope_restore theirs
{
data.membership, membership
};
json::stack::object object
{
*data.out, membership
};
bool ret{false};
return ret;
}