Mercurial > prosody-modules
annotate mod_archive/mod_archive.lua @ 178:62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
author | shinysky<shinysky1986(AT)gmail.com> |
---|---|
date | Mon, 14 Jun 2010 22:13:33 +0800 |
parents | ac826882a8cf |
children | 43d9e0944276 |
rev | line source |
---|---|
157
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
1 -- Prosody IM |
159
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
2 -- Copyright (C) 2010 Dai Zhiwei |
157
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
3 -- |
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
4 -- This project is MIT/X11 licensed. Please see the |
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
5 -- COPYING file in the source package for more information. |
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
6 -- |
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
7 |
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
8 local st = require "util.stanza"; |
165
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
9 local dm = require "util.datamanager"; |
178
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
10 local jid = require "util.jid"; |
165
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
11 |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
12 local PREFS_DIR = "archive_prefs"; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
13 local ARCHIVE_DIR = "archive"; |
157
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
14 |
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
15 module:add_feature("urn:xmpp:archive"); |
159
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
16 module:add_feature("urn:xmpp:archive:auto"); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
17 module:add_feature("urn:xmpp:archive:manage"); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
18 module:add_feature("urn:xmpp:archive:manual"); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
19 module:add_feature("urn:xmpp:archive:pref"); |
157
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
20 |
165
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
21 ------------------------------------------------------------ |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
22 -- Utils |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
23 ------------------------------------------------------------ |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
24 local function load_prefs(node, host, dir) |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
25 return st.deserialize(dm.load(node, host, dir or PREFS_DIR)); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
26 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
27 |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
28 local function store_prefs(data, node, host, dir) |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
29 dm.store(node, host, dir or PREFS_DIR, st.preserialize(data)); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
30 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
31 |
178
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
32 local function store_msg(data, node, host, dir) |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
33 dm.list_append(node, host, dir or ARCHIVE_DIR, st.preserialize(data)); |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
34 end |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
35 |
165
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
36 ------------------------------------------------------------ |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
37 -- Preferences |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
38 ------------------------------------------------------------ |
157
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
39 local function preferences_handler(event) |
165
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
40 local origin, stanza = event.origin, event.stanza; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
41 module:log("debug", "-- Enter preferences_handler()"); |
159
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
42 module:log("debug", "-- pref:\n%s", tostring(stanza)); |
165
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
43 if stanza.attr.type == "get" then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
44 local data = load_prefs(origin.username, origin.host); |
159
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
45 if data then |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
46 origin.send(st.reply(stanza):add_child(data)); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
47 else |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
48 local reply = st.reply(stanza):tag('pref', {xmlns='urn:xmpp:archive'}); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
49 reply:tag('default', {otr='concede', save='false', unset='true'}):up(); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
50 reply:tag('method', {type='auto', use='concede'}):up(); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
51 reply:tag('method', {type='local', use='concede'}):up(); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
52 reply:tag('method', {type='manual', use='concede'}):up(); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
53 reply:tag('auto', {save='false'}):up(); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
54 origin.send(reply); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
55 end |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
56 elseif stanza.attr.type == "set" then |
165
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
57 local node, host = origin.username, origin.host; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
58 local data = load_prefs(node, host); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
59 if not data then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
60 data = st.stanza('pref', {xmlns='urn:xmpp:archive'}); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
61 data:tag('default', {otr='concede', save='false'}):up(); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
62 data:tag('method', {type='auto', use='concede'}):up(); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
63 data:tag('method', {type='local', use='concede'}):up(); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
64 data:tag('method', {type='manual', use='concede'}):up(); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
65 data:tag('auto', {save='false'}):up(); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
66 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
67 local elem = stanza.tags[1].tags[1]; -- iq:pref:xxx |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
68 if not elem then return false end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
69 -- "default" | "item" | "session" | "method" |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
70 -- FIXME there may be many item/session/method sections!! |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
71 elem.attr["xmlns"] = nil; -- TODO why there is an extra xmlns attr? |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
72 if elem.name == "default" then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
73 local setting = data:child_with_name(elem.name) |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
74 for k, v in pairs(elem.attr) do |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
75 setting.attr[k] = v; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
76 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
77 -- setting.attr["unset"] = nil |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
78 elseif elem.name == "item" then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
79 local found = false; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
80 for child in data:children() do |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
81 -- TODO bare JID or full JID? |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
82 if child.name == elem.name and child.attr["jid"] == elem.attr["jid"] then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
83 for k, v in pairs(elem.attr) do |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
84 child.attr[k] = v; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
85 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
86 found = true; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
87 break; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
88 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
89 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
90 if not found then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
91 data:tag(elem.name, elem.attr):up(); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
92 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
93 elseif elem.name == "session" then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
94 local found = false; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
95 for child in data:children() do |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
96 if child.name == elem.name and child.attr["thread"] == elem.attr["thread"] then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
97 for k, v in pairs(elem.attr) do |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
98 child.attr[k] = v; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
99 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
100 found = true; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
101 break; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
102 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
103 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
104 if not found then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
105 data:tag(elem.name, elem.attr):up(); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
106 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
107 elseif elem.name == "method" then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
108 local newpref = stanza.tags[1]; -- iq:pref |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
109 for _, e in ipairs(newpref.tags) do |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
110 -- if e.name ~= "method" then continue end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
111 local found = false; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
112 for child in data:children() do |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
113 if child.name == "method" and child.attr["type"] == e.attr["type"] then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
114 child.attr["use"] = e.attr["use"]; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
115 found = true; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
116 break; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
117 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
118 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
119 if not found then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
120 data:tag(e.name, e.attr):up(); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
121 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
122 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
123 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
124 store_prefs(data, node, host); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
125 origin.send(st.reply(stanza)); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
126 local user = bare_sessions[node.."@"..host]; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
127 local push = st.iq({type="set"}); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
128 push = push:tag('pref', {xmlns='urn:xmpp:archive'}); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
129 if elem.name == "method" then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
130 for child in data:children() do |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
131 if child.name == "method" then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
132 push:add_child(child); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
133 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
134 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
135 else |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
136 push:add_child(elem); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
137 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
138 push = push:up(); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
139 for _, res in pairs(user and user.sessions or NULL) do -- broadcast to all resources |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
140 if res.presence then -- to resource |
172
ac826882a8cf
mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
shinysky<shinysky1986(AT)gmail.com>
parents:
165
diff
changeset
|
141 push.attr.to = res.full_jid; |
165
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
142 res.send(push); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
143 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
144 end |
159
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
145 end |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
146 return true; |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
147 end |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
148 |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
149 local function itemremove_handler(event) |
165
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
150 local origin, stanza = event.origin, event.stanza; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
151 if stanza.attr.type ~= "set" then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
152 return false; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
153 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
154 local elem = stanza.tags[1].tags[1]; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
155 if not elem or elem.name ~= "item" then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
156 return false; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
157 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
158 local node, host = origin.username, origin.host; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
159 local data = load_prefs(node, host); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
160 if not data then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
161 return false; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
162 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
163 for i, child in ipairs(data) do |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
164 if child.name == "item" and child.attr["jid"] == elem.attr["jid"] then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
165 table.remove(data, i) |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
166 break; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
167 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
168 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
169 store_prefs(data, node, host); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
170 origin.send(st.reply(stanza)); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
171 return true; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
172 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
173 |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
174 local function sessionremove_handler(event) |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
175 local origin, stanza = event.origin, event.stanza; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
176 if stanza.attr.type ~= "set" then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
177 return false; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
178 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
179 local elem = stanza.tags[1].tags[1]; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
180 if not elem or elem.name ~= "session" then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
181 return false; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
182 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
183 local node, host = origin.username, origin.host; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
184 local data = load_prefs(node, host); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
185 if not data then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
186 return false; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
187 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
188 for i, child in ipairs(data) do |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
189 if child.name == "session" and child.attr["thread"] == elem.attr["thread"] then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
190 table.remove(data, i) |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
191 break; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
192 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
193 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
194 store_prefs(data, node, host); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
195 origin.send(st.reply(stanza)); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
196 return true; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
197 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
198 |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
199 local function auto_handler(event) |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
200 -- event.origin.send(st.error_reply(event.stanza, "cancel", "feature-not-implemented")); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
201 local origin, stanza = event.origin, event.stanza; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
202 if stanza.attr.type ~= "set" then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
203 return false; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
204 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
205 local elem = stanza.tags[1]; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
206 local node, host = origin.username, origin.host; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
207 local data = load_prefs(node, host); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
208 if not data then |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
209 return false; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
210 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
211 local setting = data:child_with_name(elem.name) |
172
ac826882a8cf
mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
shinysky<shinysky1986(AT)gmail.com>
parents:
165
diff
changeset
|
212 for k, v in pairs(elem.attr) do |
ac826882a8cf
mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
shinysky<shinysky1986(AT)gmail.com>
parents:
165
diff
changeset
|
213 setting.attr[k] = v; |
ac826882a8cf
mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
shinysky<shinysky1986(AT)gmail.com>
parents:
165
diff
changeset
|
214 end |
165
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
215 store_prefs(data, node, host); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
216 origin.send(st.reply(stanza)); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
217 return true; |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
218 end |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
219 |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
220 local function chat_handler(event) |
159
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
221 module:log("debug", "-- stanza:\n%s", tostring(event.stanza)); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
222 return true; |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
223 end |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
224 |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
225 local function list_handler(event) |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
226 module:log("debug", "-- stanza:\n%s", tostring(event.stanza)); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
227 return true; |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
228 end |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
229 |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
230 local function modified_handler(event) |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
231 module:log("debug", "-- stanza:\n%s", tostring(event.stanza)); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
232 return true; |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
233 end |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
234 |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
235 local function remove_handler(event) |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
236 module:log("debug", "-- stanza:\n%s", tostring(event.stanza)); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
237 return true; |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
238 end |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
239 |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
240 local function retrieve_handler(event) |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
241 module:log("debug", "-- stanza:\n%s", tostring(event.stanza)); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
242 return true; |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
243 end |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
244 |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
245 local function save_handler(event) |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
246 module:log("debug", "-- stanza:\n%s", tostring(event.stanza)); |
157
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
247 return true; |
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
248 end |
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
249 |
178
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
250 ------------------------------------------------------------ |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
251 -- Message Handler |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
252 ------------------------------------------------------------ |
172
ac826882a8cf
mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
shinysky<shinysky1986(AT)gmail.com>
parents:
165
diff
changeset
|
253 local function msg_handler(data) |
ac826882a8cf
mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
shinysky<shinysky1986(AT)gmail.com>
parents:
165
diff
changeset
|
254 module:log("debug", "-- Enter msg_handler()"); |
ac826882a8cf
mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
shinysky<shinysky1986(AT)gmail.com>
parents:
165
diff
changeset
|
255 local origin, stanza = data.origin, data.stanza; |
178
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
256 local body = stanza:child_with_name("body"); |
172
ac826882a8cf
mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
shinysky<shinysky1986(AT)gmail.com>
parents:
165
diff
changeset
|
257 module:log("debug", "-- msg:\n%s", tostring(stanza)); |
178
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
258 if body then |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
259 module:log("debug", "-- msg body:\n%s", tostring(body)); |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
260 -- module:log("debug", "-- msg body text:\n%s", body:get_text()); |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
261 local from_node, from_host = jid.split(stanza.attr.from); |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
262 local to_node, to_host = jid.split(stanza.attr.to); |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
263 -- FIXME the format of collections |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
264 if from_host == "localhost" then -- FIXME only archive messages of users on this host |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
265 store_msg(stanza, from_node, from_host); |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
266 end |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
267 if to_host == "localhost" then |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
268 store_msg(stanza, to_node, to_host); |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
269 end |
62f47a93b5b7
mod_archive: Now we can archive messages, even though not in organized way.
shinysky<shinysky1986(AT)gmail.com>
parents:
172
diff
changeset
|
270 end |
172
ac826882a8cf
mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
shinysky<shinysky1986(AT)gmail.com>
parents:
165
diff
changeset
|
271 return nil; |
ac826882a8cf
mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
shinysky<shinysky1986(AT)gmail.com>
parents:
165
diff
changeset
|
272 end |
ac826882a8cf
mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
shinysky<shinysky1986(AT)gmail.com>
parents:
165
diff
changeset
|
273 |
157
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
274 module:hook("iq/self/urn:xmpp:archive:pref", preferences_handler); |
165
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
275 module:hook("iq/self/urn:xmpp:archive:itemremove", itemremove_handler); |
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
276 module:hook("iq/self/urn:xmpp:archive:sessionremove", sessionremove_handler); |
159
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
277 module:hook("iq/self/urn:xmpp:archive:auto", auto_handler); |
165
fd8d76daad97
mod_archive: preference handling is done.
shinysky<shinysky1986(AT)gmail.com>
parents:
159
diff
changeset
|
278 -- module:hook("iq/self/urn:xmpp:archive:chat", chat_handler); |
159
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
279 module:hook("iq/self/urn:xmpp:archive:list", list_handler); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
280 module:hook("iq/self/urn:xmpp:archive:modified", modified_handler); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
281 module:hook("iq/self/urn:xmpp:archive:remove", remove_handler); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
282 module:hook("iq/self/urn:xmpp:archive:retrieve", retrieve_handler); |
9a37898f4f7c
mod_archive: Added features: Determining Server Support & Determining Preferences
shinysky<shinysky1986(AT)gmail.com>
parents:
157
diff
changeset
|
283 module:hook("iq/self/urn:xmpp:archive:save", save_handler); |
157
86c28405c5da
initial commitment of mod_archive
shinysky<shinysky1986(AT)gmail.com>
parents:
diff
changeset
|
284 |
172
ac826882a8cf
mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
shinysky<shinysky1986(AT)gmail.com>
parents:
165
diff
changeset
|
285 module:hook("message/full", msg_handler, 10); |
ac826882a8cf
mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
shinysky<shinysky1986(AT)gmail.com>
parents:
165
diff
changeset
|
286 module:hook("message/bare", msg_handler, 10); |
ac826882a8cf
mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
shinysky<shinysky1986(AT)gmail.com>
parents:
165
diff
changeset
|
287 |