Mercurial > prosody-modules
comparison mod_default_bookmarks/mod_default_bookmarks.lua @ 4978:4c8b66da4dec
mod_default_bookmarks: Bail on empty 'default_bookmarks' to fix traceback
Ipairs fails on nil if the option is unset
Thanks more666p0wer for reporting
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 25 Jul 2022 19:28:38 +0200 |
| parents | 62006f4022e9 |
| children | 8f77452abc59 |
comparison
equal
deleted
inserted
replaced
| 4977:3bd725430f40 | 4978:4c8b66da4dec |
|---|---|
| 78 module:log("debug", "Setting max_items=pep_max_items because 'max' is not supported in this version"); | 78 module:log("debug", "Setting max_items=pep_max_items because 'max' is not supported in this version"); |
| 79 publish_options["max_items"] = module:get_option_number("pep_max_items", 256); | 79 publish_options["max_items"] = module:get_option_number("pep_max_items", 256); |
| 80 end | 80 end |
| 81 local service = mod_pep.get_pep_service(session.username); | 81 local service = mod_pep.get_pep_service(session.username); |
| 82 local bookmarks = module:get_option_array("default_bookmarks"); | 82 local bookmarks = module:get_option_array("default_bookmarks"); |
| 83 if not bookmarks or #bookmarks == 0 then | |
| 84 return; | |
| 85 end | |
| 83 local ns = event.version or "urn:xmpp:bookmarks:1"; | 86 local ns = event.version or "urn:xmpp:bookmarks:1"; |
| 84 for i, bookmark in ipairs(bookmarks) do | 87 for i, bookmark in ipairs(bookmarks) do |
| 85 local bm_jid = jid.prep(bookmark.jid); | 88 local bm_jid = jid.prep(bookmark.jid); |
| 86 if not bm_jid then | 89 if not bm_jid then |
| 87 module:log("error", "Invalid JID in default_bookmarks[%d].jid = %q", i, bookmark.jid); | 90 module:log("error", "Invalid JID in default_bookmarks[%d].jid = %q", i, bookmark.jid); |
