From 1788d7f4a9aff5ff08093febae5bd86eb2e337a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?=
Date: Wed, 28 Oct 2026 15:57:29 +0300
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20board:=20Manual=20sort=20by=20defau?=
=?UTF-8?q?lt=20with=20in-column=20reorder;=20admins=20restore=20recently?=
=?UTF-8?q?=20deleted=20tasks;=20im=20admins'=20role=20is=20fixed?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 4 +-
.../0007_activity_restore_kinds.sql | 26 ++
crates/iz-core/src/authz.rs | 28 +-
crates/iz-core/src/store/members.rs | 22 +-
crates/iz-core/src/store/migrate.rs | 4 +
crates/iz-core/src/store/mod.rs | 2 +-
crates/iz-core/src/store/outbox.rs | 7 +-
crates/iz-core/src/store/reminders.rs | 4 +-
crates/iz-core/src/store/rules_engine.rs | 2 +-
crates/iz-core/src/store/sessions.rs | 7 +-
crates/iz-core/src/store/tasks.rs | 349 +++++++++++++++++-
crates/iz-core/src/time.rs | 7 +
crates/iz-web/assets/board.js | 44 ++-
crates/iz-web/src/i18n/admin.rs | 54 +++
crates/iz-web/src/i18n/board.rs | 14 +-
crates/iz-web/src/i18n/task.rs | 10 +
crates/iz-web/src/pages/admin.rs | 1 +
crates/iz-web/src/pages/board.rs | 21 +-
crates/iz-web/src/pages/files.rs | 2 +-
crates/iz-web/src/pages/people.rs | 8 +-
crates/iz-web/src/pages/photo.rs | 2 +-
crates/iz-web/src/pages/settings.rs | 73 +++-
crates/iz-web/src/pages/sign_in.rs | 2 +-
crates/iz-web/src/pages/tasks.rs | 9 +-
crates/iz-web/src/views/admin.rs | 56 +++
crates/iz-web/src/views/board.rs | 5 +
crates/iz-web/src/views/structure.rs | 4 +
docs/architecture.md | 36 +-
28 files changed, 726 insertions(+), 77 deletions(-)
create mode 100644 crates/iz-core/migrations/0007_activity_restore_kinds.sql
diff --git a/README.md b/README.md
index b06c629..19f1a69 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,9 @@
iz is the family task board. It has columns, cards (with one level of subtasks, dependencies and
assignees), projects (tags), deadlines with meeting times and reminders, comments, attachments with
in-page viewers (images, media, PDF, spreadsheets, slides), an activity trail, and admin-defined mail
-rules with a durable outbox. Sign-in goes through the family's `im` identity provider.
+rules with a durable outbox. Sign-in goes through the family's `im` identity provider. Cards keep a manual
+order (the default sort), an administrator can restore tasks deleted in the last 30 days, and an `im`
+administrator is an administrator in iz whatever role is stored here.
Design notes are in `docs/architecture.md`. The HTTP contracts with `im` and `in` are in
`docs/contracts.md`, and the code conventions are in `docs/conventions.md`.
diff --git a/crates/iz-core/migrations/0007_activity_restore_kinds.sql b/crates/iz-core/migrations/0007_activity_restore_kinds.sql
new file mode 100644
index 0000000..087ba60
--- /dev/null
+++ b/crates/iz-core/migrations/0007_activity_restore_kinds.sql
@@ -0,0 +1,26 @@
+-- 0007: the activity trail gains two kinds. 'task_reordered' is a card placed at a new spot in its column
+-- under the Manual sort; 'task_restored' is a deleted task brought back by an administrator. SQLite cannot
+-- alter a CHECK, so the table is rebuilt. Rows of 0001 carry over unchanged; the indexes are recreated.
+CREATE TABLE activity_by_kind (
+ id TEXT PRIMARY KEY,
+ task_id TEXT REFERENCES tasks(id) ON DELETE CASCADE,
+ actor TEXT REFERENCES members(sub) ON DELETE SET NULL,
+ subject TEXT REFERENCES members(sub) ON DELETE SET NULL,
+ kind TEXT NOT NULL CHECK (kind IN (
+ 'task_created', 'task_edited', 'task_moved', 'task_deleted',
+ 'assigned', 'unassigned', 'tag_changed', 'parent_changed',
+ 'link_added', 'link_removed', 'unblocked',
+ 'deadline_set', 'deadline_cleared', 'clock_set', 'clock_cleared',
+ 'watch_changed', 'comment_added', 'comment_edited', 'comment_deleted',
+ 'file_added', 'file_deleted', 'reminded', 'account_changed',
+ 'task_reordered', 'task_restored'
+ )),
+ detail TEXT NOT NULL DEFAULT '{}' CHECK (json_valid(detail)),
+ at TEXT NOT NULL
+);
+INSERT INTO activity_by_kind (id, task_id, actor, subject, kind, detail, at)
+ SELECT id, task_id, actor, subject, kind, detail, at FROM activity;
+DROP TABLE activity;
+ALTER TABLE activity_by_kind RENAME TO activity;
+CREATE INDEX activity_by_task ON activity(task_id, at);
+CREATE INDEX activity_recent ON activity(at);
diff --git a/crates/iz-core/src/authz.rs b/crates/iz-core/src/authz.rs
index 800330c..fcd0e93 100644
--- a/crates/iz-core/src/authz.rs
+++ b/crates/iz-core/src/authz.rs
@@ -3,10 +3,11 @@
//! A denial is `NotFound` when the viewer must not learn that the thing exists, and `Forbidden`
//! when the viewer may know it but may not act on it.
//!
-//! Levels: admin contains member, member contains viewer. `im_admin` acts as admin. A disabled
-//! account and role `none` are denied everything with `NotFound`. An anonymous actor is `Forbidden`,
-//! so the caller can show the sign-in card. The store repeats the disabled and `none` checks in its
-//! own queries (sessions, assignments), so a denied member cannot reach data through another path.
+//! Levels: admin contains member, member contains viewer. `im_admin` acts as admin, whatever the stored
+//! role says. A disabled account is denied everything with `NotFound`; so is a member with role `none`
+//! who is not an `im` administrator. An anonymous actor is `Forbidden`, so the caller can show the sign-in
+//! card. The store repeats the disabled and `none` checks in its own queries (sessions, assignments, mail),
+//! with the same `im_admin` exception, so a denied member cannot reach data through another path.
use crate::error::Error;
@@ -128,19 +129,18 @@ enum Level {
pub fn authorize(actor: &Actor, action: &Action) -> Result<(), Denied> {
let (sub, level) = match actor {
Actor::Anonymous => return Err(Denied::Forbidden),
- // A disabled member and a member with no role have no access, even when `im` makes them an admin.
- Actor::Member { disabled: true, .. }
- | Actor::Member {
- role: Role::NoAccess,
- ..
- } => {
- return Err(Denied::NotFound);
- }
+ // A disabled account has no access, even when `im` makes it an admin.
+ Actor::Member { disabled: true, .. } => return Err(Denied::NotFound),
+ // An `im` administrator is an admin whatever the stored role says, role `none` included.
Actor::Member {
sub,
im_admin: true,
..
} => (sub.as_str(), Level::Admin),
+ Actor::Member {
+ role: Role::NoAccess,
+ ..
+ } => return Err(Denied::NotFound),
Actor::Member { sub, role, .. } => {
let level = match role {
Role::Admin => Level::Admin,
@@ -222,6 +222,10 @@ mod tests {
[ok, ok, ok, Err(F), ok, ok, ok, ok],
),
(member("ada", Role::NoAccess, false, false), [Err(N); 8]),
+ (
+ member("ada", Role::NoAccess, true, false),
+ [ok, ok, ok, ok, ok, ok, ok, ok],
+ ),
(member("ada", Role::Admin, false, true), [Err(N); 8]),
];
let actions = [
diff --git a/crates/iz-core/src/store/members.rs b/crates/iz-core/src/store/members.rs
index 6e7e56a..cb19c81 100644
--- a/crates/iz-core/src/store/members.rs
+++ b/crates/iz-core/src/store/members.rs
@@ -59,6 +59,17 @@ pub struct Member {
pub last_sign_in_at: Option,
}
+impl Member {
+ /// The role iz acts on: an `im` administrator is always `admin`, whatever the stored role says.
+ pub fn effective_role(&self) -> Role {
+ if self.im_admin {
+ Role::Admin
+ } else {
+ self.role
+ }
+ }
+}
+
/// What the directory (or a sign-in) says about one person. Validated before it is stored.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DirectoryMember {
@@ -324,10 +335,18 @@ impl Store {
/// of the same conditional UPDATE, so two demotions cannot both pass.
///
/// Moving to `viewer` or `none` also removes the member's assignments and pending reminders.
+ /// A member who is an `im` administrator keeps the admin role whatever is stored, so their role
+ /// cannot be changed here (refused as a conflict; the page does not offer the change).
pub async fn set_role(&self, sub: &str, role: Role) -> Result<()> {
let conn = self.inner.conn.lock().await;
let tx = conn.unchecked_transaction().await.map_err(db_err)?;
let outcome: Result<()> = async {
+ let member = select_member(&tx, sub).await?.ok_or(Error::NotFound)?;
+ if member.im_admin {
+ return Err(Error::Conflict(
+ "the role of an im administrator is set in im".into(),
+ ));
+ }
let changed = tx
.execute(
"UPDATE members SET role = ?2 WHERE sub = ?1 AND (?2 = 'admin' OR EXISTS ( \
@@ -338,9 +357,6 @@ impl Store {
.await
.map_err(db_err)?;
if changed == 0 {
- if select_member(&tx, sub).await?.is_none() {
- return Err(Error::NotFound);
- }
return Err(Error::Conflict(
"the last administrator cannot be demoted".into(),
));
diff --git a/crates/iz-core/src/store/migrate.rs b/crates/iz-core/src/store/migrate.rs
index 6151041..d96e72b 100644
--- a/crates/iz-core/src/store/migrate.rs
+++ b/crates/iz-core/src/store/migrate.rs
@@ -24,6 +24,10 @@ pub const MIGRATIONS: &[(u32, &str)] = &[
6,
include_str!("../../migrations/0006_decision_skipped.sql"),
),
+ (
+ 7,
+ include_str!("../../migrations/0007_activity_restore_kinds.sql"),
+ ),
];
fn migration_err(e: turso::Error) -> Error {
diff --git a/crates/iz-core/src/store/mod.rs b/crates/iz-core/src/store/mod.rs
index ece8406..4501c41 100644
--- a/crates/iz-core/src/store/mod.rs
+++ b/crates/iz-core/src/store/mod.rs
@@ -404,7 +404,7 @@ mod tests {
})
.await
.unwrap();
- assert_eq!(versions, vec![1, 2, 3, 4, 5, 6]);
+ assert_eq!(versions, vec![1, 2, 3, 4, 5, 6, 7]);
}
#[tokio::test]
diff --git a/crates/iz-core/src/store/outbox.rs b/crates/iz-core/src/store/outbox.rs
index acd0857..f6a3a3e 100644
--- a/crates/iz-core/src/store/outbox.rs
+++ b/crates/iz-core/src/store/outbox.rs
@@ -178,7 +178,8 @@ pub fn clamp_page(limit: usize) -> usize {
limit.clamp(1, PAGE_MAX)
}
-/// Decides whether a claimed recipient may still receive mail: enabled, role admin or member.
+/// Decides whether a claimed recipient may still receive mail: enabled, role admin or member. The role
+/// read is the effective one (an `im` administrator is `admin`).
fn eligible_role(role: &str) -> bool {
matches!(role, "admin" | "member")
}
@@ -196,7 +197,7 @@ impl Store {
let candidates = fetch_all(
&tx,
&format!(
- "SELECT {OUTBOX_COLS}, m.role FROM mail_outbox o JOIN members m ON m.sub = o.recipient \
+ "SELECT {OUTBOX_COLS}, CASE WHEN m.im_admin = 1 THEN 'admin' ELSE m.role END FROM mail_outbox o JOIN members m ON m.sub = o.recipient \
WHERE o.state IN ('pending', 'failed') AND o.next_attempt_at <= ?1 \
AND (o.claimed_at IS NULL OR o.claimed_at <= ?2) \
ORDER BY o.next_attempt_at, o.id LIMIT ?3"
@@ -387,7 +388,7 @@ impl Store {
}
let recipients = fetch_all(
&tx,
- "SELECT sub FROM members WHERE disabled = 0 AND role IN ('admin', 'member') AND sub <> ?1 ORDER BY sub",
+ "SELECT sub FROM members WHERE disabled = 0 AND (im_admin = 1 OR role IN ('admin', 'member')) AND sub <> ?1 ORDER BY sub",
(actor.to_owned(),),
|row| col_text(row, 0),
)
diff --git a/crates/iz-core/src/store/reminders.rs b/crates/iz-core/src/store/reminders.rs
index f24f4f5..cf434ce 100644
--- a/crates/iz-core/src/store/reminders.rs
+++ b/crates/iz-core/src/store/reminders.rs
@@ -83,7 +83,7 @@ pub(super) async fn sync_reminders(tx: &Transaction<'_>, task_id: &str) -> Resul
"INSERT INTO reminders (task_id, sub, due_at, sent_at) \
SELECT a.task_id, a.sub, ?2, NULL FROM task_assignees a \
WHERE a.task_id = ?1 AND EXISTS ( \
- SELECT 1 FROM members m WHERE m.sub = a.sub AND m.disabled = 0 AND m.role IN ('admin', 'member')) \
+ SELECT 1 FROM members m WHERE m.sub = a.sub AND m.disabled = 0 AND (m.im_admin = 1 OR m.role IN ('admin', 'member'))) \
ON CONFLICT(task_id, sub) DO NOTHING",
(task_id.to_owned(), due),
)
@@ -112,7 +112,7 @@ impl Store {
"SELECT r.task_id, r.sub, t.key, t.title, t.meeting_at, m.zoneinfo, m.locale, m.locale_override \
FROM reminders r JOIN tasks t ON t.id = r.task_id JOIN members m ON m.sub = r.sub \
WHERE r.sent_at IS NULL AND r.due_at <= ?1 AND t.deleted_at IS NULL \
- AND m.disabled = 0 AND m.role IN ('admin', 'member') \
+ AND m.disabled = 0 AND (m.im_admin = 1 OR m.role IN ('admin', 'member')) \
ORDER BY r.due_at, r.task_id, r.sub LIMIT ?2",
(stamp.clone(), i64::try_from(batch).unwrap_or(i64::MAX)),
|row| {
diff --git a/crates/iz-core/src/store/rules_engine.rs b/crates/iz-core/src/store/rules_engine.rs
index 53ea2ee..cbcfccf 100644
--- a/crates/iz-core/src/store/rules_engine.rs
+++ b/crates/iz-core/src/store/rules_engine.rs
@@ -76,7 +76,7 @@ async fn eligible_members(tx: &Transaction<'_>) -> Result> {
fetch_all(
tx,
"SELECT sub, locale, locale_override, zoneinfo FROM members \
- WHERE disabled = 0 AND role IN ('admin', 'member') ORDER BY sub",
+ WHERE disabled = 0 AND (im_admin = 1 OR role IN ('admin', 'member')) ORDER BY sub",
(),
|row| {
let locale = col_opt_text(row, 1)?;
diff --git a/crates/iz-core/src/store/sessions.rs b/crates/iz-core/src/store/sessions.rs
index c620bea..6cc7d25 100644
--- a/crates/iz-core/src/store/sessions.rs
+++ b/crates/iz-core/src/store/sessions.rs
@@ -81,7 +81,7 @@ impl Store {
"INSERT INTO sessions (id, sub, token_hash, csrf_token, sid, created_at, expires_at, \
last_seen, user_agent, ip, id_token_sealed) \
SELECT ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?6, ?8, ?9, ?10 FROM members \
- WHERE sub = ?2 AND disabled = 0 AND role <> 'none'",
+ WHERE sub = ?2 AND disabled = 0 AND (im_admin = 1 OR role <> 'none')",
(
id.clone(),
sub.to_owned(),
@@ -107,7 +107,8 @@ impl Store {
})
}
- /// The live session for a cookie token: unexpired, member enabled, role not `none`. `None` otherwise,
+ /// The live session for a cookie token: unexpired, member enabled, role not `none` (an `im` administrator
+ /// always passes). `None` otherwise,
/// with no hint about which check failed.
pub async fn session_by_token(&self, token: &str) -> Result
}
+
+
(t(lang, K::DeletedHeading))
+
(t(lang, K::DeletedHelp))
+ if page.deleted.is_empty() {
+
(t(lang, K::DeletedEmpty))
+ } else {
+
+
+
+
(t(lang, K::DeletedTaskHeader))
+
(t(lang, K::DeletedAtHeader))
+
(t(lang, K::DeletedByHeader))
+
+
+
+
+ for row in page.deleted.iter() {
+
+
(row.key.as_str()) " " (row.title.as_str())
+
(row.at.as_str())
+
+ if let Some(name) = &row.by {
+ (name.as_str())
+ } else {
+ (t(lang, K::DeletedUnknown))
+ }
+