CompatSessionRepository

Trait CompatSessionRepository 

Source
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§

Source

type Error

The error type returned by the repository

Required Methods§

Source

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

Source

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 use
  • clock: The clock used to generate timestamps
  • user: The user to create the compat session for
  • device: The device ID of this session
  • browser_session: The browser session which created this session
  • is_synapse_admin: Whether the session is a synapse admin session
  • human_name: The human-readable name of the session provided by the client or the user
§Errors

Returns Self::Error if the underlying repository fails

Source

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 timestamps
  • compat_session: The compat session to end
§Errors

Returns Self::Error if the underlying repository fails

Source

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 timestamps
  • filter: The filter to apply
§Errors

Returns Self::Error if the underlying repository fails

Source

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 apply
  • pagination: The pagination parameters
§Errors

Returns Self::Error if the underlying repository fails

Source

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

Source

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

Source

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 for
  • user_agent: The user agent to record
§Errors

Returns Self::Error if the underlying repository fails

Source

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 for
  • human_name: The human name to set
§Errors

Returns Self::Error if the underlying repository fails

Source

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 timestamp
  • until: Only delete sessions finished before this timestamp
  • limit: Maximum number of sessions to delete
§Errors

Returns Self::Error if the underlying repository fails

Source

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 with last_active_at at or after this timestamp (exclusive). If None, starts from the beginning.
  • threshold: Clear IPs for sessions with last_active_at before this time
  • limit: Maximum number of sessions to update in this batch
§Errors

Returns Self::Error if the underlying repository fails

Implementations on Foreign Types§

Source§

impl<R> CompatSessionRepository for Box<R>

Source§

type Error = <R as CompatSessionRepository>::Error

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Implementors§