mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-16 15:17:14 +00:00
fix(clients): preserve enable on portable import (#6481)
* fix(clients): preserve enable on portable import Stop BulkCreate and orphan ImportClients from forcing enable=true, and restate Enable=false after GORM Create (clients.enable default:true drops the zero value). Interactive Create still defaults new clients to enabled. Fixes #6478. * fix(clients): respect enable=false on node mirror; omit enable defaults true --------- Co-authored-by: mrchatam <287639636+mrchatam@users.noreply.github.com>
This commit is contained in:
@@ -155,9 +155,7 @@ func (s *ClientService) ImportClients(inboundSvc *InboundService, items []Client
|
||||
continue
|
||||
}
|
||||
}
|
||||
if !client.Enable {
|
||||
client.Enable = true
|
||||
}
|
||||
// Preserve exported enable so a disabled orphan stays disabled (#6478).
|
||||
now := time.Now().UnixMilli()
|
||||
if client.CreatedAt == 0 {
|
||||
client.CreatedAt = now
|
||||
@@ -170,6 +168,13 @@ func (s *ClientService) ImportClients(inboundSvc *InboundService, items []Client
|
||||
skip(email, err.Error())
|
||||
continue
|
||||
}
|
||||
// gorm default:true drops enable=false on Create — restate (#6478).
|
||||
if !client.Enable {
|
||||
if err := db.Model(&model.ClientRecord{}).Where("id = ?", rec.Id).
|
||||
UpdateColumn("enable", false).Error; err != nil {
|
||||
return result, needRestart, err
|
||||
}
|
||||
}
|
||||
result.Created++
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user