diff --git a/matrix/matrix.cc b/matrix/matrix.cc index 8b72c75bd..28a706016 100644 --- a/matrix/matrix.cc +++ b/matrix/matrix.cc @@ -157,6 +157,7 @@ ircd::m::module_names "client_sync_account_data", "client_sync_device_lists", "client_sync_device_one_time_keys_count", + "client_sync_device_unused_fallback_key_types", "client_sync_groups", "client_sync_presence", "client_sync_to_device", diff --git a/modules/Makefile.am b/modules/Makefile.am index 00d80857b..6bf8d3226 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -443,6 +443,7 @@ 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 +client_client_sync_device_unused_fallback_key_types_la_SOURCES = client/sync/device_unused_fallback_key_types.cc client_module_LTLIBRARIES += \ client/client_sync_account_data.la \ @@ -452,6 +453,7 @@ client_module_LTLIBRARIES += \ client/client_sync_to_device.la \ client/client_sync_device_lists.la \ client/client_sync_device_one_time_keys_count.la \ + client/client_sync_device_unused_fallback_key_types.la \ ### # client/sync/rooms/ diff --git a/modules/client/sync/device_unused_fallback_key_types.cc b/modules/client/sync/device_unused_fallback_key_types.cc new file mode 100644 index 000000000..1795cb1e5 --- /dev/null +++ b/modules/client/sync/device_unused_fallback_key_types.cc @@ -0,0 +1,64 @@ +// Matrix Construct +// +// Copyright (C) Matrix Construct Developers, Authors & Contributors +// Copyright (C) 2016-2023 Jason Volk +// +// 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 device_unused_fallback_key_types_polylog(data &); + static bool device_unused_fallback_key_types_linear(data &); + + extern item device_unused_fallback_key_types; +} + +ircd::mapi::header +IRCD_MODULE +{ + "Client Sync :Device Unused Fallback Key Types" +}; + +decltype(ircd::m::sync::device_unused_fallback_key_types) +ircd::m::sync::device_unused_fallback_key_types +{ + "device_unused_fallback_key_types", + device_unused_fallback_key_types_polylog, + device_unused_fallback_key_types_linear +}; + +bool +ircd::m::sync::device_unused_fallback_key_types_linear(data &data) +{ + if(!data.device_id) + return false; + + if(!data.event || !data.event->event_id) + return false; + + if(!startswith(json::get<"type"_>(*data.event), "ircd.device")) + return false; + + if(json::get<"room_id"_>(*data.event) != data.user_room) + return false; + + json::stack::array array + { + *data.out, "device_unused_fallback_key_types" + }; + + array.append("signed_curve25519"); + return true; +} + +bool +ircd::m::sync::device_unused_fallback_key_types_polylog(data &data) +{ + if(!data.device_id) + return false; + + return false; +}