Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-8628 fix(wecom): ask the room to open the 1:1 when WeCom refuses a private reply (#9956)

Xichang(Seacen) Zhaobd1cffaa217b
diff --git a/server/internal/integrations/wecom/binding.go b/server/internal/integrations/wecom/binding.go
index 1ce3ace285..566afe2fa4 100644
--- a/server/internal/integrations/wecom/binding.go
+++ b/server/internal/integrations/wecom/binding.go
@@ -48,12 +48,15 @@ const BindingTokenTTL = 15 * time.Minute
// with "tap the link I sent you", pointing at something that never arrived,
// and the user cannot link their account until the window passes.
//
-// That covers the send we never hear back about, and equally the send we know
+// That covers the send we never hear back about, and most sends we know
// failed: the row is written before delivery is attempted, so a prompt the
// transport refused outright (no live connection mid-reconnect or lease flip)
-// still suppresses the next minute of mints. Nothing here reacts to that
-// error — the window itself, not a delivery receipt, is what bounds the
-// damage, which is the other reason to keep it short.
+// still suppresses the next minute of mints. The window itself, not a delivery
+// receipt, is what bounds that damage, which is the other reason to keep it
+// short. The one exception is errcodeUserMustMessageFirst: the replier
+// withdraws that link (Withdraw), because the room has just been asked to open
+// the 1:1 and the user's next message there must get a link, not a pointer to
+// one.
//
// Sixty seconds does the job the throttle was written for: six lines typed in
// one breath still write one row, at a cost of at most one row a minute for a
@@ -100,13 +103,14 @@ type RedeemedBindingToken struct {
WecomUserID string
}
-// bindingMintQueries is the slice of generated queries the mint path uses.
-// Narrow on purpose: mint is the only part of the service that runs outside a
-// transaction, so it is the only part a unit test can drive with a fake.
-// *db.Queries satisfies it.
+// bindingMintQueries is the slice of generated queries the mint and withdraw
+// paths use. Narrow on purpose: they are the parts of the service that run
+// outside a transaction, so they are the parts a unit test can drive with a
+// fake. *db.Queries satisfies it.
type bindingMintQueries interface {
CreateChannelBindingToken(ctx context.Context, arg db.CreateChannelBindingTokenParams) (db.ChannelBindingToken, error)
FindLiveChannelBindingToken(ctx context.Context, arg db.FindLiveChannelBindingTokenParams) (db.ChannelBindingToken, error)
+ ConsumeChannelBindingToken(ctx context.Context, tokenHash string) (db.ChannelBindingToken, error)
}
// BindingTokenService mints and redeems WeCom binding tokens. Redemption is
@@ -182,6 +186,21 @@ func (s *BindingTokenService) Mint(ctx context.Context, workspaceID, installatio
return BindingToken{Raw: raw, ExpiresAt: expiresAt}, nil
}
+// Withdraw retires a link that never reached its user, so the throttle stops
+// pointing them back at it and their next message mints one that can. It
+// spends the token the way a redemption does (consumed_at), which is also what
+// makes it unredeemable — harmless for a link nobody received. A token already
+// spent or expired is not an error: there is nothing left to withdraw.
+func (s *BindingTokenService) Withdraw(ctx context.Context, raw string) error {
+ if s.mint == nil {
+ return errors.New("wecom: BindingTokenService missing queries")
+ }
+ if _, err := s.mint.ConsumeChannelBindingToken(ctx, hashBindingToken(raw)); err != nil && !errors.Is(err, pgx.ErrNoRows) {
+ return fmt.Errorf("wecom: withdraw token: %w", err)
+ }
+ return nil
+}
+
// RedeemAndBind atomically consumes a raw token and binds the WeCom userid
// to multicaUserID (taken from the session, never from the token). Returns
// ErrBindingTokenInvalid / ErrBindingAlreadyAssigned /
diff --git a/server/internal/integrations/wecom/binding_test.go b/server/internal/integrations/wecom/binding_test.go
index 6760e7a1e9..11c7563593 100644
--- a/server/internal/integrations/wecom/binding_test.go
+++ b/server/internal/integrations/wecom/binding_test.go
@@ -72,6 +72,17 @@ func (f *fakeMintQueries) FindLiveChannelBindingToken(_ context.Context, arg db.
return best, nil
}
+func (f *fakeMintQueries) ConsumeChannelBindingToken(_ context.Context, tokenHash string) (db.ChannelBindingToken, error) {
+ for i := range f.rows {
+ r := &f.rows[i]
+ if r.TokenHash == tokenHash && !r.ConsumedAt.Valid && r.ExpiresAt.Time.After(f.now()) {
+ r.ConsumedAt = pgtype.Timestamptz{Time: f.now(), Valid: true}
+ return *r, nil
+ }
+ }
+ return db.ChannelBindingToken{}, pgx.ErrNoRows
+}
+
func newThrottledService() (*BindingTokenService, *fakeMintQueries, *time.Time) {
clock := time.Now()
fake := &fakeMintQueries{now: func() time.Time { return clock }}
@@ -207,3 +218,39 @@ func TestMintIgnoresAConsumedToken(t *testing.T) {
t.Fatalf("%d rows written, want 2", fake.creates)
}
}
+
+// TestWithdrawLetsTheNextMessageGetALink: a link WeCom refused to deliver must
+// not hold the throttle. Without Withdraw the second mint comes back Reused and
+// the user is pointed at a link they never received.
+func TestWithdrawLetsTheNextMessageGetALink(t *testing.T) {
+ svc, fake, _ := newThrottledService()
+ ws, inst := bindingUUID(1), bindingUUID(2)
+
+ first, err := svc.Mint(context.Background(), ws, inst, "T-alex")
+ if err != nil {
+ t.Fatalf("first mint: %v", err)
+ }
+ if err := svc.Withdraw(context.Background(), first.Raw); err != nil {
+ t.Fatalf("withdraw: %v", err)
+ }
+
+ again, err := svc.Mint(context.Background(), ws, inst, "T-alex")
+ if err != nil {
+ t.Fatalf("second mint: %v", err)
+ }
+ if again.Reused || again.Raw == "" || again.Raw == first.Raw {
+ t.Fatalf("mint after a withdrawal = %+v, want a fresh link", again)
+ }
+ if fake.creates != 2 {
+ t.Fatalf("%d rows written, want 2", fake.creates)
+ }
+}
+
+// TestWithdrawOfASpentTokenIsNotAnError: the user may have redeemed it, or it
+// may have expired, between the send and the withdrawal. Nothing is left to do.
+func TestWithdrawOfASpentTokenIsNotAnError(t *testing.T) {
+ svc, _, _ := newThrottledService()
+ if err := svc.Withdraw(context.Background(), "never-minted"); err != nil {
+ t.Fatalf("withdraw of an unknown token: %v", err)
+ }
+}
diff --git a/server/internal/integrations/wecom/locale_wiring_test.go b/server/internal/integrations/wecom/locale_wiring_test.go
index 0b8fc05310..ad86be4e5b 100644
--- a/server/internal/integrations/wecom/locale_wiring_test.go
+++ b/server/internal/integrations/wecom/locale_wiring_test.go
@@ -211,6 +211,40 @@ func TestInvokeDeniedFromAGroupReadsTheSendersLanguage(t *testing.T) {
}
}
+// TestInvokeDeniedAsksTheRoomWhenTheUserMustMessageFirst — being bound does
+// not mean the member has ever written to the bot in their 1:1, and until they
+// have WeCom refuses the private refusal (846607). The room then gets the same
+// token-less ask an unbound member gets, in the room's language, and nothing
+// that says the agent was refused to them.
+func TestInvokeDeniedAsksTheRoomWhenTheUserMustMessageFirst(t *testing.T) {
+ t.Parallel()
+ reg := newSendersRegistry()
+ inst := engine.ResolvedInstallation{ID: mustTestUUID(t)}
+ conn := &recordingConn{refuseTo: "T-asker", refuseCode: errcodeUserMustMessageFirst}
+ reg.set(inst.ID, conn.autoAck(newWSSender(conn, nil)))
+ r := NewOutboundReplier(OutboundReplierConfig{
+ Senders: reg,
+ Languages: languagesFor("en"),
+ AppURL: "https://multica.example",
+ })
+ msg := channel.InboundMessage{Source: channel.Source{
+ ChatID: "GROUP_CHAT",
+ ChatType: channel.ChatTypeGroup,
+ SenderID: "T-asker",
+ }}
+ r.Reply(context.Background(), inst, msg, engine.Result{Outcome: engine.OutcomeInvokeDenied})
+
+ if n := len(conn.sendFrames()); n != 2 {
+ t.Fatalf("expected 2 frames (refused private notice + room ask), got %d", n)
+ }
+ if got := conn.sendBody(t, 1)["chatid"]; got != "GROUP_CHAT" {
+ t.Fatalf("second frame went to %v, want the room", got)
+ }
+ if got, want := sentMarkdown(t, conn, 1), copyFor(deploymentLocale()).MessageMeFirst; got != want {
+ t.Fatalf("room line = %q, want the room's-language ask %q", got, want)
+ }
+}
+
// ---- surface 2: inbox_message.go ----
func TestInboxCardReadsTheRecipientsLanguage(t *testing.T) {
diff --git a/server/internal/integrations/wecom/replier.go b/server/internal/integrations/wecom/replier.go
index 9fe9c380e2..9617b81393 100644
--- a/server/internal/integrations/wecom/replier.go
+++ b/server/internal/integrations/wecom/replier.go
@@ -52,6 +52,27 @@ type OutboundReplier struct {
// (no DB-backed token mint). *BindingTokenService is the production value.
type binder interface {
Mint(ctx context.Context, workspaceID, installationID pgtype.UUID, wecomUserID string) (BindingToken, error)
+ Withdraw(ctx context.Context, raw string) error
+}
+
+// errcodeUserMustMessageFirst — WeCom refused an aibot_send_msg because the
+// person has never written to the bot in that conversation. The bot may push
+// into a chat only after the user has spoken there: "需要用户在会话中给机器人发消息,
+// 后续机器人才能主动推送消息给对应会话中" (developer.work.weixin.qq.com/document/path/101463).
+// The global errcode table names the code and the same remedy: "846607 发送消息
+// 命中限制 智能机器人发送消息频率超限,请确保用户在该会话中给机器人发过消息"
+// (.../path/90313). The errmsg the server sends with it reads "aibot send msg
+// frequency limit exceeded", which is why the code and not the text decides.
+//
+// For a group trigger the conversation is the sender's 1:1, which a member who
+// has only ever @-mentioned the bot in a room has never opened.
+const errcodeUserMustMessageFirst = 846607
+
+// userMustMessageFirst reports whether a private send was refused because the
+// recipient has not yet written to the bot in their 1:1.
+func userMustMessageFirst(err error) bool {
+ var apiErr *wecomAPIError
+ return errors.As(err, &apiErr) && apiErr.Code == errcodeUserMustMessageFirst
}
// OutboundReplierConfig configures the replier. Binding + AppURL are
@@ -160,7 +181,7 @@ func (r *OutboundReplier) Reply(ctx context.Context, inst engine.ResolvedInstall
"installation_id", util.UUIDToString(inst.ID), "error", err)
}
case engine.OutcomeInvokeDenied:
- if err := r.sendInvokeDenied(ctx, inst, msg); err != nil {
+ if err := r.sendInvokeDenied(ctx, inst, msg, c); err != nil {
r.logger.WarnContext(ctx, "wecom replier: invoke-denied notice failed",
"installation_id", util.UUIDToString(inst.ID), "error", err)
}
@@ -233,6 +254,30 @@ func (r *OutboundReplier) sendBindingPrompt(ctx context.Context, inst engine.Res
// address outbound.go uses for inbox pushes), never to the room. Lark's
// SendBindingPromptCard targets the sender's OpenID for the same reason.
if err := r.postPrivate(ctx, inst, sender, text); err != nil {
+ // The room is about to be told that a message in the 1:1 gets an
+ // answer. Left live, the refused link would make that message's mint
+ // come back Reused inside BindingTokenMintInterval, and the user would
+ // be told to tap a link above that is not there. Withdrawing it lets
+ // the next message mint a link that can reach them. Only this refusal:
+ // any other leaves the throttle as it was, so a 45009 is not answered
+ // with a fresh mint per message. A throttled prompt has no raw token
+ // to withdraw.
+ if userMustMessageFirst(err) && !token.Reused {
+ if werr := r.binding.Withdraw(ctx, token.Raw); werr != nil {
+ r.logger.WarnContext(ctx, "wecom replier: withdraw undelivered binding link failed",
+ "installation_id", util.UUIDToString(inst.ID), "error", werr)
+ }
+ }
+ // A member who has only ever @-mentioned the bot in a room cannot be
+ // written to privately until they write to it first. Without a word
+ // in the room they hear nothing at all, so the room is asked to make
+ // that first move. The line carries no token and names no one; the
+ // link itself still only ever goes to the 1:1, once they open it.
+ if userMustMessageFirst(err) && aibotChatTypeFromChannel(msg.Source.ChatType) == chatTypeGroupInt {
+ if perr := r.post(ctx, inst, msg, c.MessageMeFirst); perr != nil {
+ return errors.Join(err, perr)
+ }
+ }
return err
}
// A group trigger still needs an answer — silence reads as a broken bot —
@@ -248,21 +293,28 @@ func (r *OutboundReplier) sendBindingPrompt(ctx context.Context, inst engine.Res
// sendInvokeDenied tells a member the agent is not theirs to run.
//
// A 1:1 is answered in place. A GROUP trigger is answered in the sender's own
-// 1:1 and the room hears nothing: a line there would tell everyone present both
-// which member was refused and that the agent is someone's private one. The
-// sender is bound by definition at this point — the identity check is what
-// produced the user id this verdict was read for — so a 1:1 route to them
-// exists.
+// 1:1 and the room hears nothing about the refusal: a line there would tell
+// everyone present both which member was refused and that the agent is
+// someone's private one. Being bound does not mean they have ever written to
+// the bot in that 1:1, though, and until they have WeCom refuses the push
+// (errcodeUserMustMessageFirst). The room is then asked, in roomCopy, to make
+// that first move — the same line an unbound member gets, so it says nothing
+// about why. Their first message in the 1:1 is refused in place.
//
-// Either way the only reader is the sender, so the sender's own profile picks
-// the language — not the room's, which is what Reply resolved for everything
-// else it says.
-func (r *OutboundReplier) sendInvokeDenied(ctx context.Context, inst engine.ResolvedInstallation, msg channel.InboundMessage) error {
+// The refusal's only reader is the sender, so the sender's own profile picks
+// its language — not the room's, which is what Reply resolved into roomCopy.
+func (r *OutboundReplier) sendInvokeDenied(ctx context.Context, inst engine.ResolvedInstallation, msg channel.InboundMessage, roomCopy copyPack) error {
text := copyFor(localeFor(ctx, r.languages, inst.ID, chatTypeSingleInt, msg.Source.SenderID)).InvokeDenied
if aibotChatTypeFromChannel(msg.Source.ChatType) != chatTypeGroupInt {
return r.post(ctx, inst, msg, text)
}
- return r.postPrivate(ctx, inst, msg.Source.SenderID, text)
+ err := r.postPrivate(ctx, inst, msg.Source.SenderID, text)
+ if userMustMessageFirst(err) {
+ if perr := r.post(ctx, inst, msg, roomCopy.MessageMeFirst); perr != nil {
+ return errors.Join(err, perr)
+ }
+ }
+ return err
}
// postPrivate delivers text to a single user's 1:1 chat (chat_type=1),
diff --git a/server/internal/integrations/wecom/replier_test.go b/server/internal/integrations/wecom/replier_test.go
index a8db91daeb..7147ac7794 100644
--- a/server/internal/integrations/wecom/replier_test.go
+++ b/server/internal/integrations/wecom/replier_test.go
@@ -28,9 +28,19 @@ import (
// fakeBinder mints a fixed, recognizable raw token without touching a DB.
// With reused set it behaves like the throttle suppressing a mint: no raw
// secret, only the live token's expiry.
+//
+// withdrawn, when set, records every raw token the replier withdraws.
type fakeBinder struct {
- raw string
- reused bool
+ raw string
+ reused bool
+ withdrawn *[]string
+}
+
+func (f fakeBinder) Withdraw(_ context.Context, raw string) error {
+ if f.withdrawn != nil {
+ *f.withdrawn = append(*f.withdrawn, raw)
+ }
+ return nil
}
func (f fakeBinder) Mint(context.Context, pgtype.UUID, pgtype.UUID, string) (BindingToken, error) {
@@ -51,10 +61,14 @@ type recordingConn struct {
// that read their verdict block until one arrives, so a double that never
// answers turns every send into a 5-second timeout.
//
- // Set refuseCode to make the server refuse instead.
+ // Set refuseCode to make the server refuse instead. refuseTo narrows that
+ // to the aibot_send_msg frames addressed to one chatid, the way WeCom
+ // refuses a push into a 1:1 the user never opened while the room the
+ // trigger came from still takes the bot's frames.
sender *wsSender
refuseCode int
refuseMsg string
+ refuseTo string
// refuseFromSend and swallowAckFromSend act on aibot_send_msg frames
// only, counted 1-based, and are how a test refuses or loses the verdict
@@ -81,6 +95,15 @@ func (c *recordingConn) WriteMessage(_ int, data []byte) error {
c.frames = append(c.frames, env)
s := c.sender
code, msg := c.refuseCode, c.refuseMsg
+ if c.refuseTo != "" {
+ var body struct {
+ ChatID string `json:"chatid"`
+ }
+ _ = json.Unmarshal(env.Body, &body)
+ if env.Cmd != cmdSendMsg || body.ChatID != c.refuseTo {
+ code, msg = 0, ""
+ }
+ }
swallow := false
if env.Cmd == cmdSendMsg {
c.sends++
@@ -380,6 +403,123 @@ func TestSendBindingPrompt_ThrottledSendsNoURL(t *testing.T) {
}
}
+// groupMessage is an @-mention of the bot in a room by SENDER_USERID.
+func groupMessage() channel.InboundMessage {
+ return channel.InboundMessage{Source: channel.Source{
+ ChatID: "GROUP_CHAT_ID",
+ ChatType: channel.ChatTypeGroup,
+ SenderID: "SENDER_USERID",
+ }}
+}
+
+// TestSendBindingPrompt_AsksTheRoomWhenTheUserMustMessageFirst: a member who
+// has only ever @-mentioned the bot has no 1:1 WeCom will push into, so the
+// private link is refused with 846607. Before this the room heard nothing and
+// neither did they. The room now gets the token-less ask, and the refused link
+// is withdrawn so the message they send in the 1:1 gets a fresh one.
+func TestSendBindingPrompt_AsksTheRoomWhenTheUserMustMessageFirst(t *testing.T) {
+ t.Parallel()
+ const rawToken = "SECRET_BEARER_TOKEN_do_not_leak"
+ r, inst, conn := newReplierWithConn(t)
+ var withdrawn []string
+ r.binding = fakeBinder{raw: rawToken, withdrawn: &withdrawn}
+ conn.refuseTo, conn.refuseCode, conn.refuseMsg = "SENDER_USERID", errcodeUserMustMessageFirst, "aibot send msg frequency limit exceeded"
+
+ err := r.sendBindingPrompt(context.Background(), inst, groupMessage(), engine.Result{Sender: "SENDER_USERID"}, copyFor(DefaultLocale))
+ if !userMustMessageFirst(err) {
+ t.Fatalf("sendBindingPrompt error = %v, want the 846607 refusal reported", err)
+ }
+
+ frames := conn.sendFrames()
+ if len(frames) != 2 {
+ t.Fatalf("expected 2 frames (refused private link + room ask), got %d", len(frames))
+ }
+ room := conn.sendBody(t, 1)
+ if room["chatid"] != "GROUP_CHAT_ID" || room["chat_type"] != float64(chatTypeGroupInt) {
+ t.Fatalf("second frame = %v, want the room", room)
+ }
+ if got, want := sentMarkdown(t, conn, 1), copyFor(DefaultLocale).MessageMeFirst; got != want {
+ t.Fatalf("room line = %q, want %q", got, want)
+ }
+ if strings.Contains(sentMarkdown(t, conn, 1), rawToken) {
+ t.Fatal("SECURITY: the room line carries the raw token")
+ }
+ if len(withdrawn) != 1 || withdrawn[0] != rawToken {
+ t.Fatalf("withdrawn = %v, want the refused link withdrawn", withdrawn)
+ }
+}
+
+// TestSendBindingPrompt_OtherRefusalsStayOutOfTheRoom: asking the room to open
+// the 1:1, and withdrawing the link so that chat gets a fresh one, are the
+// answer to 846607 alone. Any other refusal leaves both as they were: the room
+// hears nothing and the throttle keeps the link, so a 45009 is not met with a
+// new mint per message.
+func TestSendBindingPrompt_OtherRefusalsStayOutOfTheRoom(t *testing.T) {
+ t.Parallel()
+ r, inst, conn := newReplierWithConn(t)
+ var withdrawn []string
+ r.binding = fakeBinder{raw: "RAW", withdrawn: &withdrawn}
+ conn.refuseTo, conn.refuseCode, conn.refuseMsg = "SENDER_USERID", 45002, "content exceed max length"
+
+ if err := r.sendBindingPrompt(context.Background(), inst, groupMessage(), engine.Result{Sender: "SENDER_USERID"}, copyFor(DefaultLocale)); err == nil {
+ t.Fatal("a refused private send must be reported")
+ }
+ if n := len(conn.sendFrames()); n != 1 {
+ t.Fatalf("expected only the refused private frame, got %d frames", n)
+ }
+ if len(withdrawn) != 0 {
+ t.Fatalf("withdrawn = %v, want nothing withdrawn for a refusal other than 846607", withdrawn)
+ }
+}
+
+// TestSendBindingPrompt_ThrottledRefusalWithdrawsNothing: a throttled prompt
+// carries no link, so there is no token to withdraw; the room still gets the
+// ask.
+func TestSendBindingPrompt_ThrottledRefusalWithdrawsNothing(t *testing.T) {
+ t.Parallel()
+ r, inst, conn := newReplierWithConn(t)
+ var withdrawn []string
+ r.binding = fakeBinder{reused: true, withdrawn: &withdrawn}
+ conn.refuseTo, conn.refuseCode = "SENDER_USERID", errcodeUserMustMessageFirst
+
+ _ = r.sendBindingPrompt(context.Background(), inst, groupMessage(), engine.Result{Sender: "SENDER_USERID"}, copyFor(DefaultLocale))
+ if len(withdrawn) != 0 {
+ t.Fatalf("withdrawn = %v, want nothing (no raw token exists)", withdrawn)
+ }
+ if got, want := sentMarkdown(t, conn, 1), copyFor(DefaultLocale).MessageMeFirst; got != want {
+ t.Fatalf("room line = %q, want %q", got, want)
+ }
+}
+
+// TestBindingLinkReachesTheUserWhoOpensTheChat runs the promise the room line
+// makes against the real throttle: after the refused @-mention, the user's
+// first message in the 1:1 — well inside BindingTokenMintInterval — gets a
+// link, not "I already sent you a link, it is just above".
+func TestBindingLinkReachesTheUserWhoOpensTheChat(t *testing.T) {
+ t.Parallel()
+ r, inst, conn := newReplierWithConn(t)
+ svc, _, _ := newThrottledService()
+ r.binding = svc
+ conn.refuseTo, conn.refuseCode = "SENDER_USERID", errcodeUserMustMessageFirst
+
+ _ = r.sendBindingPrompt(context.Background(), inst, groupMessage(), engine.Result{Sender: "SENDER_USERID"}, copyFor(DefaultLocale))
+
+ // They open the 1:1 and say hello; WeCom now takes pushes into it.
+ conn.mu.Lock()
+ conn.refuseTo, conn.refuseCode = "", 0
+ conn.mu.Unlock()
+ dm := channel.InboundMessage{Source: channel.Source{ChatID: "SENDER_USERID", ChatType: channel.ChatTypeP2P, SenderID: "SENDER_USERID"}}
+ if err := r.sendBindingPrompt(context.Background(), inst, dm, engine.Result{Sender: "SENDER_USERID"}, copyFor(DefaultLocale)); err != nil {
+ t.Fatalf("1:1 binding prompt: %v", err)
+ }
+
+ frames := conn.sendFrames()
+ got := sentMarkdown(t, conn, len(frames)-1)
+ if !strings.Contains(got, "https://multica.example/wecom/bind?token=") {
+ t.Fatalf("1:1 reply = %q, want a fresh bind link", got)
+ }
+}
+
// TestPost_HonoursTheCallersDeadline guards the budget the calling code
// already believed it had. Bus delivery is synchronous, so the reply path runs
// on the publishing goroutine; outbound.go and handleInboxNew each build a
diff --git a/server/internal/integrations/wecom/strings.go b/server/internal/integrations/wecom/strings.go
index bbbab48348..59c6d08fb8 100644
--- a/server/internal/integrations/wecom/strings.go
+++ b/server/internal/integrations/wecom/strings.go
@@ -157,6 +157,15 @@ type copyPack struct {
// audience of unknown size.
BindingSentPrivately string
+ // MessageMeFirst is what the ROOM sees when WeCom refused a private reply
+ // to a member because they have never written to the bot in their 1:1
+ // (replier.go, errcodeUserMustMessageFirst). Both the binding link and an
+ // invoke refusal end there, so it asks them to open that chat and promises
+ // the reply will be waiting: the next message they send there is handled
+ // like any other. Like BindingSentPrivately it names no one and carries no
+ // token, and it does not say what the reply is about.
+ MessageMeFirst string
+
// IssueCreatedPrefix leads the /issue confirmation; IssueTitleSeparator
// joins the identifier to the title when there is one.
IssueCreatedPrefix string
@@ -390,6 +399,7 @@ var copyPacks = map[Locale]copyPack{
BindingPromptSuffix: "\n(链接 15 分钟内有效)",
BindingPending: "👋 绑定链接刚才已经发给你了,就在上方,请直接点击完成绑定。",
BindingSentPrivately: "👋 已把绑定链接私发给你,请在与我的单聊里点击完成绑定。",
+ MessageMeFirst: "👋 请先私信我一句,我在那里回复你。",
IssueCreatedPrefix: "✅ 已创建 ",
IssueTitleSeparator: " — ",
@@ -467,6 +477,7 @@ var copyPacks = map[Locale]copyPack{
BindingPromptSuffix: "\n(the link is good for 15 minutes)",
BindingPending: "👋 I already sent you a link — it is just above, tap it to finish linking.",
BindingSentPrivately: "👋 I've sent the link to your direct chat with me — tap it there to finish linking.",
+ MessageMeFirst: "👋 Send me a direct message first, and I'll reply there.",
IssueCreatedPrefix: "✅ Created ",
IssueTitleSeparator: " — ",