feat: heal dead sync channels and block deleting system default (Z12h)
Ensure default channel and rebind Agent/Binding on list, ticket, agents/me, and ensure-binding so SyncPage does not stay on deleted-channel errors. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"aijianzhan/platform/internal/authx"
|
||||
"aijianzhan/platform/internal/dbsync"
|
||||
"aijianzhan/platform/internal/logic/applogic"
|
||||
"aijianzhan/platform/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
@@ -16,8 +17,11 @@ func syncBindingsListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
if !requireDBSync(svcCtx, w) {
|
||||
return
|
||||
}
|
||||
localID := r.URL.Query().Get("local_database_id")
|
||||
tid := syncTenantID(r)
|
||||
if _, err := applogic.HealTenantSyncBind(r.Context(), svcCtx, tid); err != nil {
|
||||
_ = err
|
||||
}
|
||||
localID := r.URL.Query().Get("local_database_id")
|
||||
var (
|
||||
list []dbsync.Binding
|
||||
err error
|
||||
@@ -74,6 +78,18 @@ func syncBindingsEnsureHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
}
|
||||
// Z12h-2:通道空/已删 → 静默挂回公司默认同步
|
||||
needHeal := body.ChannelID == ""
|
||||
if !needHeal {
|
||||
if _, e := svcCtx.DBSync.Store().GetChannelForTenant(body.ChannelID, body.TenantID); e != nil {
|
||||
needHeal = true
|
||||
}
|
||||
}
|
||||
if needHeal {
|
||||
if healed, hErr := applogic.HealTenantSyncBind(r.Context(), svcCtx, body.TenantID); hErr == nil && healed != nil && healed.ChannelID != "" {
|
||||
body.ChannelID = healed.ChannelID
|
||||
}
|
||||
}
|
||||
saved, err := svcCtx.DBSync.Store().EnsureBinding(body)
|
||||
if err != nil {
|
||||
authx.WriteError(w, http.StatusBadRequest, err.Error())
|
||||
|
||||
Reference in New Issue
Block a user