mirror of
https://github.com/alireza0/x-ui.git
synced 2026-03-21 00:05:49 +00:00
Fix Bug in deleting the client alireza0/x-ui#20
This commit is contained in:
@@ -258,28 +258,22 @@ func (s *InboundService) AddInboundClient(inbound *model.Inbound) error {
|
||||
return db.Save(oldInbound).Error
|
||||
}
|
||||
|
||||
func (s *InboundService) DelInboundClient(inboundId int, index int) error {
|
||||
oldInbound, err := s.GetInbound(inboundId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
settings := map[string][]model.Client{}
|
||||
json.Unmarshal([]byte(oldInbound.Settings), &settings)
|
||||
clients := settings["clients"]
|
||||
email := clients[index].Email
|
||||
settings["clients"] = append(clients[:index], clients[index+1:]...)
|
||||
|
||||
newSetting, err := json.Marshal(settings)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
oldInbound.Settings = string(newSetting)
|
||||
|
||||
func (s *InboundService) DelInboundClient(inbound *model.Inbound, email string) error {
|
||||
db := database.GetDB()
|
||||
err = s.DelClientStat(db, email)
|
||||
err := s.DelClientStat(db, email)
|
||||
if err != nil {
|
||||
logger.Error("Delete stats Data Error")
|
||||
return err
|
||||
}
|
||||
|
||||
oldInbound, err := s.GetInbound(inbound.Id)
|
||||
if err != nil {
|
||||
logger.Error("Load Old Data Error")
|
||||
return err
|
||||
}
|
||||
|
||||
oldInbound.Settings = inbound.Settings
|
||||
|
||||
return db.Save(oldInbound).Error
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user