0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd:Ⓜ️ Add experimental sigiled and qualified device MXID.

This commit is contained in:
Jason Volk 2018-02-15 13:01:07 -08:00
parent 08335c3883
commit 51b2cafc74
2 changed files with 20 additions and 1 deletions

View file

@ -44,6 +44,7 @@ struct ircd::m::id
struct room_alias;
struct group;
struct origin;
struct device;
enum sigil :char;
template<class T, size_t SIZE = 256> struct buf;
@ -85,6 +86,7 @@ enum ircd::m::id::sigil
ROOM_ALIAS = '#', ///< Room alias (4.2.3)
GROUP = '+', ///< Group ID (experimental)
ORIGIN = ':', ///< Origin ID (experimental)
DEVICE = '%', ///< Device ID (experimental)
};
/// (Appendix 4.2.1) User Identifiers
@ -183,6 +185,16 @@ struct ircd::m::id::origin
origin() = default;
};
/// Device ID (EXPERIMENTAL)
///
struct ircd::m::id::device
:ircd::m::id
{
using buf = m::id::buf<device>;
template<class... args> device(args&&... a) :m::id{DEVICE, std::forward<args>(a)...} {}
device() = default;
};
// Utilities
namespace ircd::m
{

View file

@ -57,6 +57,7 @@ struct ircd::m::id::input
const rule<> room_alias_sigil { lit(char(ircd::m::id::ROOM_ALIAS)) ,"room_alias sigil" };
const rule<> group_id_sigil { lit(char(ircd::m::id::GROUP)) ,"group_id sigil" };
const rule<> origin_sigil { lit(char(ircd::m::id::ORIGIN)) ,"origin sigil" };
const rule<> device_sigil { lit(char(ircd::m::id::DEVICE)) ,"device sigil" };
const rule<enum sigil> sigil
{
event_id_sigil |
@ -64,7 +65,8 @@ struct ircd::m::id::input
room_id_sigil |
room_alias_sigil |
group_id_sigil |
origin_sigil
origin_sigil |
device_sigil
,"sigil"
};
@ -468,6 +470,10 @@ ircd::m::id::id(const enum sigil &sigil,
printer::random_prefixed(sigil::ROOM_ALIAS, "", name);
break;
case sigil::DEVICE:
printer::random_alpha(sigil::DEVICE, name, 16);
break;
default:
printer::random_timebased(sigil, name);
break;
@ -635,6 +641,7 @@ ircd::m::reflect(const enum id::sigil &c)
case id::ROOM_ALIAS: return "ROOM_ALIAS";
case id::GROUP: return "GROUP";
case id::ORIGIN: return "ORIGIN";
case id::DEVICE: return "DEVICE";
}
return "?????";