minor changes

Co-Authored-By: somebodywashere <68244480+somebodywashere@users.noreply.github.com>
This commit is contained in:
MHSanaei 2024-03-12 17:35:17 +03:30
parent 6fdc07a2d0
commit 903db95783
2 changed files with 9 additions and 40 deletions

View file

@ -425,7 +425,6 @@
this.loading(false); this.loading(false);
if (msg.success) { if (msg.success) {
this.user = {}; this.user = {};
window.location.replace;
} }
}, },
async restartPanel() { async restartPanel() {
@ -464,7 +463,6 @@
const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user); const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user);
if (msg && msg.obj) { if (msg && msg.obj) {
this.user = msg.obj; this.user = msg.obj;
window.location.replace;
} }
this.loading(false); this.loading(false);
await this.updateAllSetting(); await this.updateAllSetting();

View file

@ -1069,11 +1069,8 @@ func (s *InboundService) AddClientStat(tx *gorm.DB, inboundId int, client *model
clientTraffic.Reset = client.Reset clientTraffic.Reset = client.Reset
result := tx.Create(&clientTraffic) result := tx.Create(&clientTraffic)
err := result.Error err := result.Error
if err != nil {
return err return err
} }
return nil
}
func (s *InboundService) UpdateClientStat(tx *gorm.DB, email string, client *model.Client) error { func (s *InboundService) UpdateClientStat(tx *gorm.DB, email string, client *model.Client) error {
result := tx.Model(xray.ClientTraffic{}). result := tx.Model(xray.ClientTraffic{}).
@ -1085,13 +1082,9 @@ func (s *InboundService) UpdateClientStat(tx *gorm.DB, email string, client *mod
"expiry_time": client.ExpiryTime, "expiry_time": client.ExpiryTime,
"reset": client.Reset, "reset": client.Reset,
}) })
err := result.Error err := result.Error
if err != nil {
return err return err
} }
return nil
}
func (s *InboundService) UpdateClientIPs(tx *gorm.DB, oldEmail string, newEmail string) error { func (s *InboundService) UpdateClientIPs(tx *gorm.DB, oldEmail string, newEmail string) error {
return tx.Model(model.InboundClientIps{}).Where("client_email = ?", oldEmail).Update("client_email", newEmail).Error return tx.Model(model.InboundClientIps{}).Where("client_email = ?", oldEmail).Update("client_email", newEmail).Error
@ -1215,11 +1208,8 @@ func (s *InboundService) SetClientTelegramUserID(trafficId int, tgId string) err
} }
inbound.Settings = string(modifiedSettings) inbound.Settings = string(modifiedSettings)
_, err = s.UpdateInboundClient(inbound, clientId) _, err = s.UpdateInboundClient(inbound, clientId)
if err != nil {
return err return err
} }
return nil
}
func (s *InboundService) checkIsEnabledByEmail(clientEmail string) (bool, error) { func (s *InboundService) checkIsEnabledByEmail(clientEmail string) (bool, error) {
_, inbound, err := s.GetClientInboundByEmail(clientEmail) _, inbound, err := s.GetClientInboundByEmail(clientEmail)
@ -1365,11 +1355,8 @@ func (s *InboundService) ResetClientIpLimitByEmail(clientEmail string, count int
} }
inbound.Settings = string(modifiedSettings) inbound.Settings = string(modifiedSettings)
_, err = s.UpdateInboundClient(inbound, clientId) _, err = s.UpdateInboundClient(inbound, clientId)
if err != nil {
return err return err
} }
return nil
}
func (s *InboundService) ResetClientExpiryTimeByEmail(clientEmail string, expiry_time int64) error { func (s *InboundService) ResetClientExpiryTimeByEmail(clientEmail string, expiry_time int64) error {
_, inbound, err := s.GetClientInboundByEmail(clientEmail) _, inbound, err := s.GetClientInboundByEmail(clientEmail)
@ -1425,11 +1412,8 @@ func (s *InboundService) ResetClientExpiryTimeByEmail(clientEmail string, expiry
} }
inbound.Settings = string(modifiedSettings) inbound.Settings = string(modifiedSettings)
_, err = s.UpdateInboundClient(inbound, clientId) _, err = s.UpdateInboundClient(inbound, clientId)
if err != nil {
return err return err
} }
return nil
}
func (s *InboundService) ResetClientTrafficLimitByEmail(clientEmail string, totalGB int) error { func (s *InboundService) ResetClientTrafficLimitByEmail(clientEmail string, totalGB int) error {
if totalGB < 0 { if totalGB < 0 {
@ -1488,11 +1472,8 @@ func (s *InboundService) ResetClientTrafficLimitByEmail(clientEmail string, tota
} }
inbound.Settings = string(modifiedSettings) inbound.Settings = string(modifiedSettings)
_, err = s.UpdateInboundClient(inbound, clientId) _, err = s.UpdateInboundClient(inbound, clientId)
if err != nil {
return err return err
} }
return nil
}
func (s *InboundService) ResetClientTrafficByEmail(clientEmail string) error { func (s *InboundService) ResetClientTrafficByEmail(clientEmail string) error {
db := database.GetDB() db := database.GetDB()
@ -1584,11 +1565,8 @@ func (s *InboundService) ResetAllClientTraffics(id int) error {
Updates(map[string]interface{}{"enable": true, "up": 0, "down": 0}) Updates(map[string]interface{}{"enable": true, "up": 0, "down": 0})
err := result.Error err := result.Error
if err != nil {
return err return err
} }
return nil
}
func (s *InboundService) ResetAllTraffics() error { func (s *InboundService) ResetAllTraffics() error {
db := database.GetDB() db := database.GetDB()
@ -1598,11 +1576,8 @@ func (s *InboundService) ResetAllTraffics() error {
Updates(map[string]interface{}{"up": 0, "down": 0}) Updates(map[string]interface{}{"up": 0, "down": 0})
err := result.Error err := result.Error
if err != nil {
return err return err
} }
return nil
}
func (s *InboundService) DelDepletedClients(id int) (err error) { func (s *InboundService) DelDepletedClients(id int) (err error) {
db := database.GetDB() db := database.GetDB()
@ -1675,13 +1650,9 @@ func (s *InboundService) DelDepletedClients(id int) (err error) {
} }
err = tx.Where(whereText+" and enable = ?", id, false).Delete(xray.ClientTraffic{}).Error err = tx.Where(whereText+" and enable = ?", id, false).Delete(xray.ClientTraffic{}).Error
if err != nil {
return err return err
} }
return nil
}
func (s *InboundService) GetClientTrafficTgBot(tgId string) ([]*xray.ClientTraffic, error) { func (s *InboundService) GetClientTrafficTgBot(tgId string) ([]*xray.ClientTraffic, error) {
db := database.GetDB() db := database.GetDB()
var inbounds []*model.Inbound var inbounds []*model.Inbound