Expand description
Slack subscription CRUD on the redb slack_subscriptions table.
The whole SlackSubscription record is stored as serde-json keyed
by its uuid bytes, the shape store::gotify uses. It gets its own
table rather than sharing Gotify’s: the two carry different record
shapes, so one table would decode the other’s rows as garbage.
Re-exports§
use anyhow::Context;🔒use forge_primitives::slack::SlackSubscription;🔒use forge_primitives::slack::SlackThreadRecord;🔒use redb::ReadableTable;🔒use redb::TableDefinition;🔒use uuid::Uuid;🔒use super::Db;🔒
Constants§
- OWN_
POSTS 🔒 - The newest messages forge posted itself, keyed
workspace\0conversation\0tsand stamped with the seconds it was recorded. The sweep refuses a message whose ts is here, because forge posts as the user and the author can no longer tell them apart. - OWN_
POST_ 🔒KEEP - A conversation’s newest own posts kept, and the age past which a row is dropped. Both are applied when that conversation records its next post, so a conversation that never posts again keeps what it had. A pruned row costs at most one self-delivery, the same cost as a lost ledger.
- OWN_
POST_ 🔒MAX_ AGE_ SECS - SUBS 🔒
- THREADS 🔒
- One followed thread per (workspace, conversation, parent) triple. The value is JSON because the owner list rides beside the verbatim reply cursor; a bare string would lose the owners.
- WATERMARKS 🔒
- Keyed by the workspace label and the conversation id, not by the subscription: a conversation can be watched by more than one subscription, and the cursor belongs to the conversation.
Functions§
- insert
- Persist a subscription, replacing any prior record with the same id.
- list
- Every persisted subscription.
- own_
post - Whether forge posted this message.
- own_
post_ 🔒key - own_
post_ 🔒prefix - read_
all 🔒 - record_
own_ post - Record a message forge posted at
now, pruning the conversation’s rows past either bound. - remove
- Delete a subscription by id. Returns whether a record existed.
- remove_
thread - Delete one thread row. Returns whether a row existed.
- remove_
watermark - Remove a conversation’s sweep cursor, the
__mentions__stream included. Returns whether one existed. - set_
thread - Store one thread’s record, replacing any prior row for the triple.
- set_
watermark - Record the last
tsdelivered for a conversation. Stored as the string Slack sent it, never as a number. - thread
- One thread’s record, or
Nonewhen that thread is not followed. - thread_
key 🔒 \u{0}joins the triple; none of its parts can carry one.- threads_
for - Every followed thread of one conversation, as (parent ts, record).
- threads_
for_ workspace - Every followed thread of one workspace, across its conversations, as (conversation, parent ts, record). Backs removal-time pruning.
- watermark
- The last
tsdelivered for a conversation in a workspace, orNonewhen that conversation has never been swept. - watermark_
conversations - Every conversation with a sweep cursor in one workspace, including the
__mentions__stream when present. - watermark_
key 🔒 \u{0}joins the pair. A Slack conversation id is alphanumeric and a workspace label is a TOML string, so neither carries one.