fix(weixin): 扫码登录端点兼容裸weixin适配器——accountId不再404
weixin 适配器可能注册为裸 `weixin-ilink`(单账号)而非 `weixin-ilink:<acct>`, weixinAccountFor
只认复合名导致 accountId=05487->404。修为: 按平台匹配 + 优先复合名 + 找不到时兜底用裸
weixin 适配器(面板传config账号id)。实测 accountId=05487 登录端点 200{idle}。build/test绿。
This commit is contained in:
1 parent
3f2c981cf8
commit
d3b0921491
1 file changed
+15
-2
@@ -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:<acct>", 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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user