mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-29 14:37:13 +00:00
feat(sub): expose last subscription fetch time (#6217)
* feat(sub): expose last subscription fetch time Record successful GET subscription fetches per client and surface the timestamp in the client API and UI. * fix(frontend): include last subscription fetch in client traffic * Update sub_fetch_test.go --------- Co-authored-by: Hermes Agent <hermes-agent@localhost>
This commit is contained in:
@@ -273,6 +273,16 @@ func (s *SubService) matchingClients(inbound *model.Inbound, subId string) []mod
|
||||
return out
|
||||
}
|
||||
|
||||
// RecordSubscriptionFetch records a successful subscription response for all clients sharing subId.
|
||||
func (s *SubService) RecordSubscriptionFetch(subId string) error {
|
||||
if strings.TrimSpace(subId) == "" {
|
||||
return nil
|
||||
}
|
||||
return database.GetDB().Model(&xray.ClientTraffic{}).
|
||||
Where("email IN (SELECT email FROM clients WHERE sub_id = ?)", subId).
|
||||
Update("last_sub_fetch", time.Now().UnixMilli()).Error
|
||||
}
|
||||
|
||||
// GetSubs retrieves subscription links for a given subscription ID and host.
|
||||
func (s *SubService) GetSubs(subId string, host string) ([]string, []string, int64, xray.ClientTraffic, error) {
|
||||
return s.ForRequest(host).getSubs(subId)
|
||||
|
||||
Reference in New Issue
Block a user