Mercurial > prosody-modules
annotate mod_mam/mod_mam.lua @ 1681:d20cfc5ba827
mod_mam: Always return true when a stanza event has been handled
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 03 May 2015 13:20:04 +0200 |
parents | 9ee56cc1be2c |
children | 6b2122630b92 |
rev | line source |
---|---|
635 | 1 -- XEP-0313: Message Archive Management for Prosody |
1400
ce5e397a7768
mod_mam: Update copyright header
Kim Alvefur <zash@zash.se>
parents:
1399
diff
changeset
|
2 -- Copyright (C) 2011-2014 Kim Alvefur |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 -- |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 -- This file is MIT/X11 licensed. |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 |
1484
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
6 local xmlns_mam = "urn:xmpp:mam:0"; |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
7 local xmlns_delay = "urn:xmpp:delay"; |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
8 local xmlns_forward = "urn:xmpp:forward:0"; |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
9 |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 local st = require "util.stanza"; |
701
cc5805f83583
mod_mam: Implement support for Result Set Management in queries.
Kim Alvefur <zash@zash.se>
parents:
675
diff
changeset
|
11 local rsm = module:require "rsm"; |
1399 | 12 local get_prefs = module:require"mamprefs".get; |
13 local set_prefs = module:require"mamprefs".set; | |
14 local prefs_to_stanza = module:require"mamprefsxml".tostanza; | |
15 local prefs_from_stanza = module:require"mamprefsxml".fromstanza; | |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 local jid_bare = require "util.jid".bare; |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 local jid_split = require "util.jid".split; |
1484
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
18 local dataform = require "util.dataforms".new; |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
19 local host = module.host; |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
20 |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
21 local rm_load_roster = require "core.rostermanager".load_roster; |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
22 |
1116
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
23 local getmetatable = getmetatable; |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
24 local function is_stanza(x) |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
25 return getmetatable(x) == st.stanza_mt; |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
26 end |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
27 |
672
8ae5317ba032
mod_mam: local tostring and some comments
Kim Alvefur <zash@zash.se>
parents:
671
diff
changeset
|
28 local tostring = tostring; |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 local time_now = os.time; |
707 | 30 local m_min = math.min; |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 local timestamp, timestamp_parse = require "util.datetime".datetime, require "util.datetime".parse; |
706
5c2b96c4dde6
mod_mam: Enforce a max number of items returned, with a default.
Kim Alvefur <zash@zash.se>
parents:
705
diff
changeset
|
32 local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", 50); |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
33 local global_default_policy = module:get_option("default_archive_policy", false); |
1587
3ac2b835c7b3
mod_mam: Make sure default_archive_policy is a boolean or "roster" (thanks souliane)
Kim Alvefur <zash@zash.se>
parents:
1484
diff
changeset
|
34 if global_default_policy ~= "roster" then |
3ac2b835c7b3
mod_mam: Make sure default_archive_policy is a boolean or "roster" (thanks souliane)
Kim Alvefur <zash@zash.se>
parents:
1484
diff
changeset
|
35 global_default_policy = module:get_option_boolean("default_archive_policy", global_default_policy); |
3ac2b835c7b3
mod_mam: Make sure default_archive_policy is a boolean or "roster" (thanks souliane)
Kim Alvefur <zash@zash.se>
parents:
1484
diff
changeset
|
36 end |
1116
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
37 |
675
da33325453fb
mod_mam: Put name of store in a single variable
Kim Alvefur <zash@zash.se>
parents:
674
diff
changeset
|
38 local archive_store = "archive2"; |
1116
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
39 local archive = module:open_store(archive_store, "archive"); |
1369
8be609f5610e
mod_mam, mod_mam_muc: Check that storagemanager didn't return an instance of the null storage method (Thanks Jonathan)
Kim Alvefur <zash@zash.se>
parents:
1325
diff
changeset
|
40 if not archive or archive.name == "null" then |
1185
30b681898c2d
mod_mam: Log error message if unable to open archive storage
Kim Alvefur <zash@zash.se>
parents:
1152
diff
changeset
|
41 module:log("error", "Could not open archive storage"); |
30b681898c2d
mod_mam: Log error message if unable to open archive storage
Kim Alvefur <zash@zash.se>
parents:
1152
diff
changeset
|
42 return |
30b681898c2d
mod_mam: Log error message if unable to open archive storage
Kim Alvefur <zash@zash.se>
parents:
1152
diff
changeset
|
43 elseif not archive.find then |
30b681898c2d
mod_mam: Log error message if unable to open archive storage
Kim Alvefur <zash@zash.se>
parents:
1152
diff
changeset
|
44 module:log("error", "mod_%s does not support archiving, switch to mod_storage_sql2", archive._provided_by); |
30b681898c2d
mod_mam: Log error message if unable to open archive storage
Kim Alvefur <zash@zash.se>
parents:
1152
diff
changeset
|
45 return |
30b681898c2d
mod_mam: Log error message if unable to open archive storage
Kim Alvefur <zash@zash.se>
parents:
1152
diff
changeset
|
46 end |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
47 |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
48 -- Handle prefs. |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
49 module:hook("iq/self/"..xmlns_mam..":prefs", function(event) |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
50 local origin, stanza = event.origin, event.stanza; |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
51 local user = origin.username; |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
52 if stanza.attr.type == "get" then |
1135
0d6ab5e4bc30
mod_mam: Break out routines for converting prefs between XML and our internal representation into a library
Kim Alvefur <zash@zash.se>
parents:
1116
diff
changeset
|
53 local prefs = prefs_to_stanza(get_prefs(user)); |
0d6ab5e4bc30
mod_mam: Break out routines for converting prefs between XML and our internal representation into a library
Kim Alvefur <zash@zash.se>
parents:
1116
diff
changeset
|
54 local reply = st.reply(stanza):add_child(prefs); |
1681
d20cfc5ba827
mod_mam: Always return true when a stanza event has been handled
Kim Alvefur <zash@zash.se>
parents:
1678
diff
changeset
|
55 origin.send(reply); |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
56 else -- type == "set" |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
57 local new_prefs = stanza:get_child("prefs", xmlns_mam); |
1135
0d6ab5e4bc30
mod_mam: Break out routines for converting prefs between XML and our internal representation into a library
Kim Alvefur <zash@zash.se>
parents:
1116
diff
changeset
|
58 local prefs = prefs_from_stanza(new_prefs); |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
59 local ok, err = set_prefs(user, prefs); |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
60 if not ok then |
1681
d20cfc5ba827
mod_mam: Always return true when a stanza event has been handled
Kim Alvefur <zash@zash.se>
parents:
1678
diff
changeset
|
61 origin.send(st.error_reply(stanza, "cancel", "internal-server-error", "Error storing preferences: "..tostring(err))); |
d20cfc5ba827
mod_mam: Always return true when a stanza event has been handled
Kim Alvefur <zash@zash.se>
parents:
1678
diff
changeset
|
62 else |
d20cfc5ba827
mod_mam: Always return true when a stanza event has been handled
Kim Alvefur <zash@zash.se>
parents:
1678
diff
changeset
|
63 origin.send(st.reply(stanza)); |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
64 end |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
65 end |
1681
d20cfc5ba827
mod_mam: Always return true when a stanza event has been handled
Kim Alvefur <zash@zash.se>
parents:
1678
diff
changeset
|
66 return true; |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
67 end); |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
68 |
1484
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
69 local query_form = dataform { |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
70 { name = "FORM_TYPE"; type = "hidden"; value = xmlns_mam; }; |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
71 { name = "with"; type = "jid-single"; }; |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
72 { name = "start"; type = "text-single" }; |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
73 { name = "end"; type = "text-single"; }; |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
74 }; |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
75 |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
76 -- Serve form |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
77 module:hook("iq-get/self/"..xmlns_mam..":query", function(event) |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
78 local origin, stanza = event.origin, event.stanza; |
1681
d20cfc5ba827
mod_mam: Always return true when a stanza event has been handled
Kim Alvefur <zash@zash.se>
parents:
1678
diff
changeset
|
79 origin.send(st.reply(stanza):add_child(query_form:form())); |
d20cfc5ba827
mod_mam: Always return true when a stanza event has been handled
Kim Alvefur <zash@zash.se>
parents:
1678
diff
changeset
|
80 return true; |
1484
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
81 end); |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
82 |
1325
b21236b6b8d8
Backed out changeset 853a382c9bd6
Kim Alvefur <zash@zash.se>
parents:
1324
diff
changeset
|
83 -- Handle archive queries |
1484
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
84 module:hook("iq-set/self/"..xmlns_mam..":query", function(event) |
1324
853a382c9bd6
mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
Kim Alvefur <zash@zash.se>
parents:
1187
diff
changeset
|
85 local origin, stanza = event.origin, event.stanza; |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
86 local query = stanza.tags[1]; |
1112
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
87 local qid = query.attr.queryid; |
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
88 |
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
89 -- Search query parameters |
1484
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
90 local qwith, qstart, qend; |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
91 local form = query:get_child("x", "jabber:x:data"); |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
92 if form then |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
93 local err; |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
94 form, err = query_form:data(form); |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
95 if err then |
1681
d20cfc5ba827
mod_mam: Always return true when a stanza event has been handled
Kim Alvefur <zash@zash.se>
parents:
1678
diff
changeset
|
96 origin.send(st.error_reply(stanza, "modify", "bad-request", select(2, next(err)))) |
d20cfc5ba827
mod_mam: Always return true when a stanza event has been handled
Kim Alvefur <zash@zash.se>
parents:
1678
diff
changeset
|
97 return true; |
1484
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
98 end |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
99 qwith, qstart, qend = form["with"], form["start"], form["end"]; |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
100 qwith = qwith and jid_bare(qwith); -- dataforms does jidprep |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
101 end |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
102 |
1112
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
103 if qstart or qend then -- Validate timestamps |
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
104 local vstart, vend = (qstart and timestamp_parse(qstart)), (qend and timestamp_parse(qend)) |
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
105 if (qstart and not vstart) or (qend and not vend) then |
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
106 origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid timestamp")) |
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
107 return true |
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
108 end |
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
109 qstart, qend = vstart, vend; |
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
110 end |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
111 |
1484
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
112 module:log("debug", "Archive query, id %s with %s from %s until %s)", |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
113 tostring(qid), qwith or "anyone", qstart or "the dawn of time", qend or "now"); |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
114 |
1112
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
115 -- RSM stuff |
1116
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
116 local qset = rsm.get(query); |
1112
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
117 local qmax = m_min(qset and qset.max or default_max_items, max_max_items); |
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
118 local reverse = qset and qset.before or false; |
1116
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
119 local before, after = qset and qset.before, qset and qset.after; |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
120 if type(before) ~= "string" then before = nil; end |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
121 |
1112
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
122 |
1116
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
123 -- Load all the data! |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
124 local data, err = archive:find(origin.username, { |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
125 start = qstart; ["end"] = qend; -- Time range |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
126 with = qwith; |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
127 limit = qmax; |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
128 before = before; after = after; |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
129 reverse = reverse; |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
130 total = true; |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
131 }); |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
132 |
1116
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
133 if not data then |
1681
d20cfc5ba827
mod_mam: Always return true when a stanza event has been handled
Kim Alvefur <zash@zash.se>
parents:
1678
diff
changeset
|
134 origin.send(st.error_reply(stanza, "cancel", "internal-server-error", err)); |
d20cfc5ba827
mod_mam: Always return true when a stanza event has been handled
Kim Alvefur <zash@zash.se>
parents:
1678
diff
changeset
|
135 return true; |
1116
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
136 end |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
137 local count = err; |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
138 |
1484
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
139 origin.send(st.reply(stanza)) |
1403
6b3db167374a
mod_mam: Mirror to and from attributes from iq on result messages
Kim Alvefur <zash@zash.se>
parents:
1400
diff
changeset
|
140 local msg_reply_attr = { to = stanza.attr.from, from = stanza.attr.to }; |
6b3db167374a
mod_mam: Mirror to and from attributes from iq on result messages
Kim Alvefur <zash@zash.se>
parents:
1400
diff
changeset
|
141 |
1116
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
142 -- Wrap it in stuff and deliver |
1403
6b3db167374a
mod_mam: Mirror to and from attributes from iq on result messages
Kim Alvefur <zash@zash.se>
parents:
1400
diff
changeset
|
143 local fwd_st, first, last; |
1116
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
144 for id, item, when in data do |
1403
6b3db167374a
mod_mam: Mirror to and from attributes from iq on result messages
Kim Alvefur <zash@zash.se>
parents:
1400
diff
changeset
|
145 fwd_st = st.message(msg_reply_attr) |
1116
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
146 :tag("result", { xmlns = xmlns_mam, queryid = qid, id = id }) |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
147 :tag("forwarded", { xmlns = xmlns_forward }) |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
148 :tag("delay", { xmlns = xmlns_delay, stamp = timestamp(when) }):up(); |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
149 |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
150 if not is_stanza(item) then |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
151 item = st.deserialize(item); |
1112
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
152 end |
1116
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
153 item.attr.xmlns = "jabber:client"; |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
154 fwd_st:add_child(item); |
701
cc5805f83583
mod_mam: Implement support for Result Set Management in queries.
Kim Alvefur <zash@zash.se>
parents:
675
diff
changeset
|
155 |
1325
b21236b6b8d8
Backed out changeset 853a382c9bd6
Kim Alvefur <zash@zash.se>
parents:
1324
diff
changeset
|
156 if not first then first = id; end |
b21236b6b8d8
Backed out changeset 853a382c9bd6
Kim Alvefur <zash@zash.se>
parents:
1324
diff
changeset
|
157 last = id; |
1116
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
158 |
2345a30dd8b4
mod_mam: Update to use 'archive' storage type. Note: this breaks support with 0.9 and older.
Kim Alvefur <zash@zash.se>
parents:
1114
diff
changeset
|
159 origin.send(fwd_st); |
1112
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
160 end |
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
161 -- That's all folks! |
1dc07833355e
mod_mam: Use more specific hook
Kim Alvefur <zash@zash.se>
parents:
1111
diff
changeset
|
162 module:log("debug", "Archive query %s completed", tostring(qid)); |
705
c9d0ba39a33b
mod_mam: Move RSM pointer to last message into a MAM-namespaced child
Kim Alvefur <zash@zash.se>
parents:
702
diff
changeset
|
163 |
1325
b21236b6b8d8
Backed out changeset 853a382c9bd6
Kim Alvefur <zash@zash.se>
parents:
1324
diff
changeset
|
164 if reverse then first, last = last, first; end |
1681
d20cfc5ba827
mod_mam: Always return true when a stanza event has been handled
Kim Alvefur <zash@zash.se>
parents:
1678
diff
changeset
|
165 origin.send(st.message(msg_reply_attr) |
1484
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
166 :tag("fin", { xmlns = xmlns_mam, queryid = qid }) |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
167 :add_child(rsm.generate { |
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
168 first = first, last = last, count = count })); |
1681
d20cfc5ba827
mod_mam: Always return true when a stanza event has been handled
Kim Alvefur <zash@zash.se>
parents:
1678
diff
changeset
|
169 return true; |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
170 end); |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
171 |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
172 local function has_in_roster(user, who) |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
173 local roster = rm_load_roster(user, host); |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
174 module:log("debug", "%s has %s in roster? %s", user, who, roster[who] and "yes" or "no"); |
798 | 175 return roster[who]; |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
176 end |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
177 |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
178 local function shall_store(user, who) |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
179 -- TODO Cache this? |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
180 local prefs = get_prefs(user); |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
181 local rule = prefs[who]; |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
182 module:log("debug", "%s's rule for %s is %s", user, who, tostring(rule)) |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
183 if rule ~= nil then |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
184 return rule; |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
185 else -- Below could be done by a metatable |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
186 local default = prefs[false]; |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
187 module:log("debug", "%s's default rule is %s", user, tostring(default)) |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
188 if default == nil then |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
189 default = global_default_policy; |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
190 module:log("debug", "Using global default rule, %s", tostring(default)) |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
191 end |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
192 if default == "roster" then |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
193 return has_in_roster(user, who); |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
194 end |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
195 return default; |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
196 end |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
197 end |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
198 |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
199 -- Handle messages |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
200 local function message_handler(event, c2s) |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
201 local origin, stanza = event.origin, event.stanza; |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
202 local orig_type = stanza.attr.type or "normal"; |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
203 local orig_from = stanza.attr.from; |
1149
d055c44a7f61
mod_mam: Clean up and explain the code that determines who's archive we put the message in
Kim Alvefur <zash@zash.se>
parents:
1135
diff
changeset
|
204 local orig_to = stanza.attr.to or orig_from; |
d055c44a7f61
mod_mam: Clean up and explain the code that determines who's archive we put the message in
Kim Alvefur <zash@zash.se>
parents:
1135
diff
changeset
|
205 -- Stanza without 'to' are treated as if it was to their own bare jid |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
206 |
1150
296820f18ba6
mod_mam: Add support for XEP-0334: Message Processing Hints
Kim Alvefur <zash@zash.se>
parents:
1149
diff
changeset
|
207 -- We don't store messages of these types |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
208 if orig_type == "error" |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
209 or orig_type == "headline" |
671
74efb2db00a6
mod_mam: From the spec: servers SHOULD NOT archive messages that do not have a <body/> child tag.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
666
diff
changeset
|
210 or orig_type == "groupchat" |
1150
296820f18ba6
mod_mam: Add support for XEP-0334: Message Processing Hints
Kim Alvefur <zash@zash.se>
parents:
1149
diff
changeset
|
211 -- or that don't have a <body/> |
296820f18ba6
mod_mam: Add support for XEP-0334: Message Processing Hints
Kim Alvefur <zash@zash.se>
parents:
1149
diff
changeset
|
212 or not stanza:get_child("body") |
296820f18ba6
mod_mam: Add support for XEP-0334: Message Processing Hints
Kim Alvefur <zash@zash.se>
parents:
1149
diff
changeset
|
213 -- or if hints suggest we shouldn't |
296820f18ba6
mod_mam: Add support for XEP-0334: Message Processing Hints
Kim Alvefur <zash@zash.se>
parents:
1149
diff
changeset
|
214 or stanza:get_child("no-permanent-store", "urn:xmpp:hints") |
296820f18ba6
mod_mam: Add support for XEP-0334: Message Processing Hints
Kim Alvefur <zash@zash.se>
parents:
1149
diff
changeset
|
215 or stanza:get_child("no-store", "urn:xmpp:hints") then |
296820f18ba6
mod_mam: Add support for XEP-0334: Message Processing Hints
Kim Alvefur <zash@zash.se>
parents:
1149
diff
changeset
|
216 module:log("debug", "Not archiving stanza: %s (content)", stanza:top_tag()); |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
217 return; |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
218 end |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
219 |
1149
d055c44a7f61
mod_mam: Clean up and explain the code that determines who's archive we put the message in
Kim Alvefur <zash@zash.se>
parents:
1135
diff
changeset
|
220 -- Whos storage do we put it in? |
d055c44a7f61
mod_mam: Clean up and explain the code that determines who's archive we put the message in
Kim Alvefur <zash@zash.se>
parents:
1135
diff
changeset
|
221 local store_user = c2s and origin.username or jid_split(orig_to); |
d055c44a7f61
mod_mam: Clean up and explain the code that determines who's archive we put the message in
Kim Alvefur <zash@zash.se>
parents:
1135
diff
changeset
|
222 -- And who are they chatting with? |
d055c44a7f61
mod_mam: Clean up and explain the code that determines who's archive we put the message in
Kim Alvefur <zash@zash.se>
parents:
1135
diff
changeset
|
223 local with = jid_bare(c2s and orig_to or orig_from); |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
224 |
1149
d055c44a7f61
mod_mam: Clean up and explain the code that determines who's archive we put the message in
Kim Alvefur <zash@zash.se>
parents:
1135
diff
changeset
|
225 -- Check with the users preferences |
d055c44a7f61
mod_mam: Clean up and explain the code that determines who's archive we put the message in
Kim Alvefur <zash@zash.se>
parents:
1135
diff
changeset
|
226 if shall_store(store_user, with) then |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
227 module:log("debug", "Archiving stanza: %s", stanza:top_tag()); |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
228 |
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
229 -- And stash it |
1484
53a3a19d6093
mod_mam: Update to version 0.3 of XEP-0313
Kim Alvefur <zash@zash.se>
parents:
1403
diff
changeset
|
230 local ok, id = archive:append(store_user, nil, time_now(), with, stanza); |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
231 else |
1150
296820f18ba6
mod_mam: Add support for XEP-0334: Message Processing Hints
Kim Alvefur <zash@zash.se>
parents:
1149
diff
changeset
|
232 module:log("debug", "Not archiving stanza: %s (prefs)", stanza:top_tag()); |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
233 end |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
234 end |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
235 |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
236 local function c2s_message_handler(event) |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
237 return message_handler(event, true); |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
238 end |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
239 |
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
240 -- Stanzas sent by local clients |
621
7bdd02056e2b
mod_mam: Bumb priority up above carbons, so that archive ids are included
Kim Alvefur <zash@zash.se>
parents:
620
diff
changeset
|
241 module:hook("pre-message/bare", c2s_message_handler, 2); |
7bdd02056e2b
mod_mam: Bumb priority up above carbons, so that archive ids are included
Kim Alvefur <zash@zash.se>
parents:
620
diff
changeset
|
242 module:hook("pre-message/full", c2s_message_handler, 2); |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
243 -- Stanszas to local clients |
621
7bdd02056e2b
mod_mam: Bumb priority up above carbons, so that archive ids are included
Kim Alvefur <zash@zash.se>
parents:
620
diff
changeset
|
244 module:hook("message/bare", message_handler, 2); |
7bdd02056e2b
mod_mam: Bumb priority up above carbons, so that archive ids are included
Kim Alvefur <zash@zash.se>
parents:
620
diff
changeset
|
245 module:hook("message/full", message_handler, 2); |
523
eff140d53b83
mod_mam: Add experimental implementation of the Message Archive Management ProtoXEP
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
246 |
1678
9ee56cc1be2c
mod_mam: Advertise feature in disco#info for account as per XEP-0313 >= 0.2
Kim Alvefur <zash@zash.se>
parents:
1587
diff
changeset
|
247 module:add_feature(xmlns_mam); -- COMPAT with XEP-0313 v 0.1 |
558
66de25ffc8d9
mod_mam: Implement archiving preferences.
Kim Alvefur <zash@zash.se>
parents:
523
diff
changeset
|
248 |
1678
9ee56cc1be2c
mod_mam: Advertise feature in disco#info for account as per XEP-0313 >= 0.2
Kim Alvefur <zash@zash.se>
parents:
1587
diff
changeset
|
249 module:hook("account-disco-info", function(event) |
9ee56cc1be2c
mod_mam: Advertise feature in disco#info for account as per XEP-0313 >= 0.2
Kim Alvefur <zash@zash.se>
parents:
1587
diff
changeset
|
250 event.reply:tag("feature", {var=xmlns_mam}):up(); |
9ee56cc1be2c
mod_mam: Advertise feature in disco#info for account as per XEP-0313 >= 0.2
Kim Alvefur <zash@zash.se>
parents:
1587
diff
changeset
|
251 end); |
9ee56cc1be2c
mod_mam: Advertise feature in disco#info for account as per XEP-0313 >= 0.2
Kim Alvefur <zash@zash.se>
parents:
1587
diff
changeset
|
252 |