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 commitc9a65a3d138de84b498cd165e99d965561458b8aParent: e11a59810 changed files +137 -166
- Cargo.lock +1 -1
- Cargo.toml +1 -1
- crates/iz-core/src/store/mod.rs +4 -2
- crates/iz-core/src/store/turso_store.rs +11 -5
- crates/iz-core/tests/store.rs +60 -14
- crates/iz-web/src/i18n.rs +0 -3
- crates/iz-web/src/main.rs +1 -0
- crates/iz-web/src/server.rs +0 -6
- crates/iz-web/src/settings.rs +1 -38
- crates/iz-web/tests/http.rs +58 -96
Cargo.lockmodified+1 -1
| @@ -1771,7 +1771,7 @@ dependencies = [ | ||
| 1771 | 1771 | [[package]] |
| 1772 | 1772 | name = "im-client" |
| 1773 | 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 | 1775 | dependencies = [ |
| 1776 | 1776 | "base64 0.22.1", |
| 1777 | 1777 | "chacha20poly1305", |
Cargo.tomlmodified+1 -1
| @@ -11,7 +11,7 @@ repository = "https://github.com/DizeyLab/iz" | ||
| 11 | 11 | [workspace.dependencies] |
| 12 | 12 | iz-core = { path = "crates/iz-core", default-features = false } |
| 13 | 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 | 15 | serde = { version = "1.0.229", features = ["derive"] } |
| 16 | 16 | serde_json = "1.0.145" |
| 17 | 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 | 789 | /// gets a row born linked — assignable, mailable and avatar-able before |
| 790 | 790 | /// their first visit. An unclaimed row with a matching address is |
| 791 | 791 | /// claimed (sub stamped, id/role/preferences/history kept), a known row |
| 792 | - /// follows the provider's address, name, admin flag and photo version, | |
| 793 | - /// and a row that already agrees is left alone. Unlike | |
| 792 | + /// follows the provider's address, name, admin flag, photo version and | |
| 793 | + /// timezone — the provider owns the clock now — and a row that already | |
| 794 | + /// agrees is left alone. Unlike | |
| 794 | 795 | /// [`Store::provision_user`] this is not a sign-in: `last_signed_in_at` |
| 795 | 796 | /// is never stamped, and an empty database grows no workspace (the first |
| 796 | 797 | /// sign-in builds it; the next beat mirrors everyone). The admin flag |
| @@ -803,6 +804,7 @@ pub trait Store: BoardReads + DetailReads + 'static { | ||
| 803 | 804 | display_name: &str, |
| 804 | 805 | im_admin: bool, |
| 805 | 806 | photo_version: u64, |
| 807 | + timezone: &str, | |
| 806 | 808 | ) -> Result<MemberSync>; |
| 807 | 809 | |
| 808 | 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 | 1465 | display_name: &str, |
| 1466 | 1466 | im_admin: bool, |
| 1467 | 1467 | photo_version: u64, |
| 1468 | + timezone: &str, | |
| 1468 | 1469 | ) -> Result<MemberSync> { |
| 1469 | 1470 | let email = fold_email(email); |
| 1470 | 1471 | // IMMEDIATE like provision_user: a beat racing a first sign-in over |
| @@ -1491,17 +1492,19 @@ impl Store for TursoStore { | ||
| 1491 | 1492 | && user.display_name == display_name |
| 1492 | 1493 | && role == user.role |
| 1493 | 1494 | && user.photo_version == photo_version |
| 1495 | + && user.timezone == timezone | |
| 1494 | 1496 | { |
| 1495 | 1497 | Some((user.id, MemberSync::Untouched)) |
| 1496 | 1498 | } else { |
| 1497 | 1499 | tx.execute( |
| 1498 | 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 | 1502 | params![ |
| 1501 | 1503 | email.clone(), |
| 1502 | 1504 | display_name, |
| 1503 | 1505 | role.as_str(), |
| 1504 | 1506 | photo_version as i64, |
| 1507 | + timezone, | |
| 1505 | 1508 | user.id.clone() |
| 1506 | 1509 | ], |
| 1507 | 1510 | ) |
| @@ -1525,13 +1528,14 @@ impl Store for TursoStore { | ||
| 1525 | 1528 | let role = synced_role(user.role, im_admin); |
| 1526 | 1529 | tx.execute( |
| 1527 | 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 | 1532 | params![ |
| 1530 | 1533 | sub, |
| 1531 | 1534 | email.clone(), |
| 1532 | 1535 | display_name, |
| 1533 | 1536 | role.as_str(), |
| 1534 | 1537 | photo_version as i64, |
| 1538 | + timezone, | |
| 1535 | 1539 | user.id.clone() |
| 1536 | 1540 | ], |
| 1537 | 1541 | ) |
| @@ -1561,8 +1565,9 @@ impl Store for TursoStore { | ||
| 1561 | 1565 | let role = if im_admin { Role::Admin } else { Role::Member }; |
| 1562 | 1566 | tx.execute( |
| 1563 | 1567 | "INSERT INTO user (id, workspace_id, oidc_sub, email, display_name, \ |
| 1564 | - role, disabled, created_at, last_signed_in_at, photo_version) \ | |
| 1565 | - VALUES (?1, ?2, ?3, ?4, ?5, ?6, 0, ?7, NULL, ?8)", | |
| 1568 | + role, disabled, created_at, last_signed_in_at, photo_version, \ | |
| 1569 | + timezone) \ | |
| 1570 | + VALUES (?1, ?2, ?3, ?4, ?5, ?6, 0, ?7, NULL, ?8, ?9)", | |
| 1566 | 1571 | params![ |
| 1567 | 1572 | id.clone(), |
| 1568 | 1573 | workspace_id, |
| @@ -1571,7 +1576,8 @@ impl Store for TursoStore { | ||
| 1571 | 1576 | display_name, |
| 1572 | 1577 | role.as_str(), |
| 1573 | 1578 | now.clone(), |
| 1574 | - photo_version as i64 | |
| 1579 | + photo_version as i64, | |
| 1580 | + timezone | |
| 1575 | 1581 | ], |
| 1576 | 1582 | ) |
| 1577 | 1583 | .await |
crates/iz-core/tests/store.rsmodified+60 -14
| @@ -8407,7 +8407,7 @@ async fn set_user_disabled_round_trips() { | ||
| 8407 | 8407 | async fn a_synced_member_is_born_linked_and_never_signed_in() { |
| 8408 | 8408 | let (scratch, workspace, _admin) = workspace_with_admin().await; |
| 8409 | 8409 | 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 | 8411 | .await |
| 8412 | 8412 | .unwrap(); |
| 8413 | 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 | 8422 | assert!(row.last_signed_in_at.is_none()); |
| 8423 | 8423 | // An im admin the workspace has never met is Admin from the first beat. |
| 8424 | 8424 | 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 | 8426 | .await |
| 8427 | 8427 | .unwrap(); |
| 8428 | 8428 | let boss = scratch |
| @@ -8443,7 +8443,7 @@ async fn a_sync_claims_an_unclaimed_row_without_touching_its_sign_in_fact() { | ||
| 8443 | 8443 | .await |
| 8444 | 8444 | .unwrap(); |
| 8445 | 8445 | 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 | 8447 | .await |
| 8448 | 8448 | .unwrap(); |
| 8449 | 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 | 8461 | #[tokio::test] |
| 8462 | 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 | 8464 | let before = scratch.store.user(&admin_id).await.unwrap().unwrap(); |
| 8465 | 8465 | let seen = before.last_signed_in_at.clone(); |
| 8466 | 8466 | 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 | 8468 | .await |
| 8469 | 8469 | .unwrap(); |
| 8470 | 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 | 8473 | assert_eq!(after.last_signed_in_at, seen); |
| 8474 | 8474 | // Losing the flag in the directory drops an Admin to Member. |
| 8475 | 8475 | 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 | 8477 | .await |
| 8478 | 8478 | .unwrap(); |
| 8479 | 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 | 8485 | let (scratch, _, _) = workspace_with_admin().await; |
| 8486 | 8486 | let mut rx = scratch.store.subscribe(); |
| 8487 | 8487 | 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 | 8489 | .await |
| 8490 | 8490 | .unwrap(); |
| 8491 | 8491 | assert_eq!(sync, iz_core::store::MemberSync::Untouched); |
| @@ -8496,7 +8496,7 @@ async fn an_agreeing_sync_is_untouched_and_silent() { | ||
| 8496 | 8496 | async fn a_sync_without_a_workspace_skips_and_writes_nothing() { |
| 8497 | 8497 | let scratch = Scratch::open().await; |
| 8498 | 8498 | 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 | 8500 | .await |
| 8501 | 8501 | .unwrap(); |
| 8502 | 8502 | assert_eq!(sync, iz_core::store::MemberSync::Skipped); |
| @@ -8512,8 +8512,7 @@ async fn a_photo_version_bump_refreshes_and_announces() { | ||
| 8512 | 8512 | let (scratch, workspace, _admin) = workspace_with_admin().await; |
| 8513 | 8513 | let mut rx = scratch.store.subscribe(); |
| 8514 | 8514 | let sync = scratch |
| 8515 | - .store | |
| 8516 | - .sync_member("sub-mert", "mert@iz.sh", "Mert", false, 2) | |
| 8515 | + .store.sync_member("sub-mert", "mert@iz.sh", "Mert", false, 2, "UTC+03:00") | |
| 8517 | 8516 | .await |
| 8518 | 8517 | .unwrap(); |
| 8519 | 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 | 8528 | // The same version again: the row agrees, and silence is the answer. |
| 8530 | 8529 | let again = scratch |
| 8531 | - .store | |
| 8532 | - .sync_member("sub-mert", "mert@iz.sh", "Mert", false, 2) | |
| 8530 | + .store.sync_member("sub-mert", "mert@iz.sh", "Mert", false, 2, "UTC+03:00") | |
| 8533 | 8531 | .await |
| 8534 | 8532 | .unwrap(); |
| 8535 | 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 | 8536 | // im counted another upload: the stamp moves and the move is news. |
| 8539 | 8537 | let bumped = scratch |
| 8540 | - .store | |
| 8541 | - .sync_member("sub-mert", "mert@iz.sh", "Mert", false, 3) | |
| 8538 | + .store.sync_member("sub-mert", "mert@iz.sh", "Mert", false, 3, "UTC+03:00") | |
| 8542 | 8539 | .await |
| 8543 | 8540 | .unwrap(); |
| 8544 | 8541 | assert_eq!(bumped, iz_core::store::MemberSync::Refreshed); |
| @@ -8552,6 +8549,55 @@ async fn a_photo_version_bump_refreshes_and_announces() { | ||
| 8552 | 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 | 8601 | /// The app-level setting drawer: a key never set reads as absent, one set |
| 8556 | 8602 | /// reads back, and setting it again replaces rather than duplicates — the |
| 8557 | 8603 | /// 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 | 132 | ConnectionLastPass, |
| 133 | 133 | ConnectionNever, |
| 134 | 134 | EmailLabel, |
| 135 | - TimezoneLabel, | |
| 136 | 135 | ThemeLabel, |
| 137 | 136 | LightOption, |
| 138 | 137 | DarkOption, |
| @@ -568,8 +567,6 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | ||
| 568 | 567 | (ConnectionNever, Tr) => "hiç", |
| 569 | 568 | (EmailLabel, En) => "EMAIL", |
| 570 | 569 | (EmailLabel, Tr) => "E-POSTA", |
| 571 | - (TimezoneLabel, En) => "TIMEZONE", | |
| 572 | - (TimezoneLabel, Tr) => "SAAT DİLİMİ", | |
| 573 | 570 | (ThemeLabel, En) => "THEME", |
| 574 | 571 | (ThemeLabel, Tr) => "TEMA", |
| 575 | 572 | (UiLabel, En) => "INTERFACE", |
crates/iz-web/src/main.rsmodified+1 -0
| @@ -437,6 +437,7 @@ async fn apply_member( | ||
| 437 | 437 | &member.name, |
| 438 | 438 | member.admin, |
| 439 | 439 | member.photo_version, |
| 440 | + &member.timezone, | |
| 440 | 441 | ) |
| 441 | 442 | .await |
| 442 | 443 | { |
crates/iz-web/src/server.rsmodified+0 -6
| @@ -349,7 +349,6 @@ pub enum Refusal { | ||
| 349 | 349 | /// and days. |
| 350 | 350 | BadPolicy, |
| 351 | 351 | /// The timezone field was not one of the offsets the form offers. |
| 352 | - BadZone, | |
| 353 | 352 | /// The theme field was not one of the values the form offers. |
| 354 | 353 | BadTheme, |
| 355 | 354 | /// The ui field was not one of the values the form offers. |
| @@ -426,7 +425,6 @@ impl Refusal { | ||
| 426 | 425 | "A limit has to be at least 1 MB, and no wider than 500 MB per file.".to_string() |
| 427 | 426 | } |
| 428 | 427 | Refusal::BadPolicy => "A security number is out of range.".to_string(), |
| 429 | - Refusal::BadZone => "That is not a timezone.".to_string(), | |
| 430 | 428 | Refusal::BadTheme => "That is not a theme.".to_string(), |
| 431 | 429 | Refusal::BadUi => "That is not an interface.".to_string(), |
| 432 | 430 | Refusal::BadLanguage => "That is not a language.".to_string(), |
| @@ -494,7 +492,6 @@ impl Refusal { | ||
| 494 | 492 | "Limit en az 1 MB, dosya başına en çok 500 MB olabilir.".to_string() |
| 495 | 493 | } |
| 496 | 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 | 495 | Refusal::BadTheme => "Bu bir tema değil.".to_string(), |
| 499 | 496 | Refusal::BadUi => "Bu bir arayüz değil.".to_string(), |
| 500 | 497 | Refusal::BadLanguage => "Bu bir dil değil.".to_string(), |
| @@ -527,7 +524,6 @@ impl Refusal { | ||
| 527 | 524 | "empty-name" => Refusal::EmptyName, |
| 528 | 525 | "bad-limit" => Refusal::BadLimit, |
| 529 | 526 | "bad-policy" => Refusal::BadPolicy, |
| 530 | - "bad-zone" => Refusal::BadZone, | |
| 531 | 527 | "bad-theme" => Refusal::BadTheme, |
| 532 | 528 | "bad-ui" => Refusal::BadUi, |
| 533 | 529 | "bad-language" => Refusal::BadLanguage, |
| @@ -575,7 +571,6 @@ impl Refusal { | ||
| 575 | 571 | Refusal::EmptyName => "empty-name", |
| 576 | 572 | Refusal::BadLimit => "bad-limit", |
| 577 | 573 | Refusal::BadPolicy => "bad-policy", |
| 578 | - Refusal::BadZone => "bad-zone", | |
| 579 | 574 | Refusal::BadTheme => "bad-theme", |
| 580 | 575 | Refusal::BadUi => "bad-ui", |
| 581 | 576 | Refusal::BadLanguage => "bad-language", |
| @@ -927,7 +922,6 @@ mod refusal_message_tests { | ||
| 927 | 922 | Refusal::FileTypeNotAllowed, |
| 928 | 923 | Refusal::BadDeadline, |
| 929 | 924 | Refusal::BadClock, |
| 930 | - Refusal::BadZone, | |
| 931 | 925 | Refusal::BadTheme, |
| 932 | 926 | Refusal::BadLanguage, |
| 933 | 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 | 635 | #[derive(serde::Deserialize)] |
| 636 | 636 | struct SaveProfileForm { |
| 637 | - timezone: String, | |
| 638 | 637 | theme: String, |
| 639 | 638 | language: String, |
| 640 | 639 | ui: String, |
| @@ -649,31 +648,6 @@ const UI_OPTIONS: [&str; 2] = ["instrument", "ledger"]; | ||
| 649 | 648 | /// The values the language field offers. |
| 650 | 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 | 651 | #[route(POST "/api/save_profile")] |
| 678 | 652 | async fn save_profile( |
| 679 | 653 | cx: &Cx, |
| @@ -683,9 +657,6 @@ async fn save_profile( | ||
| 683 | 657 | Ok(user) => user, |
| 684 | 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 | 660 | if !THEME_OPTIONS.contains(&input.theme.as_str()) { |
| 690 | 661 | return Ok(saved_or_refused("save_profile", Some(Refusal::BadTheme))); |
| 691 | 662 | } |
| @@ -699,7 +670,7 @@ async fn save_profile( | ||
| 699 | 670 | let refusal = match store |
| 700 | 671 | .set_preferences( |
| 701 | 672 | &user.id, |
| 702 | - &input.timezone, | |
| 673 | + &user.timezone, | |
| 703 | 674 | &input.theme, |
| 704 | 675 | &input.language, |
| 705 | 676 | &input.ui, |
| @@ -1326,14 +1297,6 @@ async fn settings_page(cx: &Cx) -> Result { | ||
| 1326 | 1297 | <p class="panel-lede">(t(lang, Key::IdentityFromIm))</p> |
| 1327 | 1298 | </div> |
| 1328 | 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 | 1300 | <label class="field"> |
| 1338 | 1301 | <span class="field-label">(t(lang, Key::ThemeLabel))</span> |
| 1339 | 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 | 4336 | let utc = until_logs_contains(&app, &admin_cookie, "\"title\":\"Ship it\"").await; |
| 4337 | 4337 | let utc_at = moment_for(&utc, "Ship it"); |
| 4338 | 4338 | |
| 4339 | - let saved = app | |
| 4340 | - .post( | |
| 4341 | - "/api/save_profile", | |
| 4342 | - Some(&admin_cookie), | |
| 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 | - ); | |
| 4339 | + app.store | |
| 4340 | + .sync_member("im-ada", "ada@iz.sh", "Ada Lovelace", true, 0, "UTC+03:00") | |
| 4341 | + .await | |
| 4342 | + .unwrap(); | |
| 4360 | 4343 | |
| 4361 | 4344 | let shifted = app |
| 4362 | 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 | 4379 | let html = String::from_utf8_lossy(&page.bytes); |
| 4397 | 4380 | let utc_at = activity_stamp_of(&html).to_string(); |
| 4398 | 4381 | |
| 4399 | - let saved = app | |
| 4400 | - .post( | |
| 4401 | - "/api/save_profile", | |
| 4402 | - Some(&admin_cookie), | |
| 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 | - ); | |
| 4382 | + app.store | |
| 4383 | + .sync_member("im-ada", "ada@iz.sh", "Ada Lovelace", true, 0, "UTC+03:00") | |
| 4384 | + .await | |
| 4385 | + .unwrap(); | |
| 4420 | 4386 | |
| 4421 | 4387 | let shifted_page = app |
| 4422 | 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 | 4401 | #[tokio::test] |
| 4436 | -async fn an_unlisted_timezone_is_refused() { | |
| 4402 | +async fn a_posted_timezone_is_ignored() { | |
| 4437 | 4403 | let app = App::open().await; |
| 4438 | 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 | 4409 | let answer = app |
| 4441 | 4410 | .post( |
| 4442 | 4411 | "/api/save_profile", |
| 4443 | 4412 | Some(&admin_cookie), |
| 4444 | 4413 | &[ |
| 4445 | 4414 | ("timezone", "Mars/Olympus_Mons"), |
| 4446 | - ("theme", "light"), | |
| 4415 | + ("theme", "dark"), | |
| 4447 | 4416 | ("language", "en"), |
| 4448 | 4417 | ("ui", "instrument"), |
| 4449 | 4418 | ], |
| 4450 | 4419 | ) |
| 4451 | 4420 | .await; |
| 4452 | - let location = answer.location.as_deref().unwrap_or_default(); | |
| 4453 | 4421 | assert!( |
| 4454 | - location.contains("refusal=bad-zone&on=save_profile"), | |
| 4455 | - "{location}" | |
| 4422 | + !answer | |
| 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 | 4436 | #[tokio::test] |
| @@ -4971,7 +4948,7 @@ async fn a_synced_member_is_listed_and_assignable_before_their_first_sign_in() { | ||
| 4971 | 4948 | .unwrap(); |
| 4972 | 4949 | |
| 4973 | 4950 | 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 | 4952 | .await |
| 4976 | 4953 | .unwrap(); |
| 4977 | 4954 | assert_eq!(sync, iz_core::store::MemberSync::Inserted); |
| @@ -5217,6 +5194,26 @@ async fn a_members_avatar_proxies_the_im_photo() { | ||
| 5217 | 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 | 5217 | /// The stamp the row carries pins the face: `?v=` agreeing with the row is |
| 5221 | 5218 | /// cacheable for a year because the URL itself changes when the face does, |
| 5222 | 5219 | /// 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 | 5226 | let member_id = user_id(&app, "emre@iz.sh").await; |
| 5230 | 5227 | // The directory pass finds the row by its sub — the same subject the |
| 5231 | 5228 | // sign-in provisions — and reports the face's third revision. |
| 5232 | - app.store | |
| 5233 | - .sync_member("im-emre@iz.sh", "emre@iz.sh", "Emre", false, 3) | |
| 5229 | + app.store.sync_member("im-emre@iz.sh", "emre@iz.sh", "Emre", false, 3, "UTC+03:00") | |
| 5234 | 5230 | .await |
| 5235 | 5231 | .unwrap(); |
| 5236 | 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 | 5252 | // im's count moves; the next sync (the stream's event, or the beat) |
| 5257 | 5253 | // carries it onto the row, and the old stamp stops being true. |
| 5258 | - app.store | |
| 5259 | - .sync_member("sub-emre", "emre@iz.sh", "Emre", false, 4) | |
| 5254 | + app.store.sync_member("im-emre@iz.sh", "emre@iz.sh", "Emre", false, 4, "UTC+03:00") | |
| 5260 | 5255 | .await |
| 5261 | 5256 | .unwrap(); |
| 5262 | 5257 | let moved = app |
| @@ -8313,29 +8308,13 @@ async fn a_clock_saved_on_a_task_renders_in_the_viewers_stored_timezone() { | ||
| 8313 | 8308 | ); |
| 8314 | 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 field | |
| 8317 | - // and its label both shift, the stored value does not. | |
| 8318 | - let saved = app | |
| 8319 | - .post( | |
| 8320 | - "/api/save_profile", | |
| 8321 | - Some(&admin_cookie), | |
| 8322 | - &[ | |
| 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 | - ); | |
| 8311 | + // The same instant, read back by a viewer whose row mirrors UTC+03:00 | |
| 8312 | + // from im: the field and its label both shift, the stored value does | |
| 8313 | + // not. The mirror is the only path a timezone change still takes. | |
| 8314 | + app.store | |
| 8315 | + .sync_member("im-ada", "ada@iz.sh", "Ada Lovelace", true, 0, "UTC+03:00") | |
| 8316 | + .await | |
| 8317 | + .unwrap(); | |
| 8339 | 8318 | |
| 8340 | 8319 | let shifted = app |
| 8341 | 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 | 8659 | // The viewer reads in UTC+03:00, so the typed 14:00 is 11:00 stored and |
| 8681 | 8660 | // 14:00 on the card again — the chip goes through the same zone both ways. |
| 8682 | - let saved = app | |
| 8683 | - .post( | |
| 8684 | - "/api/save_profile", | |
| 8685 | - Some(&admin_cookie), | |
| 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 | - ); | |
| 8661 | + app.store | |
| 8662 | + .sync_member("im-ada", "ada@iz.sh", "Ada Lovelace", true, 0, "UTC+03:00") | |
| 8663 | + .await | |
| 8664 | + .unwrap(); | |
| 8703 | 8665 | |
| 8704 | 8666 | let column = first_column(&app).await; |
| 8705 | 8667 | let answer = app |