refactor: remove unused traffic reset logic and clean up client model fields

This commit is contained in:
egregors 2025-09-14 11:50:27 +02:00
parent b00de0a59b
commit 8cbbbeb5e8
No known key found for this signature in database
GPG key ID: 78C8DDCC8BB0494A
3 changed files with 15 additions and 64 deletions

View file

@ -100,8 +100,6 @@ type Client struct {
LimitIP int `json:"limitIp"`
TotalGB int64 `json:"totalGB" form:"totalGB"`
ExpiryTime int64 `json:"expiryTime" form:"expiryTime"`
TrafficReset string `json:"trafficReset" form:"trafficReset" gorm:"default:never"`
LastTrafficResetTime int64 `json:"lastTrafficResetTime" form:"lastTrafficResetTime" gorm:"default:0"`
Enable bool `json:"enable" form:"enable"`
TgID int64 `json:"tgId" form:"tgId"`
SubID string `json:"subId" form:"subId"`

View file

@ -237,12 +237,6 @@
</a-tooltip>
</td>
</tr>
<tr v-if="infoModal.clientSettings.trafficReset">
<td>{{ i18n "pages.inbounds.periodicTrafficResetTitle" }}</td>
<td>
<a-tag color="blue">[[ i18n("pages.inbounds.periodicTrafficReset." + infoModal.clientSettings.trafficReset) ]]</a-tag>
</td>
</tr>
<tr v-if="app.ipLimitEnable">
<td>{{ i18n "pages.inbounds.IPLimit" }}</td>
<td>

View file

@ -1706,47 +1706,6 @@ func (s *InboundService) ResetClientTrafficByEmail(clientEmail string) error {
return err
}
// Update lastTrafficResetTime in client settings
_, inbound, err := s.GetClientInboundByEmail(clientEmail)
if err != nil {
logger.Warning("Failed to get inbound for client", clientEmail, ":", err)
return nil // Don't fail the reset if we can't update the timestamp
}
if inbound != nil {
var settings map[string]any
err = json.Unmarshal([]byte(inbound.Settings), &settings)
if err != nil {
logger.Warning("Failed to parse inbound settings:", err)
return nil
}
clientsSettings := settings["clients"].([]any)
now := time.Now().Unix() * 1000
for client_index := range clientsSettings {
c := clientsSettings[client_index].(map[string]any)
if c["email"] == clientEmail {
c["lastTrafficResetTime"] = now
c["updated_at"] = now
break
}
}
settings["clients"] = clientsSettings
modifiedSettings, err := json.MarshalIndent(settings, "", " ")
if err != nil {
logger.Warning("Failed to marshal inbound settings:", err)
return nil
}
inbound.Settings = string(modifiedSettings)
err = db.Save(inbound).Error
if err != nil {
logger.Warning("Failed to save inbound with updated client settings:", err)
}
}
return nil
}