pub trait CompatSessionRepository: Send + Sync {
type Error;
// Required methods
fn lookup<'life0, 'async_trait>(
&'life0 mut self,
id: Ulid,
) -> Pin<Box<dyn Future<Output = Result<Option<CompatSession>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn add<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
rng: &'life1 mut (dyn RngCore + Send),
clock: &'life2 dyn Clock,
user: &'life3 User,
device: Device,
browser_session: Option<&'life4 BrowserSession>,
is_synapse_admin: bool,
human_name: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait;
fn finish<'life0, 'life1, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
compat_session: CompatSession,
) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn finish_bulk<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
filter: CompatSessionFilter<'life2>,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn list<'life0, 'life1, 'async_trait>(
&'life0 mut self,
filter: CompatSessionFilter<'life1>,
pagination: Pagination,
) -> Pin<Box<dyn Future<Output = Result<Page<(CompatSession, Option<CompatSsoLogin>)>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn count<'life0, 'life1, 'async_trait>(
&'life0 mut self,
filter: CompatSessionFilter<'life1>,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn record_batch_activity<'life0, 'async_trait>(
&'life0 mut self,
activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn record_user_agent<'life0, 'async_trait>(
&'life0 mut self,
compat_session: CompatSession,
user_agent: String,
) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn set_human_name<'life0, 'async_trait>(
&'life0 mut self,
compat_session: CompatSession,
human_name: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn cleanup_finished<'life0, 'async_trait>(
&'life0 mut self,
since: Option<DateTime<Utc>>,
until: DateTime<Utc>,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<(usize, Option<DateTime<Utc>>), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn cleanup_inactive_ips<'life0, 'async_trait>(
&'life0 mut self,
since: Option<DateTime<Utc>>,
threshold: DateTime<Utc>,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<(usize, Option<DateTime<Utc>>), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
A CompatSessionRepository helps interacting with
CompatSession saved in the storage backend
Required Associated Types§
Required Methods§
Sourcefn lookup<'life0, 'async_trait>(
&'life0 mut self,
id: Ulid,
) -> Pin<Box<dyn Future<Output = Result<Option<CompatSession>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn lookup<'life0, 'async_trait>(
&'life0 mut self,
id: Ulid,
) -> Pin<Box<dyn Future<Output = Result<Option<CompatSession>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Lookup a compat session by its ID
Returns the compat session if it exists, None otherwise
§Parameters
id: The ID of the compat session to lookup
§Errors
Returns Self::Error if the underlying repository fails
Sourcefn add<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
rng: &'life1 mut (dyn RngCore + Send),
clock: &'life2 dyn Clock,
user: &'life3 User,
device: Device,
browser_session: Option<&'life4 BrowserSession>,
is_synapse_admin: bool,
human_name: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn add<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
rng: &'life1 mut (dyn RngCore + Send),
clock: &'life2 dyn Clock,
user: &'life3 User,
device: Device,
browser_session: Option<&'life4 BrowserSession>,
is_synapse_admin: bool,
human_name: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Start a new compat session
Returns the newly created compat session
§Parameters
rng: The random number generator to useclock: The clock used to generate timestampsuser: The user to create the compat session fordevice: The device ID of this sessionbrowser_session: The browser session which created this sessionis_synapse_admin: Whether the session is a synapse admin sessionhuman_name: The human-readable name of the session provided by the client or the user
§Errors
Returns Self::Error if the underlying repository fails
Sourcefn finish<'life0, 'life1, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
compat_session: CompatSession,
) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn finish<'life0, 'life1, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
compat_session: CompatSession,
) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
End a compat session
Returns the ended compat session
§Parameters
clock: The clock used to generate timestampscompat_session: The compat session to end
§Errors
Returns Self::Error if the underlying repository fails
Sourcefn finish_bulk<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
filter: CompatSessionFilter<'life2>,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn finish_bulk<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
filter: CompatSessionFilter<'life2>,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Mark all the CompatSession matching the given filter as finished
Returns the number of sessions affected
§Parameters
clock: The clock used to generate timestampsfilter: The filter to apply
§Errors
Returns Self::Error if the underlying repository fails
Sourcefn list<'life0, 'life1, 'async_trait>(
&'life0 mut self,
filter: CompatSessionFilter<'life1>,
pagination: Pagination,
) -> Pin<Box<dyn Future<Output = Result<Page<(CompatSession, Option<CompatSsoLogin>)>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list<'life0, 'life1, 'async_trait>(
&'life0 mut self,
filter: CompatSessionFilter<'life1>,
pagination: Pagination,
) -> Pin<Box<dyn Future<Output = Result<Page<(CompatSession, Option<CompatSsoLogin>)>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
List CompatSession with the given filter and pagination
Returns a page of compat sessions, with the associated SSO logins if any
§Parameters
filter: The filter to applypagination: The pagination parameters
§Errors
Returns Self::Error if the underlying repository fails
Sourcefn count<'life0, 'life1, 'async_trait>(
&'life0 mut self,
filter: CompatSessionFilter<'life1>,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn count<'life0, 'life1, 'async_trait>(
&'life0 mut self,
filter: CompatSessionFilter<'life1>,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Count the number of CompatSession with the given filter
§Parameters
filter: The filter to apply
§Errors
Returns Self::Error if the underlying repository fails
Sourcefn record_batch_activity<'life0, 'async_trait>(
&'life0 mut self,
activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn record_batch_activity<'life0, 'async_trait>(
&'life0 mut self,
activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Record a batch of CompatSession activity
§Parameters
activity: A list of tuples containing the session ID, the last activity timestamp and the IP address of the client
§Errors
Returns Self::Error if the underlying repository fails
Sourcefn record_user_agent<'life0, 'async_trait>(
&'life0 mut self,
compat_session: CompatSession,
user_agent: String,
) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn record_user_agent<'life0, 'async_trait>(
&'life0 mut self,
compat_session: CompatSession,
user_agent: String,
) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Record the user agent of a compat session
§Parameters
compat_session: The compat session to record the user agent foruser_agent: The user agent to record
§Errors
Returns Self::Error if the underlying repository fails
Sourcefn set_human_name<'life0, 'async_trait>(
&'life0 mut self,
compat_session: CompatSession,
human_name: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_human_name<'life0, 'async_trait>(
&'life0 mut self,
compat_session: CompatSession,
human_name: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Set the human name of a compat session
§Parameters
compat_session: The compat session to set the human name forhuman_name: The human name to set
§Errors
Returns Self::Error if the underlying repository fails
Sourcefn cleanup_finished<'life0, 'async_trait>(
&'life0 mut self,
since: Option<DateTime<Utc>>,
until: DateTime<Utc>,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<(usize, Option<DateTime<Utc>>), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cleanup_finished<'life0, 'async_trait>(
&'life0 mut self,
since: Option<DateTime<Utc>>,
until: DateTime<Utc>,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<(usize, Option<DateTime<Utc>>), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Cleanup finished CompatSessions and their associated tokens.
This deletes compat sessions that have been finished, along with their associated access tokens, refresh tokens, and SSO logins.
Returns the number of sessions deleted and the timestamp of the last
deleted session’s finished_at, which can be used for pagination.
§Parameters
since: Only delete sessions finished at or after this timestampuntil: Only delete sessions finished before this timestamplimit: Maximum number of sessions to delete
§Errors
Returns Self::Error if the underlying repository fails
Sourcefn cleanup_inactive_ips<'life0, 'async_trait>(
&'life0 mut self,
since: Option<DateTime<Utc>>,
threshold: DateTime<Utc>,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<(usize, Option<DateTime<Utc>>), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cleanup_inactive_ips<'life0, 'async_trait>(
&'life0 mut self,
since: Option<DateTime<Utc>>,
threshold: DateTime<Utc>,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<(usize, Option<DateTime<Utc>>), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Clear IP addresses from sessions inactive since the threshold
Sets last_active_ip to NULL for sessions where last_active_at is
before the threshold. Returns the number of sessions affected and the
last last_active_at timestamp processed for pagination.
§Parameters
since: Only process sessions withlast_active_atat or after this timestamp (exclusive). IfNone, starts from the beginning.threshold: Clear IPs for sessions withlast_active_atbefore this timelimit: Maximum number of sessions to update in this batch
§Errors
Returns Self::Error if the underlying repository fails