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

@ -92,23 +92,21 @@ type Setting struct {
} }
type Client struct { type Client struct {
ID string `json:"id"` ID string `json:"id"`
Security string `json:"security"` Security string `json:"security"`
Password string `json:"password"` Password string `json:"password"`
Flow string `json:"flow"` Flow string `json:"flow"`
Email string `json:"email"` Email string `json:"email"`
LimitIP int `json:"limitIp"` LimitIP int `json:"limitIp"`
TotalGB int64 `json:"totalGB" form:"totalGB"` TotalGB int64 `json:"totalGB" form:"totalGB"`
ExpiryTime int64 `json:"expiryTime" form:"expiryTime"` ExpiryTime int64 `json:"expiryTime" form:"expiryTime"`
TrafficReset string `json:"trafficReset" form:"trafficReset" gorm:"default:never"` Enable bool `json:"enable" form:"enable"`
LastTrafficResetTime int64 `json:"lastTrafficResetTime" form:"lastTrafficResetTime" gorm:"default:0"` TgID int64 `json:"tgId" form:"tgId"`
Enable bool `json:"enable" form:"enable"` SubID string `json:"subId" form:"subId"`
TgID int64 `json:"tgId" form:"tgId"` Comment string `json:"comment" form:"comment"`
SubID string `json:"subId" form:"subId"` Reset int `json:"reset" form:"reset"`
Comment string `json:"comment" form:"comment"` CreatedAt int64 `json:"created_at,omitempty"`
Reset int `json:"reset" form:"reset"` UpdatedAt int64 `json:"updated_at,omitempty"`
CreatedAt int64 `json:"created_at,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"`
} }
type VLESSSettings struct { type VLESSSettings struct {

View file

@ -237,12 +237,6 @@
</a-tooltip> </a-tooltip>
</td> </td>
</tr> </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"> <tr v-if="app.ipLimitEnable">
<td>{{ i18n "pages.inbounds.IPLimit" }}</td> <td>{{ i18n "pages.inbounds.IPLimit" }}</td>
<td> <td>

View file

@ -1706,47 +1706,6 @@ func (s *InboundService) ResetClientTrafficByEmail(clientEmail string) error {
return err 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 return nil
} }