Mercurial > prosody-modules
comparison mod_http_admin_api/mod_http_admin_api.lua @ 5781:cb25d341745f
mod_http_admin_api: Return avatar metadata from get_user_info()
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 07 Dec 2023 15:30:01 +0000 |
parents | 6ab9e1763f35 |
children | 5621dece3ee4 |
comparison
equal
deleted
inserted
replaced
5780:f199bff16f1f | 5781:cb25d341745f |
---|---|
173 return 404; | 173 return 404; |
174 end | 174 end |
175 return 200; | 175 return 200; |
176 end | 176 end |
177 | 177 |
178 local function get_user_avatar_info(username) | |
179 local pep_service = mod_pep.get_pep_service(username); | |
180 local ok, _, avatar_item = pep_service:get_last_item("urn:xmpp:avatar:metadata", true); | |
181 avatar_item = avatar_item and avatar_item:get_child("metadata", "urn:xmpp:avatar:metadata"); | |
182 if not ok or not avatar_item then return; end | |
183 | |
184 local avatar_info = {}; | |
185 | |
186 for avatar in avatar_item:childtags("info") do | |
187 table.insert(avatar_info, { | |
188 bytes = tonumber(avatar.attr.bytes); | |
189 hash = avatar.attr.id; | |
190 type = avatar.attr.type; | |
191 width = tonumber(avatar.attr.width); | |
192 height = tonumber(avatar.attr.height); | |
193 }); | |
194 end | |
195 | |
196 return avatar_info; | |
197 end | |
198 | |
178 local function get_user_info(username) | 199 local function get_user_info(username) |
179 if not usermanager.user_exists(username, module.host) then | 200 if not usermanager.user_exists(username, module.host) then |
180 return nil; | 201 return nil; |
181 end | 202 end |
182 local display_name; | 203 local display_name; |
212 secondary_roles = secondary_roles; | 233 secondary_roles = secondary_roles; |
213 roles = legacy_roles; -- COMPAT w/0.12 | 234 roles = legacy_roles; -- COMPAT w/0.12 |
214 enabled = enabled; | 235 enabled = enabled; |
215 last_active = mod_lastlog2.get_last_active(username); | 236 last_active = mod_lastlog2.get_last_active(username); |
216 deletion_request = deleted_users:get(username); | 237 deletion_request = deleted_users:get(username); |
238 avatar_info = get_user_avatar_info(username); | |
217 }; | 239 }; |
218 end | 240 end |
219 | 241 |
220 local function get_session_debug_info(session) | 242 local function get_session_debug_info(session) |
221 local info = { | 243 local info = { |