diff --git a/modules/messenger/cmd/messenger/answers_test.go b/modules/messenger/cmd/messenger/answers_test.go index d3ff82ca..8d90d4ac 100644 --- a/modules/messenger/cmd/messenger/answers_test.go +++ b/modules/messenger/cmd/messenger/answers_test.go @@ -340,9 +340,18 @@ func TestEveryAnswerThatIsNotTheOperatorsIsRefusedAndSaid(t *testing.T) { if len(w.of("mesh-delivery")) != 0 { t.Error("a warrant was issued") } - if tc.kind == "telegram" && (len(tg.sends) != before+1 || tg.sends[len(tg.sends)-1].Title != "That answer was not taken") { + title := "That answer was not taken" + if tc.identity == "666" { + // Another account's answer is said to the operator, naming that account (the lab's proof found + // the plain refusal reached the operator and read as their own answer refused). + title = "Another account tried to answer for you" + } + if tc.kind == "telegram" && (len(tg.sends) != before+1 || tg.sends[len(tg.sends)-1].Title != title) { t.Errorf("the refusal was not said on the channel: %+v", tg.sends[before:]) } + if tc.identity == "666" && !strings.Contains(tg.sends[len(tg.sends)-1].Body, "number 666") { + t.Errorf("the notice does not name the other account: %q", tg.sends[len(tg.sends)-1].Body) + } }) } } diff --git a/modules/messenger/cmd/messenger/asks.go b/modules/messenger/cmd/messenger/asks.go index a32e244d..3bb56d91 100644 --- a/modules/messenger/cmd/messenger/asks.go +++ b/modules/messenger/cmd/messenger/asks.go @@ -653,7 +653,7 @@ func (h *Holder) judge(kind string, c asks.Choice, key string) (string, error) { id = &only } if id == nil { - return h.refuseChoice(kind, c, "this account is not linked as the operator") + return h.refuseStranger(kind, c) } person.Verified = "user id verified" } else { @@ -692,6 +692,24 @@ func (h *Holder) judge(kind string, c asks.Choice, key string) (string, error) { return "chosen", nil } +// refuseStranger refuses an answer from an account that is not the operator's, and tells the operator, by name +// and number, on the account that is linked: a question's buttons reached somebody else (a forwarded message, +// or a phone in other hands). Nothing is said to the other account. +func (h *Holder) refuseStranger(kind string, c asks.Choice) (string, error) { + why := "this account is not linked as the operator" + h.Logf("[messenger] an answer on %s from %s was refused: %s", kind, c.Sender.Identity, why) + h.record(Sent{At: h.Now(), Channel: kind, Key: "(answer)", What: "answer", Outcome: "refused: " + why}) + who := c.Sender.Display + if who == "" { + who = "an account" + } + _ = h.showOn(kind, Message{Title: "Another account tried to answer for you", + Body: fmt.Sprintf("The %s account %s (number %s) chose an answer on a question meant for you. It was refused "+ + "and nothing was done. If you did not pass the question on, somebody else can read your messages.", + Display(kind), who, c.Sender.Identity), Urgent: true}) + return "refused", errorf("%s", why) +} + // refuseChoice says on the kind that an answer was not taken, and why. func (h *Holder) refuseChoice(kind string, c asks.Choice, why string) (string, error) { h.Logf("[messenger] an answer on %s from %s was refused: %s", kind, c.Sender.Identity, why)