Skip to content

feat(channels): first message claims the owner - #121

Merged
its-janghoon merged 1 commit into
developfrom
feat/channel-owner-claim
Oct 17, 2026
Merged

its-janghoon merged 1 commit into
developfrom
feat/channel-owner-claim

Conversation

@its-janghoon

Copy link
Copy Markdown
Member

What's done

  • ChannelConfig.claimUntil?: number (epoch ms). Config.openClaim() turns a channel on and, when the allowlist is empty, sets claimUntil = now + 15 min; Config.claim() writes the owner and drops the field; Config.claimOpen() / Config.owner() are the two readers. defaultChannel() is unchanged.
  • Allowlist.check (one place, packages/channels/core/src/allowlist.ts) now has three outcomes for a sender who is not allowed:
    • empty allowlist + window open: sender is added in memory, claimUntil cleared, log claimed <channel> owner <senderId>, verdict { allowed: true, claimed }.
    • empty allowlist, window over/unset: once per sender, Nobody owns this bot yet. Turn the channel off and on again in Redrob Launcher, then send a message within 15 minutes.
    • non-empty allowlist: today's You are not allowed to use this bot., unchanged.
  • ChannelManager.onMessage: on claimed, persists with Config.update, rewrites the running entry's config and the manager snapshot (so a later POST /channels/reload sees no change and keeps the connection), replies You are now the owner of this bot. Only you can talk to it. Send /new to start a fresh session., then dispatches the same message normally.
  • GET /channels/status per channel: owner?: string (first allowlist entry) and claimOpen: boolean. Protocol schema, server controller type, ChannelManager.status(), regenerated packages/client/src/generated/types.ts.
  • CLI: redrob channels enable prints Waiting for its owner: send any message to the bot within 15 minutes. when nobody is allowed; list shows owner: <id> / owner: (waiting) (+ also: for extra ids, json rows gain owner/claimOpen); status shows waiting for its owner's first message or owner: <id>; allow closes any open window.
  • WhatsApp gets no special case: the first sender to the linked number (the paired phone or another) is the owner.
  • Docs: docs/CHANNELS.md and the four transport READMEs replace the allow <senderId> step with the claim sentence; redrob channels allow stays documented as how to add more people.

What's not done

  • Redrob Launcher (separate repo) still writes channels.json itself; it must set claimUntil (or call the same Config.openClaim shape: enabled: true, claimUntil: Date.now() + 15*60*1000 when allowlist is empty) and can read owner / claimOpen from /channels/status to show "waiting for your first message".
  • No tests added, no CI changes, no builds (release builds once). The pre-push hook ran turbo typecheck on its own: 23/23 green.
  • Exerciser scenario untouched: v2.channels.status only asserts channels is an array.

What to review

  • packages/channels/core/src/allowlist.ts: the verdict shape and the three reply branches.
  • packages/channels/core/src/index.ts: onMessage ordering (persist, greet, dispatch) and claimed() keeping run.config / this.config in sync so apply() does not restart the transport.
  • packages/channels/core/src/config.ts: claim() prepends the owner and keeps any id added to the file in the meantime.

Intentions

  • Non-developers never have to find their own platform id: turn the channel on, send a message, done. The 15-minute window keeps "empty allowlist" from meaning "open to the world" for long, and allow remains the explicit path for a second person.

A channel enabled with an empty allowlist used to let nobody in, so the user had to look up their own platform sender id and run `redrob channels allow`. Now `redrob channels enable` opens a 15-minute claim window (`claimUntil` in channels.json); the first person who messages the bot inside it is written into the allowlist as the owner, greeted, and answered. After the window a stranger is told to turn the channel off and on again; once owned, the old "not allowed" reply stays.

The claim is applied in the running allowlist and the manager rewrites its config snapshot, so a later /channels/reload does not restart the transport. GET /channels/status gains `owner` and `claimOpen`; the client types are regenerated. CLI: `enable` prints the waiting line, `list` shows owner, `status` shows "waiting for its owner". Docs and transport READMEs replace the allow step with the claim; `allow` remains the way to add more people.
@its-janghoon its-janghoon reopened this Oct 17, 2026
@its-janghoon
its-janghoon merged commit 06a23b9 into develop Oct 17, 2026
33 of 34 checks passed
@its-janghoon
its-janghoon deleted the feat/channel-owner-claim branch October 17, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant