feat: store user agent with sessions

This commit is contained in:
Jef Roosens 2025-03-29 15:37:50 +01:00
parent 5112a6ce35
commit 2c44f788d9
No known key found for this signature in database
GPG key ID: 21FD3D77D56BAF49
9 changed files with 23 additions and 5 deletions

View file

@ -0,0 +1,2 @@
alter table sessions
drop column user_agent;

View file

@ -0,0 +1,2 @@
alter table sessions
add column user_agent text;

View file

@ -10,6 +10,7 @@ pub struct Session {
pub id: i64,
pub user_id: i64,
pub last_seen: i64,
pub user_agent: Option<String>,
}
impl Session {

View file

@ -59,6 +59,7 @@ impl gpodder::AuthStore for SqliteRepository {
id: session.id,
last_seen: DateTime::from_timestamp(session.last_seen, 0).unwrap(),
user: user.into(),
user_agent: session.user_agent.clone(),
})),
Ok(None) => Ok(None),
Err(err) => Err(DbError::from(err).into()),
@ -79,6 +80,7 @@ impl gpodder::AuthStore for SqliteRepository {
id: session.id,
user_id: session.user.id,
last_seen: session.last_seen.timestamp(),
user_agent: session.user_agent.clone(),
}
.insert_into(sessions::table)
.execute(&mut self.pool.get().map_err(DbError::from)?)

View file

@ -43,6 +43,7 @@ diesel::table! {
id -> BigInt,
user_id -> BigInt,
last_seen -> BigInt,
user_agent -> Nullable<Text>,
}
}