fix(group-translate): make the group introduction opt-in and off by default - #60
Merged
Merged
Conversation
…efault Enabling the plugin used to post a "Translation bot" introduction into a group the first time it saw any message there. That fired per group, so one enable announced the bot into every group the WhatsApp account belonged to — and the account running a plugin is usually somebody's own WhatsApp, not a dedicated bot number. The introduction now sits behind announceInGroups, false in the manifest and false in the code that reads it, so an install upgrading from an earlier version has no stored value and stays silent. Nothing is lost by defaulting it off: the same text is still available to anyone on demand via `/tr help`, and translation already required an admin to run `/tr on` in that specific group. The regression test asserts the default, which is the value that shipped the harm; with the guard removed it fails on the announcement it must not send. The concurrency test that used the announcement as its observable now opts in explicitly, keeping what it proves intact.
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.
Problem
Enabling this plugin made it post a
👋 Translation bot…introduction into a group the first time it saw any message there. The check sat at the very top of the message path, ahead of every other condition:State is per chat, so this fired once per group — a single enable announced the bot into every group the WhatsApp account belonged to, as each of those groups saw its next message. The account running a plugin is normally a real person's WhatsApp rather than a dedicated bot number, which makes the blast radius somebody's entire group list.
Change
The introduction now sits behind a new
announceInGroupssetting, default false — in the manifest and, independently, in the code that reads it. An install upgrading from an earlier version has no stored value for the key, so it stays silent without operator action.Defaulting it off costs nothing:
/tr help/tr onin that specific groupThis was the only place the plugin spoke without being addressed; every other send is a reply to a
/trcommand or a translation in a group where an admin turned it on.Tests
The regression test asserts the default configuration — the value that shipped the harm — and checks both that nothing is sent and that an ordinary group message is not claimed. Removing the guard fails it on the send it must not make. Two more cases cover the opt-in path announcing once per group, and
/tr helpstill answering regardless of the setting.The pre-existing concurrency test used the announcement as its observable for the per-chat lock; it now opts in explicitly, so what it proves is unchanged.
Full suite 529/529, typecheck and catalog check clean.