# HG changeset patch # User Matthew Wild # Date 1701864852 0 # Node ID 4c3216d9b1182bcc9dca2684de3ee8cb402113d8 # Parent 7b722955c59b8460bc0b31ab06b3bd4190c6e6b3 mod_http_admin_api: Include user account status and activity in get_user_info diff -r 7b722955c59b -r 4c3216d9b118 mod_http_admin_api/mod_http_admin_api.lua --- a/mod_http_admin_api/mod_http_admin_api.lua Wed Dec 06 12:12:37 2023 +0000 +++ b/mod_http_admin_api/mod_http_admin_api.lua Wed Dec 06 12:14:12 2023 +0000 @@ -14,6 +14,7 @@ local tokens = module:depends("tokenauth"); local mod_pep = module:depends("pep"); local mod_groups = module:depends("groups_internal"); +local mod_lastlog2 = module:depends("lastlog2"); local push_errors = module:shared("cloud_notify/push_errors"); @@ -28,6 +29,8 @@ local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; local xmlns_nick = "http://jabber.org/protocol/nick"; +assert(mod_lastlog2.get_last_active, "Newer version of mod_lastlog2 is required to use this module"); + local function check_credentials(request) local auth_type, auth_data = string.match(request.headers.authorization or "", "^(%S+)%s(.+)$"); if not (auth_type and auth_data) then @@ -195,12 +198,19 @@ end end + local enabled = true; -- Assume all enabled if on a version without is_enabled + if usermanager.user_is_enabled then + enabled = usermanager.user_is_enabled(username, module.host); + end + return { username = username; display_name = display_name; role = primary_role and primary_role.name or nil; secondary_roles = secondary_roles; roles = legacy_roles; -- COMPAT w/0.12 + enabled = enabled; + last_active = mod_lastlog2.get_last_active(username); }; end