Repository navigation
Count a thumbs up on the chat bot's message as approval - #169
Merged
Merged
Conversation
An admitted user's 👍 on one of the bot's Slack or Discord messages, in a thread with a session, reaches the session as an approval that counts as a mention. Other reactions, outsiders' and bots' reactions, and threads without a session are ignored; a reaction never starts a session. Closes EFF-3163
Slack decodes only a thumbs up on a message, so the handler loses its shape checks and reuses the author spread. Discord checks the emoji before reading the seen store, and both dispatches share one refusal handler.
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.
A 👍 reaction (any skin tone) on one of the chat bot's Slack or Discord messages now counts as approval. It works when the reaction comes from an admitted user, in a thread that has a session. The session gets it as a message from that user, "👍 (reacted with a thumbs up to your message: approved)". That message counts as a mention, so it skips the reply gate and starts or steers a turn. This lets someone answer a yes/no question or an approval request with a thumbs up.
Authorization stays as it is. A reaction never starts a session. Other emoji, reactions on someone else's message, and reactions from outsiders, guests or bots are ignored, not kept as context. Reactions from other guilds and in threads without a session are ignored too.
Discord
DiscordIngress.handleReactionhandlesMESSAGE_REACTION_ADD. The gateway now asks forGUILD_MESSAGE_REACTIONS, which is not privileged, and routes the event through the same before-sequence hook as messages. Approval ids go intoSeenMessages, so a RESUME replay is dropped.member.roles, through atoAuthorhelper that is now shared withtoChatMessage.{ id: null, name: "👍" }, although dfx types it as a custom emoji. Matching is by name, and only for emoji with no id.postReply: an approval's id (reaction/{message}/{user}) isn't a Discord snowflake, and Discord would reject amessage_referenceto it. A turn started by an approval therefore mentions the approver instead of replying to the message, the same way the thread-starter case already works.Slack
reaction_added. It accepts+1orthumbsup, with or without::skin-tone-N, on a message whoseitem_useris the bot.conversations.replieswithts= the reacted message. Per the API docs,tsmay be "either a thread's parent message or a message in the thread". Results are ordered earliest first, and every threaded message carries the root's ts asthread_ts, somessages[0].thread_tsis the root. An unthreaded message has nothread_tsand is ignored. Adeniederror, such asthread_not_foundfor a deleted message, is logged and the reaction ignored. Other failures answer 503 so Slack retries. The call needs no new scopes:channels:history,groups:historyandim:historyare already granted.users.info, then remember) is factored intoadmitand shared with the message path.Deployment
reactions:readscope and areaction_addedbot event subscription, then a reinstall.docs/chat.mdcovers both.Validation
test/Chat/{Slack,Discord}/Ingress.test.ts. Each covers the approval cases and all the dropped cases. Both fail onmainand pass here.vp checkpasses. All Chat tests pass (95/95).Closes EFF-3163