use std::net::IpAddr;
use mas_data_model::{BrowserSession, CompatSession, Session};
use mas_storage::Clock;
use crate::activity_tracker::ActivityTracker;
#[derive(Clone)]
pub struct Bound {
tracker: ActivityTracker,
ip: Option<IpAddr>,
}
impl Bound {
#[must_use]
pub fn new(tracker: ActivityTracker, ip: Option<IpAddr>) -> Self {
Self { tracker, ip }
}
#[must_use]
pub fn ip(&self) -> Option<IpAddr> {
self.ip
}
pub async fn record_oauth2_session(&self, clock: &dyn Clock, session: &Session) {
self.tracker
.record_oauth2_session(clock, session, self.ip)
.await;
}
pub async fn record_compat_session(&self, clock: &dyn Clock, session: &CompatSession) {
self.tracker
.record_compat_session(clock, session, self.ip)
.await;
}
pub async fn record_browser_session(&self, clock: &dyn Clock, session: &BrowserSession) {
self.tracker
.record_browser_session(clock, session, self.ip)
.await;
}
}