Skip to main content

Module slack

Module slack 

Source
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\0ts and 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 ts delivered for a conversation. Stored as the string Slack sent it, never as a number.
thread
One thread’s record, or None when 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 ts delivered for a conversation in a workspace, or None when 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.