Mercurial > prosody-modules
comparison mod_debug_omemo/mod_debug_omemo.lua @ 4689:ecfffbbcbf42
mod_debug_omemo: Use archive single message retrieval method
Likely more efficient, where implemented.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 15 Sep 2021 17:55:58 +0200 |
| parents | 41ddb782320c |
| children |
comparison
equal
deleted
inserted
replaced
| 4688:05725276fac0 | 4689:ecfffbbcbf42 |
|---|---|
| 98 whitelist = "Private"; | 98 whitelist = "Private"; |
| 99 roster = "Contacts only"; | 99 roster = "Contacts only"; |
| 100 presence = "Contacts only"; | 100 presence = "Contacts only"; |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 local function get_message(username, message_id) | |
| 104 if mam.get then | |
| 105 return mam:get(username, message_id); | |
| 106 end | |
| 107 -- COMPAT | |
| 108 local message; | |
| 109 for _, result in mam:find(username, { key = message_id }) do | |
| 110 message = result; | |
| 111 end | |
| 112 return message; | |
| 113 end | |
| 114 | |
| 103 local function render_message(event, path) | 115 local function render_message(event, path) |
| 104 local username, message_id = path:match("^([^/]+)/(.+)$"); | 116 local username, message_id = path:match("^([^/]+)/(.+)$"); |
| 105 if not username then | 117 if not username then |
| 106 return 400; | 118 return 400; |
| 107 end | 119 end |
| 108 local message; | 120 local message = get_message(username, message_id); |
| 109 for _, result in mam:find(username, { key = message_id }) do | |
| 110 message = result; | |
| 111 end | |
| 112 if not message then | 121 if not message then |
| 113 return 404; | 122 return 404; |
| 114 end | 123 end |
| 115 | 124 |
| 116 local user_omemo_status = get_user_omemo_info(username); | 125 local user_omemo_status = get_user_omemo_info(username); |
