mirror of
https://github.com/matrix-construct/construct
synced 2025-01-03 19:34:29 +01:00
ircd:Ⓜ️ Generate user_room ID's for all users local and remote.
This commit is contained in:
parent
5a1d0a9f45
commit
d3d58d8ee9
1 changed files with 21 additions and 8 deletions
|
@ -158,27 +158,40 @@ ircd::m::id::room::buf
|
||||||
ircd::m::user::room_id()
|
ircd::m::user::room_id()
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
assert(!empty(user_id));
|
char buf[256];
|
||||||
return
|
return room_id(buf);
|
||||||
{
|
|
||||||
user_id.local(), my_host()
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates a room MXID of the following form: `!@user:host`
|
/// Generates a room MXID of the following form: `!@user:host` If the user
|
||||||
|
/// is on my_host(), then the room localpart is literally "!@user" but if
|
||||||
|
/// the user is not on my_host, the full user_id is hashed and the room_id
|
||||||
|
/// is the b58 hash on my_host.
|
||||||
///
|
///
|
||||||
/// This is the "user's room" essentially serving as a database mechanism for
|
/// This is the "user's room" essentially serving as a database mechanism for
|
||||||
/// this specific user. This is for users on this server's host only.
|
/// this specific user.
|
||||||
///
|
///
|
||||||
ircd::m::id::room
|
ircd::m::id::room
|
||||||
ircd::m::user::room_id(const mutable_buffer &buf)
|
ircd::m::user::room_id(const mutable_buffer &buf)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
assert(!empty(user_id));
|
assert(!empty(user_id));
|
||||||
|
|
||||||
|
if(my(user_id))
|
||||||
return
|
return
|
||||||
{
|
{
|
||||||
buf, user_id.local(), my_host()
|
buf, user_id.local(), my_host()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const sha256::buf hash
|
||||||
|
{
|
||||||
|
sha256{user_id}
|
||||||
|
};
|
||||||
|
|
||||||
|
char b58[size(hash) * 2];
|
||||||
|
return
|
||||||
|
{
|
||||||
|
buf, b58encode(b58, hash), my_host()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::string_view
|
ircd::string_view
|
||||||
|
|
Loading…
Reference in a new issue