Mercurial > prosody-modules
changeset 4858:727f147aac4d
mod_default_bookmarks: Minor refactor to do some checks earlier
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 08 Jan 2022 02:21:54 +0100 |
parents | 3f6711c1c66a |
children | 33208c3ae586 |
files | mod_default_bookmarks/mod_default_bookmarks.lua |
diffstat | 1 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_default_bookmarks/mod_default_bookmarks.lua Sat Jan 08 00:05:45 2022 +0100 +++ b/mod_default_bookmarks/mod_default_bookmarks.lua Sat Jan 08 02:21:54 2022 +0100 @@ -53,18 +53,18 @@ if mod_bookmarks_available then local mod_bookmarks = module:depends(mod_bookmarks_available); - local function on_bookmarks_empty(event) - local session = event.session; - if mod_bookmarks.publish_to_pep then + if mod_bookmarks.publish_to_pep then + local function on_bookmarks_empty(event) + local session = event.session; local bookmarks = get_default_bookmarks(session.username); if bookmarks then mod_bookmarks.publish_to_pep(session.full_jid, bookmarks); end - else - module:log("error", "Method for publishing legacy bookmarks not exposed by mod_bookmarks") end + module:hook("bookmarks/empty", on_bookmarks_empty); + else + module:log("error", "Method for publishing legacy bookmarks not exposed by mod_bookmarks") end - module:hook("bookmarks/empty", on_bookmarks_empty); else local function on_private_xml_get(event) local origin, stanza = event.origin, event.stanza;