mas_handlers/activity_tracker/
bound.rs1use std::net::IpAddr;
8
9use mas_data_model::{BrowserSession, CompatSession, Session};
10use mas_storage::Clock;
11
12use crate::activity_tracker::ActivityTracker;
13
14#[derive(Clone)]
16pub struct Bound {
17 tracker: ActivityTracker,
18 ip: Option<IpAddr>,
19}
20
21impl Bound {
22 #[must_use]
24 pub fn new(tracker: ActivityTracker, ip: Option<IpAddr>) -> Self {
25 Self { tracker, ip }
26 }
27
28 #[must_use]
30 pub fn ip(&self) -> Option<IpAddr> {
31 self.ip
32 }
33
34 pub async fn record_oauth2_session(&self, clock: &dyn Clock, session: &Session) {
36 self.tracker
37 .record_oauth2_session(clock, session, self.ip)
38 .await;
39 }
40
41 pub async fn record_compat_session(&self, clock: &dyn Clock, session: &CompatSession) {
43 self.tracker
44 .record_compat_session(clock, session, self.ip)
45 .await;
46 }
47
48 pub async fn record_browser_session(&self, clock: &dyn Clock, session: &BrowserSession) {
50 self.tracker
51 .record_browser_session(clock, session, self.ip)
52 .await;
53 }
54}