comparison mod_mam_muc/mod_mam_muc.lua @ 1382:ba17268490b7

mod_mam_muc: Fix to, from on result messages (thanks daurnimator)
author Kim Alvefur <zash@zash.se>
date Tue, 08 Apr 2014 17:28:08 +0200
parents 8be609f5610e
children da9469e68dee
comparison
equal deleted inserted replaced
1381:11b6170a50f7 1382:ba17268490b7
114 -- Handle archive queries 114 -- Handle archive queries
115 module:hook("iq-get/bare/"..xmlns_mam..":query", function(event) 115 module:hook("iq-get/bare/"..xmlns_mam..":query", function(event)
116 local origin, stanza = event.origin, event.stanza; 116 local origin, stanza = event.origin, event.stanza;
117 local room = stanza.attr.to; 117 local room = stanza.attr.to;
118 local room_node = jid_split(room); 118 local room_node = jid_split(room);
119 local orig_from = stanza.attr.from;
119 local query = stanza.tags[1]; 120 local query = stanza.tags[1];
120 121
121 local room_obj = rooms[room]; 122 local room_obj = rooms[room];
122 if not room_obj then 123 if not room_obj then
123 return origin.send(st.error_reply(stanza, "cancel", "item-not-found")) 124 return origin.send(st.error_reply(stanza, "cancel", "item-not-found"))
124 end 125 end
125 local from = jid_bare(stanza.attr.from); 126 local from = jid_bare(orig_from);
126 127
127 -- Banned or not a member of a members-only room? 128 -- Banned or not a member of a members-only room?
128 local from_affiliation = room_obj:get_affiliation(from); 129 local from_affiliation = room_obj:get_affiliation(from);
129 if from_affiliation == "outcast" -- banned 130 if from_affiliation == "outcast" -- banned
130 or room_obj:get_members_only() and not from_affiliation then -- members-only, not a member 131 or room_obj:get_members_only() and not from_affiliation then -- members-only, not a member
171 local count = err; 172 local count = err;
172 173
173 -- Wrap it in stuff and deliver 174 -- Wrap it in stuff and deliver
174 local first, last; 175 local first, last;
175 for id, item, when in data do 176 for id, item, when in data do
176 local fwd_st = st.message{ to = origin.full_jid } 177 local fwd_st = st.message{ to = orig_from, from = room }
177 :tag("result", { xmlns = xmlns_mam, queryid = qid, id = id }) 178 :tag("result", { xmlns = xmlns_mam, queryid = qid, id = id })
178 :tag("forwarded", { xmlns = xmlns_forward }) 179 :tag("forwarded", { xmlns = xmlns_forward })
179 :tag("delay", { xmlns = xmlns_delay, stamp = timestamp(when) }):up(); 180 :tag("delay", { xmlns = xmlns_delay, stamp = timestamp(when) }):up();
180 181
181 if not is_stanza(item) then 182 if not is_stanza(item) then