Software / code / prosody-modules
Comparison
mod_client_management/mod_client_management.lua @ 5650:1571c280aaef
mod_client_management: Show timestamp of first client appearance
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 16 Aug 2023 11:17:28 +0200 |
| parent | 5607:c799b460f9f0 |
| child | 5668:f16edebb1305 |
comparison
equal
deleted
inserted
replaced
| 5649:f889ff779571 | 5650:1571c280aaef |
|---|---|
| 435 local clients = mod.get_active_clients(username); | 435 local clients = mod.get_active_clients(username); |
| 436 if not clients or #clients == 0 then | 436 if not clients or #clients == 0 then |
| 437 return true, "No clients associated with this account"; | 437 return true, "No clients associated with this account"; |
| 438 end | 438 end |
| 439 | 439 |
| 440 local function date_or_time(last_seen) | |
| 441 return last_seen and os.date(os.difftime(os.time(), last_seen) >= 86400 and "%Y-%m-%d" or "%H:%M:%S", last_seen); | |
| 442 end | |
| 443 | |
| 440 local colspec = { | 444 local colspec = { |
| 441 { title = "ID"; key = "id"; width = "1p" }; | 445 { title = "ID"; key = "id"; width = "1p" }; |
| 442 { | 446 { |
| 443 title = "Software"; | 447 title = "Software"; |
| 444 key = "user_agent"; | 448 key = "user_agent"; |
| 445 width = "1p"; | 449 width = "1p"; |
| 446 mapper = user_agent_tostring; | 450 mapper = user_agent_tostring; |
| 447 }; | 451 }; |
| 448 { | 452 { |
| 453 title = "First seen"; | |
| 454 key = "first_seen"; | |
| 455 width = math.max(#os.date("%Y-%m-%d"), #os.date("%H:%M:%S")); | |
| 456 align = "right"; | |
| 457 mapper = date_or_time; | |
| 458 }; | |
| 459 { | |
| 449 title = "Last seen"; | 460 title = "Last seen"; |
| 450 key = "last_seen"; | 461 key = "last_seen"; |
| 451 width = math.max(#os.date("%Y-%m-%d"), #os.date("%H:%M:%S")); | 462 width = math.max(#os.date("%Y-%m-%d"), #os.date("%H:%M:%S")); |
| 452 align = "right"; | 463 align = "right"; |
| 453 mapper = function(last_seen) | 464 mapper = date_or_time; |
| 454 return last_seen and os.date(os.difftime(os.time(), last_seen) >= 86400 and "%Y-%m-%d" or "%H:%M:%S", last_seen); | |
| 455 end; | |
| 456 }; | 465 }; |
| 457 { | 466 { |
| 458 title = "Authentication"; | 467 title = "Authentication"; |
| 459 key = "active"; | 468 key = "active"; |
| 460 width = "2p"; | 469 width = "2p"; |