messenger: tell the operator, by name and number, when another account answers a question meant for them
The lab's proof showed a stranger's refused tap said as "That answer was not taken" on the operator's own chat (the router sends to the linked account), where it reads as the operator's own answer refused. It now says which account tried, that nothing was done, and what it may mean.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user