diff options
| author | Ali Golzar <57574919+aliglzr@users.noreply.github.com> | 2025-08-31 19:33:50 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-31 19:33:50 +0300 |
| commit | 4a0914cb1e271ab4f076cb1bd68c9f07cc025e92 (patch) | |
| tree | 95a15ed4255736b0bc7edaa509951d62c9c0254a /web/service | |
| parent | 664269d513f4c122c9f5a713d3293777872d3353 (diff) | |
feat: add "Last Online" column to client list and modal (Closes #3402) (#3405)
* feat: persist client last online and expose API
* feat(ui): show client last online in table and info modal
* i18n: add “Last Online” across locales
* chore: format timestamps as HH:mm:ss
Diffstat (limited to 'web/service')
| -rw-r--r-- | web/service/inbound.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/web/service/inbound.go b/web/service/inbound.go index 0621cdea..b494d502 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -967,6 +967,7 @@ func (s *InboundService) addClientTraffic(tx *gorm.DB, traffics []*xray.ClientTr // Add user in onlineUsers array on traffic if traffics[traffic_index].Up+traffics[traffic_index].Down > 0 { onlineClients = append(onlineClients, traffics[traffic_index].Email) + dbClientTraffics[dbTraffic_index].LastOnline = time.Now().UnixMilli() } break } @@ -2187,6 +2188,20 @@ func (s *InboundService) GetOnlineClients() []string { return p.GetOnlineClients() } +func (s *InboundService) GetClientsLastOnline() (map[string]int64, error) { + db := database.GetDB() + var rows []xray.ClientTraffic + err := db.Model(&xray.ClientTraffic{}).Select("email, last_online").Find(&rows).Error + if err != nil && err != gorm.ErrRecordNotFound { + return nil, err + } + result := make(map[string]int64, len(rows)) + for _, r := range rows { + result[r.Email] = r.LastOnline + } + return result, nil +} + func (s *InboundService) FilterAndSortClientEmails(emails []string) ([]string, []string, error) { db := database.GetDB() |
