Mercurial > prosody-modules
comparison mod_sift/mod_sift.lua @ 1343:7dbde05b48a9
all the things: Remove trailing whitespace
| author | Florian Zeitz <florob@babelmonkeys.de> |
|---|---|
| date | Tue, 11 Mar 2014 18:44:01 +0100 |
| parents | f37de7e2ad14 |
| children |
comparison
equal
deleted
inserted
replaced
| 1342:0ae065453dc9 | 1343:7dbde05b48a9 |
|---|---|
| 54 -- handle SIFT set | 54 -- handle SIFT set |
| 55 module:hook("iq/self/urn:xmpp:sift:1:sift", function(event) | 55 module:hook("iq/self/urn:xmpp:sift:1:sift", function(event) |
| 56 local origin, stanza = event.origin, event.stanza; | 56 local origin, stanza = event.origin, event.stanza; |
| 57 if stanza.attr.type == "set" then | 57 if stanza.attr.type == "set" then |
| 58 local sifttag = stanza.tags[1]; -- <sift/> | 58 local sifttag = stanza.tags[1]; -- <sift/> |
| 59 | 59 |
| 60 -- first, get the elements we are interested in | 60 -- first, get the elements we are interested in |
| 61 local message = sifttag:get_child("message"); | 61 local message = sifttag:get_child("message"); |
| 62 local presence = sifttag:get_child("presence"); | 62 local presence = sifttag:get_child("presence"); |
| 63 local iq = sifttag:get_child("iq"); | 63 local iq = sifttag:get_child("iq"); |
| 64 | 64 |
| 65 -- for quick lookup, convert the elements into hashtables | 65 -- for quick lookup, convert the elements into hashtables |
| 66 message = to_hashtable(message); | 66 message = to_hashtable(message); |
| 67 presence = to_hashtable(presence); | 67 presence = to_hashtable(presence); |
| 68 iq = to_hashtable(iq); | 68 iq = to_hashtable(iq); |
| 69 | 69 |
| 70 -- make sure elements were valid | 70 -- make sure elements were valid |
| 71 if message == false or presence == false or iq == false then | 71 if message == false or presence == false or iq == false then |
| 72 origin.send(st.error_reply(stanza, "modify", "bad-request")); | 72 origin.send(st.error_reply(stanza, "modify", "bad-request")); |
| 73 return true; | 73 return true; |
| 74 end | 74 end |
| 75 | 75 |
| 76 local existing = data[origin.full_jid] or {}; -- get existing data, if any | 76 local existing = data[origin.full_jid] or {}; -- get existing data, if any |
| 77 data[origin.full_jid] = { presence = presence, message = message, iq = iq }; -- store new data | 77 data[origin.full_jid] = { presence = presence, message = message, iq = iq }; -- store new data |
| 78 | 78 |
| 79 origin.send(st.reply(stanza)); -- send back IQ result | 79 origin.send(st.reply(stanza)); -- send back IQ result |
| 80 | 80 |
| 81 if not existing.presence and not origin.presence and presence then | 81 if not existing.presence and not origin.presence and presence then |
| 82 -- TODO send probes | 82 -- TODO send probes |
| 83 end | 83 end |
| 84 return true; | 84 return true; |
| 85 end | 85 end |
