Repository navigation
feat(channels): first message claims the owner - #121
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's done
ChannelConfig.claimUntil?: number(epoch ms).Config.openClaim()turns a channel on and, when the allowlist is empty, setsclaimUntil = 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:claimUntilcleared, logclaimed <channel> owner <senderId>, verdict{ allowed: true, claimed }.Nobody owns this bot yet. Turn the channel off and on again in Redrob Launcher, then send a message within 15 minutes.You are not allowed to use this bot., unchanged.ChannelManager.onMessage: onclaimed, persists withConfig.update, rewrites the running entry's config and the manager snapshot (so a laterPOST /channels/reloadsees no change and keeps the connection), repliesYou 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/statusper channel:owner?: string(first allowlist entry) andclaimOpen: boolean. Protocol schema, server controller type,ChannelManager.status(), regeneratedpackages/client/src/generated/types.ts.redrob channels enableprintsWaiting for its owner: send any message to the bot within 15 minutes.when nobody is allowed;listshowsowner: <id>/owner: (waiting)(+also:for extra ids, json rows gainowner/claimOpen);statusshowswaiting for its owner's first messageorowner: <id>;allowcloses any open window.docs/CHANNELS.mdand the four transport READMEs replace theallow <senderId>step with the claim sentence;redrob channels allowstays documented as how to add more people.What's not done
channels.jsonitself; it must setclaimUntil(or call the sameConfig.openClaimshape:enabled: true, claimUntil: Date.now() + 15*60*1000whenallowlistis empty) and can readowner/claimOpenfrom/channels/statusto show "waiting for your first message".turbo typecheckon its own: 23/23 green.v2.channels.statusonly assertschannelsis 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:onMessageordering (persist, greet, dispatch) andclaimed()keepingrun.config/this.configin sync soapply()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
allowremains the explicit path for a second person.