diff --git a/internal/services/gateway/admin_channels_weixin.go b/internal/services/gateway/admin_channels_weixin.go index 124a132..11a36d4 100644 --- a/internal/services/gateway/admin_channels_weixin.go +++ b/internal/services/gateway/admin_channels_weixin.go @@ -174,6 +174,12 @@ func weixinAccountFor(caps CapabilityStore, platform, accountID string) (weixinL if caps == nil { return nil, false } + // A weixin adapter may be registered with the bare "weixin-ilink" name (single + // account) rather than "weixin-ilink:", so first try a composite match, and + // fall back to a bare weixin adapter when the caller names a specific account but + // no composite name carries it (the panel passes the config account id). + var bare weixinLoginAdmin + var bareFound bool for _, cap := range caps.List(capreg.KindChannel) { ch, ok := cap.Value.(sdk.Channel) if !ok { @@ -183,12 +189,19 @@ func weixinAccountFor(caps CapabilityStore, platform, accountID string) (weixinL if plat != platform { continue } - if accountID != "" && acct != accountID { + w, ok := asWeixinLoginAdmin(cap.Value) + if !ok { continue } - if w, ok := asWeixinLoginAdmin(cap.Value); ok { + if accountID == "" || acct == accountID { return w, true } + if acct == "" { + bare, bareFound = w, true + } + } + if bareFound { + return bare, true } return nil, false }