mirror of
https://github.com/matrix-construct/construct
synced 2024-11-16 15:00:51 +01:00
modules/client/initialsync: Sync global account_data from user's room; minor cleanup.
This commit is contained in:
parent
b305e72cef
commit
777525f85a
1 changed files with 37 additions and 9 deletions
|
@ -139,7 +139,8 @@ initialsync(client &client,
|
||||||
static void
|
static void
|
||||||
initialsync_rooms(client &client,
|
initialsync_rooms(client &client,
|
||||||
const resource::request &request,
|
const resource::request &request,
|
||||||
json::stack::object &out);
|
json::stack::object &out,
|
||||||
|
const m::user::room &);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
initialsync_presence(client &client,
|
initialsync_presence(client &client,
|
||||||
|
@ -149,18 +150,22 @@ initialsync_presence(client &client,
|
||||||
static void
|
static void
|
||||||
initialsync_account_data(client &client,
|
initialsync_account_data(client &client,
|
||||||
const resource::request &request,
|
const resource::request &request,
|
||||||
json::stack::object &out);
|
json::stack::object &out,
|
||||||
|
const m::user::room &);
|
||||||
|
|
||||||
void
|
void
|
||||||
_initialsync(client &client,
|
_initialsync(client &client,
|
||||||
const resource::request &request,
|
const resource::request &request,
|
||||||
json::stack::object &out)
|
json::stack::object &out)
|
||||||
{
|
{
|
||||||
|
const m::user user{request.user_id};
|
||||||
|
const m::user::room user_room{user};
|
||||||
|
|
||||||
// rooms
|
// rooms
|
||||||
{
|
{
|
||||||
json::stack::member member{out, "rooms"};
|
json::stack::member member{out, "rooms"};
|
||||||
json::stack::object object{member};
|
json::stack::object object{member};
|
||||||
initialsync_rooms(client, request, object);
|
initialsync_rooms(client, request, object, user_room);
|
||||||
}
|
}
|
||||||
|
|
||||||
// presence
|
// presence
|
||||||
|
@ -174,7 +179,7 @@ _initialsync(client &client,
|
||||||
{
|
{
|
||||||
json::stack::member member{out, "account_data"};
|
json::stack::member member{out, "account_data"};
|
||||||
json::stack::object object{member};
|
json::stack::object object{member};
|
||||||
initialsync_account_data(client, request, object);
|
initialsync_account_data(client, request, object, user_room);
|
||||||
}
|
}
|
||||||
|
|
||||||
// next_batch
|
// next_batch
|
||||||
|
@ -213,9 +218,34 @@ initialsync_presence(client &client,
|
||||||
void
|
void
|
||||||
initialsync_account_data(client &client,
|
initialsync_account_data(client &client,
|
||||||
const resource::request &request,
|
const resource::request &request,
|
||||||
json::stack::object &out)
|
json::stack::object &out,
|
||||||
|
const m::user::room &user_room)
|
||||||
{
|
{
|
||||||
|
json::stack::member member{out, "events"};
|
||||||
|
json::stack::array array{member};
|
||||||
|
|
||||||
|
const m::room::state state{user_room};
|
||||||
|
state.for_each("ircd.account_data", [&array]
|
||||||
|
(const m::event &event)
|
||||||
|
{
|
||||||
|
json::stack::object object{array};
|
||||||
|
|
||||||
|
// type
|
||||||
|
{
|
||||||
|
json::stack::member member
|
||||||
|
{
|
||||||
|
object, "type", unquote(at<"state_key"_>(event))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// content
|
||||||
|
{
|
||||||
|
json::stack::member member
|
||||||
|
{
|
||||||
|
object, "content", unquote(at<"content"_>(event))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -239,11 +269,9 @@ initialsync_rooms_invite(client &client,
|
||||||
void
|
void
|
||||||
initialsync_rooms(client &client,
|
initialsync_rooms(client &client,
|
||||||
const resource::request &request,
|
const resource::request &request,
|
||||||
json::stack::object &out)
|
json::stack::object &out,
|
||||||
|
const m::user::room &user_room)
|
||||||
{
|
{
|
||||||
const m::user user{request.user_id};
|
|
||||||
const m::user::room user_room{user};
|
|
||||||
|
|
||||||
// join
|
// join
|
||||||
{
|
{
|
||||||
json::stack::member member{out, "join"};
|
json::stack::member member{out, "join"};
|
||||||
|
|
Loading…
Reference in a new issue