Software /
code /
prosody
Comparison
plugins/mod_mam/mod_mam.lua @ 8538:3eb4cafb3b64
mod_mam: Implement option to enable MAM implicitly when client support is detected (#867)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 21 Feb 2018 21:02:16 +0100 |
parent | 8252:63e505578d4f |
child | 8575:5040c8ce32dd |
comparison
equal
deleted
inserted
replaced
8517:980d2daf3ed4 | 8538:3eb4cafb3b64 |
---|---|
74 if not ok then | 74 if not ok then |
75 origin.send(st.error_reply(stanza, "cancel", "internal-server-error", "Error storing preferences: "..tostring(err))); | 75 origin.send(st.error_reply(stanza, "cancel", "internal-server-error", "Error storing preferences: "..tostring(err))); |
76 return true; | 76 return true; |
77 end | 77 end |
78 end | 78 end |
79 local prefs = prefs_to_stanza(get_prefs(user)); | 79 local prefs = prefs_to_stanza(get_prefs(user, true)); |
80 local reply = st.reply(stanza):add_child(prefs); | 80 local reply = st.reply(stanza):add_child(prefs); |
81 origin.send(reply); | 81 origin.send(reply); |
82 return true; | 82 return true; |
83 end); | 83 end); |
84 | 84 |
90 }; | 90 }; |
91 | 91 |
92 -- Serve form | 92 -- Serve form |
93 module:hook("iq-get/self/"..xmlns_mam..":query", function(event) | 93 module:hook("iq-get/self/"..xmlns_mam..":query", function(event) |
94 local origin, stanza = event.origin, event.stanza; | 94 local origin, stanza = event.origin, event.stanza; |
95 get_prefs(origin.username, true); | |
95 origin.send(st.reply(stanza):query(xmlns_mam):add_child(query_form:form())); | 96 origin.send(st.reply(stanza):query(xmlns_mam):add_child(query_form:form())); |
96 return true; | 97 return true; |
97 end); | 98 end); |
98 | 99 |
99 -- Handle archive queries | 100 -- Handle archive queries |
100 module:hook("iq-set/self/"..xmlns_mam..":query", function(event) | 101 module:hook("iq-set/self/"..xmlns_mam..":query", function(event) |
101 local origin, stanza = event.origin, event.stanza; | 102 local origin, stanza = event.origin, event.stanza; |
102 local query = stanza.tags[1]; | 103 local query = stanza.tags[1]; |
103 local qid = query.attr.queryid; | 104 local qid = query.attr.queryid; |
104 | 105 |
106 get_prefs(origin.username, true); | |
105 schedule_cleanup(origin.username); | 107 schedule_cleanup(origin.username); |
106 | 108 |
107 -- Search query parameters | 109 -- Search query parameters |
108 local qwith, qstart, qend; | 110 local qwith, qstart, qend; |
109 local form = query:get_child("x", "jabber:x:data"); | 111 local form = query:get_child("x", "jabber:x:data"); |