mirror of
https://github.com/matrix-construct/construct
synced 2024-10-02 21:59:02 +02:00
modules/client/sync/rooms/state: Split out the initial sync branch; add room avatar.
This commit is contained in:
parent
a8b536e420
commit
77b4ea969f
1 changed files with 41 additions and 25 deletions
|
@ -12,6 +12,7 @@ namespace ircd::m::sync
|
||||||
{
|
{
|
||||||
static void room_state_append(data &, json::stack::array &, const m::event &, const m::event::idx &);
|
static void room_state_append(data &, json::stack::array &, const m::event &, const m::event::idx &);
|
||||||
|
|
||||||
|
static bool room_state_phased_events(data &);
|
||||||
static bool room_state_polylog_events(data &);
|
static bool room_state_polylog_events(data &);
|
||||||
static bool _room_state_polylog(data &);
|
static bool _room_state_polylog(data &);
|
||||||
static bool room_state_polylog(data &);
|
static bool room_state_polylog(data &);
|
||||||
|
@ -155,39 +156,17 @@ ircd::m::sync::_room_state_polylog(data &data)
|
||||||
bool
|
bool
|
||||||
ircd::m::sync::room_state_polylog_events(data &data)
|
ircd::m::sync::room_state_polylog_events(data &data)
|
||||||
{
|
{
|
||||||
|
if(data.phased && data.range.first == 0)
|
||||||
|
return room_state_phased_events(data);
|
||||||
|
|
||||||
const m::room &room{*data.room};
|
const m::room &room{*data.room};
|
||||||
const m::room::state state{room};
|
const m::room::state state{room};
|
||||||
|
|
||||||
json::stack::array array
|
json::stack::array array
|
||||||
{
|
{
|
||||||
*data.out, "events"
|
*data.out, "events"
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ret{false};
|
bool ret{false};
|
||||||
if(data.phased && data.range.first == 0)
|
|
||||||
{
|
|
||||||
data.room->get(std::nothrow, "m.room.create", "", [&]
|
|
||||||
(const m::event &event)
|
|
||||||
{
|
|
||||||
room_state_append(data, array, event, index(event));
|
|
||||||
ret = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
data.room->get(std::nothrow, "m.room.canonical_alias", "", [&]
|
|
||||||
(const m::event &event)
|
|
||||||
{
|
|
||||||
room_state_append(data, array, event, index(event));
|
|
||||||
});
|
|
||||||
|
|
||||||
data.room->get(std::nothrow, "m.room.name", "", [&]
|
|
||||||
(const m::event &event)
|
|
||||||
{
|
|
||||||
room_state_append(data, array, event, index(event));
|
|
||||||
});
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx::mutex mutex;
|
ctx::mutex mutex;
|
||||||
const event::closure_idx each_idx{[&data, &array, &mutex, &ret]
|
const event::closure_idx each_idx{[&data, &array, &mutex, &ret]
|
||||||
(const m::event::idx event_idx)
|
(const m::event::idx event_idx)
|
||||||
|
@ -234,6 +213,43 @@ ircd::m::sync::room_state_polylog_events(data &data)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ircd::m::sync::room_state_phased_events(data &data)
|
||||||
|
{
|
||||||
|
json::stack::array array
|
||||||
|
{
|
||||||
|
*data.out, "events"
|
||||||
|
};
|
||||||
|
|
||||||
|
bool ret{false};
|
||||||
|
data.room->get(std::nothrow, "m.room.create", "", [&]
|
||||||
|
(const m::event &event)
|
||||||
|
{
|
||||||
|
room_state_append(data, array, event, index(event));
|
||||||
|
ret = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
data.room->get(std::nothrow, "m.room.canonical_alias", "", [&]
|
||||||
|
(const m::event &event)
|
||||||
|
{
|
||||||
|
room_state_append(data, array, event, index(event));
|
||||||
|
});
|
||||||
|
|
||||||
|
data.room->get(std::nothrow, "m.room.name", "", [&]
|
||||||
|
(const m::event &event)
|
||||||
|
{
|
||||||
|
room_state_append(data, array, event, index(event));
|
||||||
|
});
|
||||||
|
|
||||||
|
data.room->get(std::nothrow, "m.room.avatar", "", [&]
|
||||||
|
(const m::event &event)
|
||||||
|
{
|
||||||
|
room_state_append(data, array, event, index(event));
|
||||||
|
});
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ircd::m::sync::room_state_append(data &data,
|
ircd::m::sync::room_state_append(data &data,
|
||||||
json::stack::array &events,
|
json::stack::array &events,
|
||||||
|
|
Loading…
Reference in a new issue