diff --git a/crates/im-client/src/directory.rs b/crates/im-client/src/directory.rs
index 70bb31b..03c257a 100644
--- a/crates/im-client/src/directory.rs
+++ b/crates/im-client/src/directory.rs
@@ -46,6 +46,16 @@ pub struct DirectoryMember {
/// `/photo/{sub}` be cached hard and still arrive fresh.
#[serde(default)]
pub photo_version: u64,
+ /// The member's display timezone (a fixed offset like "UTC+03:00").
+ /// Defaulted: rows mirrored before im carried the field still read.
+ #[serde(default = "default_timezone")]
+ pub timezone: String,
+}
+
+/// The timezone im starts every account on, and the one this SDK assumes
+/// when a mirrored row predates the field.
+fn default_timezone() -> String {
+ "UTC+03:00".to_string()
}
/// One event off the directory stream. The only thing `/directory/live`
@@ -366,6 +376,7 @@ mod tests {
assert_eq!(
events,
vec![DirectoryEvent::Profile(DirectoryMember {
+ timezone: default_timezone(),
sub: "one".into(),
email: "one@example.com".into(),
name: "Ann".into(),
@@ -387,6 +398,7 @@ mod tests {
events.extend(parser.feed(&whole.as_bytes()[cut..]));
assert_eq!(events.len(), 1, "cut at {cut}");
assert_eq!(events[0], DirectoryEvent::Profile(DirectoryMember {
+ timezone: default_timezone(),
sub: "two".into(),
email: "two@example.com".into(),
name: "Ann".into(),
@@ -403,6 +415,7 @@ mod tests {
let events = parser.feed(frame("three", 1).replace('\n', "\r\n").as_bytes());
assert_eq!(events.len(), 1);
assert_eq!(events[0], DirectoryEvent::Profile(DirectoryMember {
+ timezone: default_timezone(),
sub: "three".into(),
email: "three@example.com".into(),
name: "Ann".into(),
@@ -429,6 +442,7 @@ mod tests {
assert_eq!(
events[0],
DirectoryEvent::Profile(DirectoryMember {
+ timezone: default_timezone(),
sub: "four".into(),
email: "four@example.com".into(),
name: "Ann".into(),
diff --git a/crates/im-core/src/accounts.rs b/crates/im-core/src/accounts.rs
index ed10245..e3d03a1 100644
--- a/crates/im-core/src/accounts.rs
+++ b/crates/im-core/src/accounts.rs
@@ -20,7 +20,7 @@ use sha2::{Digest, Sha256};
use subtle::ConstantTimeEq;
use time::OffsetDateTime;
-use crate::model::{Invite, User, UserId};
+use crate::model::{DEFAULT_TIMEZONE, Invite, User, UserId};
use crate::store::{self, Result, Store, StoreError, backend};
/// Argon2id at the OWASP Password Storage Cheat Sheet's recommended second
@@ -392,6 +392,7 @@ pub async fn create_user_from_invite(
theme: "light".to_string(),
language: "en".to_string(),
ui: "instrument".to_string(),
+ timezone: DEFAULT_TIMEZONE.to_string(),
};
let password_hash = hash_password(password)?;
// The lock is taken only now — the reads above (`invite_by_token`) lock
@@ -656,7 +657,8 @@ pub async fn verify_login(
let mut rows = conn
.query(
"SELECT id, email, name, password_hash, totp_confirmed, admin, disabled, created_at, \
- photo_mime IS NOT NULL, photo_version, theme, language, ui FROM users WHERE email = ?1 COLLATE NOCASE",
+ photo_mime IS NOT NULL, photo_version, theme, language, ui, timezone \
+ FROM users WHERE email = ?1 COLLATE NOCASE",
turso::params![email],
)
.await
@@ -678,6 +680,7 @@ pub async fn verify_login(
theme: store::text(&row, 10)?,
language: store::text(&row, 11)?,
ui: store::text(&row, 12)?,
+ timezone: store::text(&row, 13)?,
};
let phc = store::text(&row, 3)?;
if !verify_password(password, &phc) || user.disabled {
@@ -750,7 +753,8 @@ pub async fn user_by_id(store: &Store, id: &UserId) -> Result