0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-26 13:58:18 +02:00

modules/client/sync: Add a 'semaphore mode' for muted sync.

This commit is contained in:
Jason Volk 2019-07-12 14:32:51 -07:00
parent 6b54ab902e
commit 023167b440
2 changed files with 20 additions and 0 deletions

View file

@ -296,6 +296,9 @@ ircd::m::sync::handle_get(client &client,
// in the range being considered by the sync. That threshold is
// supplied by a conf item.
&& range.second - range.first <= size_t(linear_delta_max)
// When the semaphore query param is set we don't need linear mode.
&& !args.semaphore
};
// Determine if polylog sync mode should be used.
@ -304,6 +307,9 @@ ircd::m::sync::handle_get(client &client,
// Polylog mode is only used when neither of the other two modes
// are determined.
!should_longpoll && !should_linear
// When the semaphore query param is set we don't need polylog mode.
&& !args.semaphore
};
// Determine if an empty sync response should be returned to the user.
@ -894,6 +900,11 @@ ircd::m::sync::longpoll::polled(data &data,
if(!consumed)
return false;
// In semaphore-mode we're just here to ride the longpoll's blocking
// behavior. We want the client to get an empty response.
if(args.semaphore)
return false;
const json::vector vector
{
string_view

View file

@ -105,5 +105,14 @@ struct ircd::m::sync::args
request.query.get("phased", true)
};
/// (non-spec) If this is set to true, the only response content from /sync
/// will be a `next_batch` token. This is useful for clients that only want
/// to use /sync as a semaphore notifying about new activity, but will
/// retrieve the actual data another way.
bool semaphore
{
request.query.get("semaphore", false)
};
args(const resource::request &request);
};