forge
Explore
Log in

Don't you dare go Hollow

the clock follows the face: im's timezone rides the directory onto the user row — sync_member stamps it on insert and update and a changed zone announces Members like a changed photo does — and iz's own timezone editor is gone: the profile form carries only theme, interface and language, a posted zone is not read (never refused, never saved), the save path carries the row's im-given zone through untouched, the dead bad-zone refusal and its wording leave with the field, and the stamp-shift tests set the viewer's zone the one way it still changes — through the mirror

Browse files at this commit

c9a65a3d138de84b498cd165e99d965561458b8aAhmet Kaan GümüşParent: e11a598
Cargo.lockmodified+1 -1
@@ -1771,7 +1771,7 @@ dependencies = [
1771 [[package]]1771 [[package]]
1772 name = "im-client"1772 name = "im-client"
1773 version = "0.1.0"1773 version = "0.1.0"
1774-source = "git+https://github.com/DizeyLab/im?rev=f7b2081#f7b208171820ca309b10043c6e86de12b81f3826"1774+source = "git+https://github.com/DizeyLab/im?rev=509d0e7#509d0e7b19104ad3ae2e1dc82c65e1f38dfe7d9b"
1775 dependencies = [1775 dependencies = [
1776 "base64 0.22.1",1776 "base64 0.22.1",
1777 "chacha20poly1305",1777 "chacha20poly1305",
Cargo.tomlmodified+1 -1
@@ -11,7 +11,7 @@ repository = "https://github.com/DizeyLab/iz"
11 [workspace.dependencies]11 [workspace.dependencies]
12 iz-core = { path = "crates/iz-core", default-features = false }12 iz-core = { path = "crates/iz-core", default-features = false }
13 iz-client = { path = "crates/iz-client" }13 iz-client = { path = "crates/iz-client" }
14-im-client = { git = "https://github.com/DizeyLab/im", rev = "f7b2081", default-features = false }14+im-client = { git = "https://github.com/DizeyLab/im", rev = "509d0e7", default-features = false }
15 serde = { version = "1.0.229", features = ["derive"] }15 serde = { version = "1.0.229", features = ["derive"] }
16 serde_json = "1.0.145"16 serde_json = "1.0.145"
17 thiserror = "2.0.20"17 thiserror = "2.0.20"
crates/iz-core/src/store/mod.rsmodified+4 -2
@@ -789,8 +789,9 @@ pub trait Store: BoardReads + DetailReads + 'static {
789 /// gets a row born linked — assignable, mailable and avatar-able before789 /// gets a row born linked — assignable, mailable and avatar-able before
790 /// their first visit. An unclaimed row with a matching address is790 /// their first visit. An unclaimed row with a matching address is
791 /// claimed (sub stamped, id/role/preferences/history kept), a known row791 /// claimed (sub stamped, id/role/preferences/history kept), a known row
792- /// follows the provider's address, name, admin flag and photo version,792+ /// follows the provider's address, name, admin flag, photo version and
793- /// and a row that already agrees is left alone. Unlike793+ /// timezone — the provider owns the clock now — and a row that already
794+ /// agrees is left alone. Unlike
794 /// [`Store::provision_user`] this is not a sign-in: `last_signed_in_at`795 /// [`Store::provision_user`] this is not a sign-in: `last_signed_in_at`
795 /// is never stamped, and an empty database grows no workspace (the first796 /// is never stamped, and an empty database grows no workspace (the first
796 /// sign-in builds it; the next beat mirrors everyone). The admin flag797 /// sign-in builds it; the next beat mirrors everyone). The admin flag
@@ -803,6 +804,7 @@ pub trait Store: BoardReads + DetailReads + 'static {
803 display_name: &str,804 display_name: &str,
804 im_admin: bool,805 im_admin: bool,
805 photo_version: u64,806 photo_version: u64,
807+ timezone: &str,
806 ) -> Result<MemberSync>;808 ) -> Result<MemberSync>;
807 809
808 async fn user(&self, id: &str) -> Result<Option<User>>;810 async fn user(&self, id: &str) -> Result<Option<User>>;
crates/iz-core/src/store/turso_store.rsmodified+11 -5
@@ -1465,6 +1465,7 @@ impl Store for TursoStore {
1465 display_name: &str,1465 display_name: &str,
1466 im_admin: bool,1466 im_admin: bool,
1467 photo_version: u64,1467 photo_version: u64,
1468+ timezone: &str,
1468 ) -> Result<MemberSync> {1469 ) -> Result<MemberSync> {
1469 let email = fold_email(email);1470 let email = fold_email(email);
1470 // IMMEDIATE like provision_user: a beat racing a first sign-in over1471 // IMMEDIATE like provision_user: a beat racing a first sign-in over
@@ -1491,17 +1492,19 @@ impl Store for TursoStore {
1491 && user.display_name == display_name1492 && user.display_name == display_name
1492 && role == user.role1493 && role == user.role
1493 && user.photo_version == photo_version1494 && user.photo_version == photo_version
1495+ && user.timezone == timezone
1494 {1496 {
1495 Some((user.id, MemberSync::Untouched))1497 Some((user.id, MemberSync::Untouched))
1496 } else {1498 } else {
1497 tx.execute(1499 tx.execute(
1498 "UPDATE user SET email = ?1, display_name = ?2, role = ?3, \1500 "UPDATE user SET email = ?1, display_name = ?2, role = ?3, \
1499- photo_version = ?4 WHERE id = ?5",1501+ photo_version = ?4, timezone = ?5 WHERE id = ?6",
1500 params![1502 params![
1501 email.clone(),1503 email.clone(),
1502 display_name,1504 display_name,
1503 role.as_str(),1505 role.as_str(),
1504 photo_version as i64,1506 photo_version as i64,
1507+ timezone,
1505 user.id.clone()1508 user.id.clone()
1506 ],1509 ],
1507 )1510 )
@@ -1525,13 +1528,14 @@ impl Store for TursoStore {
1525 let role = synced_role(user.role, im_admin);1528 let role = synced_role(user.role, im_admin);
1526 tx.execute(1529 tx.execute(
1527 "UPDATE user SET oidc_sub = ?1, email = ?2, display_name = ?3, role = ?4, \1530 "UPDATE user SET oidc_sub = ?1, email = ?2, display_name = ?3, role = ?4, \
1528- photo_version = ?5 WHERE id = ?6",1531+ photo_version = ?5, timezone = ?6 WHERE id = ?7",
1529 params![1532 params![
1530 sub,1533 sub,
1531 email.clone(),1534 email.clone(),
1532 display_name,1535 display_name,
1533 role.as_str(),1536 role.as_str(),
1534 photo_version as i64,1537 photo_version as i64,
1538+ timezone,
1535 user.id.clone()1539 user.id.clone()
1536 ],1540 ],
1537 )1541 )
@@ -1561,8 +1565,9 @@ impl Store for TursoStore {
1561 let role = if im_admin { Role::Admin } else { Role::Member };1565 let role = if im_admin { Role::Admin } else { Role::Member };
1562 tx.execute(1566 tx.execute(
1563 "INSERT INTO user (id, workspace_id, oidc_sub, email, display_name, \1567 "INSERT INTO user (id, workspace_id, oidc_sub, email, display_name, \
1564- role, disabled, created_at, last_signed_in_at, photo_version) \1568+ role, disabled, created_at, last_signed_in_at, photo_version, \
1565- VALUES (?1, ?2, ?3, ?4, ?5, ?6, 0, ?7, NULL, ?8)",1569+ timezone) \
1570+ VALUES (?1, ?2, ?3, ?4, ?5, ?6, 0, ?7, NULL, ?8, ?9)",
1566 params![1571 params![
1567 id.clone(),1572 id.clone(),
1568 workspace_id,1573 workspace_id,
@@ -1571,7 +1576,8 @@ impl Store for TursoStore {
1571 display_name,1576 display_name,
1572 role.as_str(),1577 role.as_str(),
1573 now.clone(),1578 now.clone(),
1574- photo_version as i641579+ photo_version as i64,
1580+ timezone
1575 ],1581 ],
1576 )1582 )
1577 .await1583 .await
crates/iz-core/tests/store.rsmodified+60 -14
@@ -8407,7 +8407,7 @@ async fn set_user_disabled_round_trips() {
8407 async fn a_synced_member_is_born_linked_and_never_signed_in() {8407 async fn a_synced_member_is_born_linked_and_never_signed_in() {
8408 let (scratch, workspace, _admin) = workspace_with_admin().await;8408 let (scratch, workspace, _admin) = workspace_with_admin().await;
8409 let sync = scratch8409 let sync = scratch
8410- .store.sync_member("sub-mert", "mert@iz.sh", "Mert", false, 0)8410+ .store.sync_member("sub-mert", "mert@iz.sh", "Mert", false, 0, "UTC+03:00")
8411 .await8411 .await
8412 .unwrap();8412 .unwrap();
8413 assert_eq!(sync, iz_core::store::MemberSync::Inserted);8413 assert_eq!(sync, iz_core::store::MemberSync::Inserted);
@@ -8422,7 +8422,7 @@ async fn a_synced_member_is_born_linked_and_never_signed_in() {
8422 assert!(row.last_signed_in_at.is_none());8422 assert!(row.last_signed_in_at.is_none());
8423 // An im admin the workspace has never met is Admin from the first beat.8423 // An im admin the workspace has never met is Admin from the first beat.
8424 scratch8424 scratch
8425- .store.sync_member("sub-boss", "boss@iz.sh", "Boss", true, 0)8425+ .store.sync_member("sub-boss", "boss@iz.sh", "Boss", true, 0, "UTC+03:00")
8426 .await8426 .await
8427 .unwrap();8427 .unwrap();
8428 let boss = scratch8428 let boss = scratch
@@ -8443,7 +8443,7 @@ async fn a_sync_claims_an_unclaimed_row_without_touching_its_sign_in_fact() {
8443 .await8443 .await
8444 .unwrap();8444 .unwrap();
8445 let sync = scratch8445 let sync = scratch
8446- .store.sync_member("sub-mert", "MERT@iz.sh", "Mert Yılmaz", false, 0)8446+ .store.sync_member("sub-mert", "MERT@iz.sh", "Mert Yılmaz", false, 0, "UTC+03:00")
8447 .await8447 .await
8448 .unwrap();8448 .unwrap();
8449 assert_eq!(sync, iz_core::store::MemberSync::Claimed);8449 assert_eq!(sync, iz_core::store::MemberSync::Claimed);
@@ -8460,11 +8460,11 @@ async fn a_sync_claims_an_unclaimed_row_without_touching_its_sign_in_fact() {
8460 8460
8461 #[tokio::test]8461 #[tokio::test]
8462 async fn a_sync_follows_provider_drift_but_not_the_sign_in_fact() {8462 async fn a_sync_follows_provider_drift_but_not_the_sign_in_fact() {
8463- let (scratch, workspace, admin_id) = workspace_with_admin().await;8463+ let (scratch, _workspace, admin_id) = workspace_with_admin().await;
8464 let before = scratch.store.user(&admin_id).await.unwrap().unwrap();8464 let before = scratch.store.user(&admin_id).await.unwrap().unwrap();
8465 let seen = before.last_signed_in_at.clone();8465 let seen = before.last_signed_in_at.clone();
8466 let sync = scratch8466 let sync = scratch
8467- .store.sync_member("sub-ada", "ada@iz.sh", "Ada Lovelace", true, 0)8467+ .store.sync_member("sub-ada", "ada@iz.sh", "Ada Lovelace", true, 0, "UTC+03:00")
8468 .await8468 .await
8469 .unwrap();8469 .unwrap();
8470 assert_eq!(sync, iz_core::store::MemberSync::Refreshed);8470 assert_eq!(sync, iz_core::store::MemberSync::Refreshed);
@@ -8473,7 +8473,7 @@ async fn a_sync_follows_provider_drift_but_not_the_sign_in_fact() {
8473 assert_eq!(after.last_signed_in_at, seen);8473 assert_eq!(after.last_signed_in_at, seen);
8474 // Losing the flag in the directory drops an Admin to Member.8474 // Losing the flag in the directory drops an Admin to Member.
8475 scratch8475 scratch
8476- .store.sync_member("sub-ada", "ada@iz.sh", "Ada Lovelace", false, 0)8476+ .store.sync_member("sub-ada", "ada@iz.sh", "Ada Lovelace", false, 0, "UTC+03:00")
8477 .await8477 .await
8478 .unwrap();8478 .unwrap();
8479 let demoted = scratch.store.user(&admin_id).await.unwrap().unwrap();8479 let demoted = scratch.store.user(&admin_id).await.unwrap().unwrap();
@@ -8485,7 +8485,7 @@ async fn an_agreeing_sync_is_untouched_and_silent() {
8485 let (scratch, _, _) = workspace_with_admin().await;8485 let (scratch, _, _) = workspace_with_admin().await;
8486 let mut rx = scratch.store.subscribe();8486 let mut rx = scratch.store.subscribe();
8487 let sync = scratch8487 let sync = scratch
8488- .store.sync_member("sub-ada", "ada@iz.sh", "Ada", true, 0)8488+ .store.sync_member("sub-ada", "ada@iz.sh", "Ada", true, 0, "UTC")
8489 .await8489 .await
8490 .unwrap();8490 .unwrap();
8491 assert_eq!(sync, iz_core::store::MemberSync::Untouched);8491 assert_eq!(sync, iz_core::store::MemberSync::Untouched);
@@ -8496,7 +8496,7 @@ async fn an_agreeing_sync_is_untouched_and_silent() {
8496 async fn a_sync_without_a_workspace_skips_and_writes_nothing() {8496 async fn a_sync_without_a_workspace_skips_and_writes_nothing() {
8497 let scratch = Scratch::open().await;8497 let scratch = Scratch::open().await;
8498 let sync = scratch8498 let sync = scratch
8499- .store.sync_member("sub-mert", "mert@iz.sh", "Mert", false, 0)8499+ .store.sync_member("sub-mert", "mert@iz.sh", "Mert", false, 0, "UTC+03:00")
8500 .await8500 .await
8501 .unwrap();8501 .unwrap();
8502 assert_eq!(sync, iz_core::store::MemberSync::Skipped);8502 assert_eq!(sync, iz_core::store::MemberSync::Skipped);
@@ -8512,8 +8512,7 @@ async fn a_photo_version_bump_refreshes_and_announces() {
8512 let (scratch, workspace, _admin) = workspace_with_admin().await;8512 let (scratch, workspace, _admin) = workspace_with_admin().await;
8513 let mut rx = scratch.store.subscribe();8513 let mut rx = scratch.store.subscribe();
8514 let sync = scratch8514 let sync = scratch
8515- .store8515+ .store.sync_member("sub-mert", "mert@iz.sh", "Mert", false, 2, "UTC+03:00")
8516- .sync_member("sub-mert", "mert@iz.sh", "Mert", false, 2)
8517 .await8516 .await
8518 .unwrap();8517 .unwrap();
8519 assert_eq!(sync, iz_core::store::MemberSync::Inserted);8518 assert_eq!(sync, iz_core::store::MemberSync::Inserted);
@@ -8528,8 +8527,7 @@ async fn a_photo_version_bump_refreshes_and_announces() {
8528 8527
8529 // The same version again: the row agrees, and silence is the answer.8528 // The same version again: the row agrees, and silence is the answer.
8530 let again = scratch8529 let again = scratch
8531- .store8530+ .store.sync_member("sub-mert", "mert@iz.sh", "Mert", false, 2, "UTC+03:00")
8532- .sync_member("sub-mert", "mert@iz.sh", "Mert", false, 2)
8533 .await8531 .await
8534 .unwrap();8532 .unwrap();
8535 assert_eq!(again, iz_core::store::MemberSync::Untouched);8533 assert_eq!(again, iz_core::store::MemberSync::Untouched);
@@ -8537,8 +8535,7 @@ async fn a_photo_version_bump_refreshes_and_announces() {
8537 8535
8538 // im counted another upload: the stamp moves and the move is news.8536 // im counted another upload: the stamp moves and the move is news.
8539 let bumped = scratch8537 let bumped = scratch
8540- .store8538+ .store.sync_member("sub-mert", "mert@iz.sh", "Mert", false, 3, "UTC+03:00")
8541- .sync_member("sub-mert", "mert@iz.sh", "Mert", false, 3)
8542 .await8539 .await
8543 .unwrap();8540 .unwrap();
8544 assert_eq!(bumped, iz_core::store::MemberSync::Refreshed);8541 assert_eq!(bumped, iz_core::store::MemberSync::Refreshed);
@@ -8552,6 +8549,55 @@ async fn a_photo_version_bump_refreshes_and_announces() {
8552 assert_eq!(announced(&mut rx), vec!["members".to_string()]);8549 assert_eq!(announced(&mut rx), vec!["members".to_string()]);
8553 }8550 }
8554 8551
8552+/// The clock is the provider's fact now: a sync that hears of a member's
8553+/// timezone stamps it and says Refreshed (so the live channel hears), one
8554+/// that already agrees says Untouched, and a row born from the directory
8555+/// opens on the timezone im holds — never on iz's own old default.
8556+#[tokio::test]
8557+async fn a_timezone_change_refreshes_and_announces() {
8558+ let (scratch, workspace, _admin) = workspace_with_admin().await;
8559+ let mut rx = scratch.store.subscribe();
8560+ let sync = scratch
8561+ .store
8562+ .sync_member("sub-deniz", "deniz@iz.sh", "Deniz", false, 0, "UTC-05:00")
8563+ .await
8564+ .unwrap();
8565+ assert_eq!(sync, iz_core::store::MemberSync::Inserted);
8566+ let row = scratch
8567+ .store
8568+ .user_by_email(&workspace, "deniz@iz.sh")
8569+ .await
8570+ .unwrap()
8571+ .unwrap();
8572+ assert_eq!(row.timezone, "UTC-05:00");
8573+ assert_eq!(announced(&mut rx), vec!["members".to_string()]);
8574+
8575+ // The same timezone again: the row agrees, and silence is the answer.
8576+ let again = scratch
8577+ .store
8578+ .sync_member("sub-deniz", "deniz@iz.sh", "Deniz", false, 0, "UTC-05:00")
8579+ .await
8580+ .unwrap();
8581+ assert_eq!(again, iz_core::store::MemberSync::Untouched);
8582+ assert!(announced(&mut rx).is_empty());
8583+
8584+ // im recorded a move: the next sync carries it and the move is news.
8585+ let moved = scratch
8586+ .store
8587+ .sync_member("sub-deniz", "deniz@iz.sh", "Deniz", false, 0, "UTC+03:00")
8588+ .await
8589+ .unwrap();
8590+ assert_eq!(moved, iz_core::store::MemberSync::Refreshed);
8591+ let row = scratch
8592+ .store
8593+ .user_by_email(&workspace, "deniz@iz.sh")
8594+ .await
8595+ .unwrap()
8596+ .unwrap();
8597+ assert_eq!(row.timezone, "UTC+03:00");
8598+ assert_eq!(announced(&mut rx), vec!["members".to_string()]);
8599+}
8600+
8555 /// The app-level setting drawer: a key never set reads as absent, one set8601 /// The app-level setting drawer: a key never set reads as absent, one set
8556 /// reads back, and setting it again replaces rather than duplicates — the8602 /// reads back, and setting it again replaces rather than duplicates — the
8557 /// family mirror rewrites its key every beat, and two rows for one key8603 /// family mirror rewrites its key every beat, and two rows for one key
crates/iz-web/src/i18n.rsmodified+0 -3
@@ -132,7 +132,6 @@ pub enum Key {
132 ConnectionLastPass,132 ConnectionLastPass,
133 ConnectionNever,133 ConnectionNever,
134 EmailLabel,134 EmailLabel,
135- TimezoneLabel,
136 ThemeLabel,135 ThemeLabel,
137 LightOption,136 LightOption,
138 DarkOption,137 DarkOption,
@@ -568,8 +567,6 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
568 (ConnectionNever, Tr) => "hiç",567 (ConnectionNever, Tr) => "hiç",
569 (EmailLabel, En) => "EMAIL",568 (EmailLabel, En) => "EMAIL",
570 (EmailLabel, Tr) => "E-POSTA",569 (EmailLabel, Tr) => "E-POSTA",
571- (TimezoneLabel, En) => "TIMEZONE",
572- (TimezoneLabel, Tr) => "SAAT DİLİMİ",
573 (ThemeLabel, En) => "THEME",570 (ThemeLabel, En) => "THEME",
574 (ThemeLabel, Tr) => "TEMA",571 (ThemeLabel, Tr) => "TEMA",
575 (UiLabel, En) => "INTERFACE",572 (UiLabel, En) => "INTERFACE",
crates/iz-web/src/main.rsmodified+1 -0
@@ -437,6 +437,7 @@ async fn apply_member(
437 &member.name,437 &member.name,
438 member.admin,438 member.admin,
439 member.photo_version,439 member.photo_version,
440+ &member.timezone,
440 )441 )
441 .await442 .await
442 {443 {
crates/iz-web/src/server.rsmodified+0 -6
@@ -349,7 +349,6 @@ pub enum Refusal {
349 /// and days.349 /// and days.
350 BadPolicy,350 BadPolicy,
351 /// The timezone field was not one of the offsets the form offers.351 /// The timezone field was not one of the offsets the form offers.
352- BadZone,
353 /// The theme field was not one of the values the form offers.352 /// The theme field was not one of the values the form offers.
354 BadTheme,353 BadTheme,
355 /// The ui field was not one of the values the form offers.354 /// The ui field was not one of the values the form offers.
@@ -426,7 +425,6 @@ impl Refusal {
426 "A limit has to be at least 1 MB, and no wider than 500 MB per file.".to_string()425 "A limit has to be at least 1 MB, and no wider than 500 MB per file.".to_string()
427 }426 }
428 Refusal::BadPolicy => "A security number is out of range.".to_string(),427 Refusal::BadPolicy => "A security number is out of range.".to_string(),
429- Refusal::BadZone => "That is not a timezone.".to_string(),
430 Refusal::BadTheme => "That is not a theme.".to_string(),428 Refusal::BadTheme => "That is not a theme.".to_string(),
431 Refusal::BadUi => "That is not an interface.".to_string(),429 Refusal::BadUi => "That is not an interface.".to_string(),
432 Refusal::BadLanguage => "That is not a language.".to_string(),430 Refusal::BadLanguage => "That is not a language.".to_string(),
@@ -494,7 +492,6 @@ impl Refusal {
494 "Limit en az 1 MB, dosya başına en çok 500 MB olabilir.".to_string()492 "Limit en az 1 MB, dosya başına en çok 500 MB olabilir.".to_string()
495 }493 }
496 Refusal::BadPolicy => "Güvenlik sayısı aralığın dışında.".to_string(),494 Refusal::BadPolicy => "Güvenlik sayısı aralığın dışında.".to_string(),
497- Refusal::BadZone => "Bu bir saat dilimi değil.".to_string(),
498 Refusal::BadTheme => "Bu bir tema değil.".to_string(),495 Refusal::BadTheme => "Bu bir tema değil.".to_string(),
499 Refusal::BadUi => "Bu bir arayüz değil.".to_string(),496 Refusal::BadUi => "Bu bir arayüz değil.".to_string(),
500 Refusal::BadLanguage => "Bu bir dil değil.".to_string(),497 Refusal::BadLanguage => "Bu bir dil değil.".to_string(),
@@ -527,7 +524,6 @@ impl Refusal {
527 "empty-name" => Refusal::EmptyName,524 "empty-name" => Refusal::EmptyName,
528 "bad-limit" => Refusal::BadLimit,525 "bad-limit" => Refusal::BadLimit,
529 "bad-policy" => Refusal::BadPolicy,526 "bad-policy" => Refusal::BadPolicy,
530- "bad-zone" => Refusal::BadZone,
531 "bad-theme" => Refusal::BadTheme,527 "bad-theme" => Refusal::BadTheme,
532 "bad-ui" => Refusal::BadUi,528 "bad-ui" => Refusal::BadUi,
533 "bad-language" => Refusal::BadLanguage,529 "bad-language" => Refusal::BadLanguage,
@@ -575,7 +571,6 @@ impl Refusal {
575 Refusal::EmptyName => "empty-name",571 Refusal::EmptyName => "empty-name",
576 Refusal::BadLimit => "bad-limit",572 Refusal::BadLimit => "bad-limit",
577 Refusal::BadPolicy => "bad-policy",573 Refusal::BadPolicy => "bad-policy",
578- Refusal::BadZone => "bad-zone",
579 Refusal::BadTheme => "bad-theme",574 Refusal::BadTheme => "bad-theme",
580 Refusal::BadUi => "bad-ui",575 Refusal::BadUi => "bad-ui",
581 Refusal::BadLanguage => "bad-language",576 Refusal::BadLanguage => "bad-language",
@@ -927,7 +922,6 @@ mod refusal_message_tests {
927 Refusal::FileTypeNotAllowed,922 Refusal::FileTypeNotAllowed,
928 Refusal::BadDeadline,923 Refusal::BadDeadline,
929 Refusal::BadClock,924 Refusal::BadClock,
930- Refusal::BadZone,
931 Refusal::BadTheme,925 Refusal::BadTheme,
932 Refusal::BadLanguage,926 Refusal::BadLanguage,
933 Refusal::BadEmail,927 Refusal::BadEmail,
crates/iz-web/src/settings.rsmodified+1 -38
@@ -634,7 +634,6 @@ async fn send_test_mail(cx: &Cx) -> Result<(StatusCode, HeaderMap, Vec<u8>)> {
634 634
635 #[derive(serde::Deserialize)]635 #[derive(serde::Deserialize)]
636 struct SaveProfileForm {636 struct SaveProfileForm {
637- timezone: String,
638 theme: String,637 theme: String,
639 language: String,638 language: String,
640 ui: String,639 ui: String,
@@ -649,31 +648,6 @@ const UI_OPTIONS: [&str; 2] = ["instrument", "ledger"];
649 /// The values the language field offers.648 /// The values the language field offers.
650 const LANGUAGE_OPTIONS: [&str; 2] = ["en", "tr"];649 const LANGUAGE_OPTIONS: [&str; 2] = ["en", "tr"];
651 650
652-/// The offsets the timezone field offers, `"UTC-12:00"` through `"UTC+14:00"`.
653-///
654-/// Decision: `time` (already a dependency) has no tz-database, and this
655-/// workspace has no other crate that carries one — adding one just for a
656-/// display label is a new dependency for what "show logs in my timezone"
657-/// does not need. Fixed offsets satisfy it; `"UTC"` stands for +00:00.
658-fn zone_options() -> Vec<String> {
659- (-12..=14)
660- .map(|hour: i32| {
661- if hour == 0 {
662- "UTC".to_string()
663- } else {
664- format!(
665- "UTC{}{:02}:00",
666- if hour > 0 { "+" } else { "-" },
667- hour.abs()
668- )
669- }
670- })
671- .collect()
672-}
673-
674-/// Writes the person asking's display-only preferences. Nobody touches
675-/// anybody else here: the id comes from the session, never from the form.
676-/// Name and address are im's to vouch and are not written here at all.
677 #[route(POST "/api/save_profile")]651 #[route(POST "/api/save_profile")]
678 async fn save_profile(652 async fn save_profile(
679 cx: &Cx,653 cx: &Cx,
@@ -683,9 +657,6 @@ async fn save_profile(
683 Ok(user) => user,657 Ok(user) => user,
684 Err(refusal) => return Ok(saved_or_refused("save_profile", Some(refusal))),658 Err(refusal) => return Ok(saved_or_refused("save_profile", Some(refusal))),
685 };659 };
686- if !zone_options().contains(&input.timezone) {
687- return Ok(saved_or_refused("save_profile", Some(Refusal::BadZone)));
688- }
689 if !THEME_OPTIONS.contains(&input.theme.as_str()) {660 if !THEME_OPTIONS.contains(&input.theme.as_str()) {
690 return Ok(saved_or_refused("save_profile", Some(Refusal::BadTheme)));661 return Ok(saved_or_refused("save_profile", Some(Refusal::BadTheme)));
691 }662 }
@@ -699,7 +670,7 @@ async fn save_profile(
699 let refusal = match store670 let refusal = match store
700 .set_preferences(671 .set_preferences(
701 &user.id,672 &user.id,
702- &input.timezone,673+ &user.timezone,
703 &input.theme,674 &input.theme,
704 &input.language,675 &input.language,
705 &input.ui,676 &input.ui,
@@ -1326,14 +1297,6 @@ async fn settings_page(cx: &Cx) -> Result {
1326 <p class="panel-lede">(t(lang, Key::IdentityFromIm))</p>1297 <p class="panel-lede">(t(lang, Key::IdentityFromIm))</p>
1327 </div>1298 </div>
1328 <form method="post" action="/api/save_profile" class="panel-body">1299 <form method="post" action="/api/save_profile" class="panel-body">
1329- <label class="field">
1330- <span class="field-label">(t(lang, Key::TimezoneLabel))</span>
1331- <select class="field-input" name="timezone">
1332- for zone in zone_options() {
1333- <option value=(zone.clone()) selected=(zone == user.timezone)>(zone)</option>
1334- }
1335- </select>
1336- </label>
1337 <label class="field">1300 <label class="field">
1338 <span class="field-label">(t(lang, Key::ThemeLabel))</span>1301 <span class="field-label">(t(lang, Key::ThemeLabel))</span>
1339 <select class="field-input" name="theme">1302 <select class="field-input" name="theme">
crates/iz-web/tests/http.rsmodified+58 -96
@@ -4336,27 +4336,10 @@ async fn a_stamp_shifts_with_the_viewers_stored_timezone() {
4336 let utc = until_logs_contains(&app, &admin_cookie, "\"title\":\"Ship it\"").await;4336 let utc = until_logs_contains(&app, &admin_cookie, "\"title\":\"Ship it\"").await;
4337 let utc_at = moment_for(&utc, "Ship it");4337 let utc_at = moment_for(&utc, "Ship it");
4338 4338
4339- let saved = app4339+ app.store
4340- .post(4340+ .sync_member("im-ada", "ada@iz.sh", "Ada Lovelace", true, 0, "UTC+03:00")
4341- "/api/save_profile",4341+ .await
4342- Some(&admin_cookie),4342+ .unwrap();
4343- &[
4344- ("timezone", "UTC+03:00"),
4345- ("theme", "light"),
4346- ("language", "en"),
4347- ("ui", "instrument"),
4348- ],
4349- )
4350- .await;
4351- assert!(
4352- !saved
4353- .location
4354- .as_deref()
4355- .unwrap_or_default()
4356- .contains("refusal="),
4357- "{:?}",
4358- saved.location
4359- );
4360 4343
4361 let shifted = app4344 let shifted = app
4362 .post("/api/current_logs", Some(&admin_cookie), &[])4345 .post("/api/current_logs", Some(&admin_cookie), &[])
@@ -4396,27 +4379,10 @@ async fn a_task_modal_stamp_shifts_with_the_viewers_stored_timezone() {
4396 let html = String::from_utf8_lossy(&page.bytes);4379 let html = String::from_utf8_lossy(&page.bytes);
4397 let utc_at = activity_stamp_of(&html).to_string();4380 let utc_at = activity_stamp_of(&html).to_string();
4398 4381
4399- let saved = app4382+ app.store
4400- .post(4383+ .sync_member("im-ada", "ada@iz.sh", "Ada Lovelace", true, 0, "UTC+03:00")
4401- "/api/save_profile",4384+ .await
4402- Some(&admin_cookie),4385+ .unwrap();
4403- &[
4404- ("timezone", "UTC+03:00"),
4405- ("theme", "light"),
4406- ("language", "en"),
4407- ("ui", "instrument"),
4408- ],
4409- )
4410- .await;
4411- assert!(
4412- !saved
4413- .location
4414- .as_deref()
4415- .unwrap_or_default()
4416- .contains("refusal="),
4417- "{:?}",
4418- saved.location
4419- );
4420 4386
4421 let shifted_page = app4387 let shifted_page = app
4422 .get(&format!("/?task={task}&tab=activity"), Some(&admin_cookie))4388 .get(&format!("/?task={task}&tab=activity"), Some(&admin_cookie))
@@ -4433,27 +4399,38 @@ async fn a_task_modal_stamp_shifts_with_the_viewers_stored_timezone() {
4433 }4399 }
4434 4400
4435 #[tokio::test]4401 #[tokio::test]
4436-async fn an_unlisted_timezone_is_refused() {4402+async fn a_posted_timezone_is_ignored() {
4437 let app = App::open().await;4403 let app = App::open().await;
4438 let admin_cookie = admin(&app).await;4404 let admin_cookie = admin(&app).await;
4439 4405
4406+ // im owns the timezone now: a posted one — even an unlisted one — is
4407+ // not read, let alone refused or saved. The row keeps the value the
4408+ // directory last mirrored while the fields iz owns still save.
4440 let answer = app4409 let answer = app
4441 .post(4410 .post(
4442 "/api/save_profile",4411 "/api/save_profile",
4443 Some(&admin_cookie),4412 Some(&admin_cookie),
4444 &[4413 &[
4445 ("timezone", "Mars/Olympus_Mons"),4414 ("timezone", "Mars/Olympus_Mons"),
4446- ("theme", "light"),4415+ ("theme", "dark"),
4447 ("language", "en"),4416 ("language", "en"),
4448 ("ui", "instrument"),4417 ("ui", "instrument"),
4449 ],4418 ],
4450 )4419 )
4451 .await;4420 .await;
4452- let location = answer.location.as_deref().unwrap_or_default();
4453 assert!(4421 assert!(
4454- location.contains("refusal=bad-zone&on=save_profile"),4422+ !answer
4455- "{location}"4423+ .location
4424+ .as_deref()
4425+ .unwrap_or_default()
4426+ .contains("refusal="),
4427+ "{:?}",
4428+ answer.location
4456 );4429 );
4430+ let admin_id = user_id(&app, "ada@iz.sh").await;
4431+ let row = app.store.user(&admin_id).await.unwrap().unwrap();
4432+ assert_eq!(row.timezone, "UTC");
4433+ assert_eq!(row.theme, "dark");
4457 }4434 }
4458 4435
4459 #[tokio::test]4436 #[tokio::test]
@@ -4971,7 +4948,7 @@ async fn a_synced_member_is_listed_and_assignable_before_their_first_sign_in() {
4971 .unwrap();4948 .unwrap();
4972 4949
4973 let sync = app4950 let sync = app
4974- .store.sync_member("sub-mert", "mert@iz.sh", "Mert", false, 0)4951+ .store.sync_member("sub-mert", "mert@iz.sh", "Mert", false, 0, "UTC+03:00")
4975 .await4952 .await
4976 .unwrap();4953 .unwrap();
4977 assert_eq!(sync, iz_core::store::MemberSync::Inserted);4954 assert_eq!(sync, iz_core::store::MemberSync::Inserted);
@@ -5217,6 +5194,26 @@ async fn a_members_avatar_proxies_the_im_photo() {
5217 assert!(cached.bytes.is_empty());5194 assert!(cached.bytes.is_empty());
5218 }5195 }
5219 5196
5197+/// The profile section renders no timezone editor: the clock is im's now,
5198+/// so the form iz serves carries only the fields iz owns.
5199+#[tokio::test]
5200+async fn the_profile_section_has_no_timezone_editor() {
5201+ let app = App::open().await;
5202+ let admin = admin(&app).await;
5203+
5204+ let page = app.get("/settings", Some(&admin)).await;
5205+ assert_eq!(page.status.as_u16(), 200);
5206+ let html = String::from_utf8(page.bytes).unwrap();
5207+ assert!(
5208+ !html.contains("name=\"timezone\""),
5209+ "a timezone select is still on the profile: {html}"
5210+ );
5211+ assert!(
5212+ !html.contains("TIMEZONE"),
5213+ "a timezone label is still on the profile: {html}"
5214+ );
5215+}
5216+
5220 /// The stamp the row carries pins the face: `?v=` agreeing with the row is5217 /// The stamp the row carries pins the face: `?v=` agreeing with the row is
5221 /// cacheable for a year because the URL itself changes when the face does,5218 /// cacheable for a year because the URL itself changes when the face does,
5222 /// any other spelling revalidates, and a sync that hears of a new photo5219 /// any other spelling revalidates, and a sync that hears of a new photo
@@ -5229,8 +5226,7 @@ async fn a_matching_version_stamp_is_immutable_and_a_new_one_moves_it() {
5229 let member_id = user_id(&app, "emre@iz.sh").await;5226 let member_id = user_id(&app, "emre@iz.sh").await;
5230 // The directory pass finds the row by its sub — the same subject the5227 // The directory pass finds the row by its sub — the same subject the
5231 // sign-in provisions — and reports the face's third revision.5228 // sign-in provisions — and reports the face's third revision.
5232- app.store5229+ app.store.sync_member("im-emre@iz.sh", "emre@iz.sh", "Emre", false, 3, "UTC+03:00")
5233- .sync_member("im-emre@iz.sh", "emre@iz.sh", "Emre", false, 3)
5234 .await5230 .await
5235 .unwrap();5231 .unwrap();
5236 app.fake.set_photo("im-emre@iz.sh", PNG.to_vec(), "image/png");5232 app.fake.set_photo("im-emre@iz.sh", PNG.to_vec(), "image/png");
@@ -5255,8 +5251,7 @@ async fn a_matching_version_stamp_is_immutable_and_a_new_one_moves_it() {
5255 5251
5256 // im's count moves; the next sync (the stream's event, or the beat)5252 // im's count moves; the next sync (the stream's event, or the beat)
5257 // carries it onto the row, and the old stamp stops being true.5253 // carries it onto the row, and the old stamp stops being true.
5258- app.store5254+ app.store.sync_member("im-emre@iz.sh", "emre@iz.sh", "Emre", false, 4, "UTC+03:00")
5259- .sync_member("sub-emre", "emre@iz.sh", "Emre", false, 4)
5260 .await5255 .await
5261 .unwrap();5256 .unwrap();
5262 let moved = app5257 let moved = app
@@ -8313,29 +8308,13 @@ async fn a_clock_saved_on_a_task_renders_in_the_viewers_stored_timezone() {
8313 );8308 );
8314 assert!(html.contains(">Sep 02 11:00<"), "{html}");8309 assert!(html.contains(">Sep 02 11:00<"), "{html}");
8315 8310
8316- // The same instant, read back by a viewer who stored UTC+03:00: the field8311+ // The same instant, read back by a viewer whose row mirrors UTC+03:00
8317- // and its label both shift, the stored value does not.8312+ // from im: the field and its label both shift, the stored value does
8318- let saved = app8313+ // not. The mirror is the only path a timezone change still takes.
8319- .post(8314+ app.store
8320- "/api/save_profile",8315+ .sync_member("im-ada", "ada@iz.sh", "Ada Lovelace", true, 0, "UTC+03:00")
8321- Some(&admin_cookie),8316+ .await
8322- &[8317+ .unwrap();
8323- ("timezone", "UTC+03:00"),
8324- ("theme", "light"),
8325- ("language", "en"),
8326- ("ui", "instrument"),
8327- ],
8328- )
8329- .await;
8330- assert!(
8331- !saved
8332- .location
8333- .as_deref()
8334- .unwrap_or_default()
8335- .contains("refusal="),
8336- "{:?}",
8337- saved.location
8338- );
8339 8318
8340 let shifted = app8319 let shifted = app
8341 .get(&format!("/?task={task}"), Some(&admin_cookie))8320 .get(&format!("/?task={task}"), Some(&admin_cookie))
@@ -8679,27 +8658,10 @@ async fn a_card_wears_the_clock_chip_in_the_viewers_zone_instead_of_the_deadline
8679 8658
8680 // The viewer reads in UTC+03:00, so the typed 14:00 is 11:00 stored and8659 // The viewer reads in UTC+03:00, so the typed 14:00 is 11:00 stored and
8681 // 14:00 on the card again — the chip goes through the same zone both ways.8660 // 14:00 on the card again — the chip goes through the same zone both ways.
8682- let saved = app8661+ app.store
8683- .post(8662+ .sync_member("im-ada", "ada@iz.sh", "Ada Lovelace", true, 0, "UTC+03:00")
8684- "/api/save_profile",8663+ .await
8685- Some(&admin_cookie),8664+ .unwrap();
8686- &[
8687- ("timezone", "UTC+03:00"),
8688- ("theme", "light"),
8689- ("language", "en"),
8690- ("ui", "instrument"),
8691- ],
8692- )
8693- .await;
8694- assert!(
8695- !saved
8696- .location
8697- .as_deref()
8698- .unwrap_or_default()
8699- .contains("refusal="),
8700- "{:?}",
8701- saved.location
8702- );
8703 8665
8704 let column = first_column(&app).await;8666 let column = first_column(&app).await;
8705 let answer = app8667 let answer = app