Mercurial > prosody-modules
annotate mod_mam_muc/mod_mam_muc.lua @ 1810:2905137cf541
mod_s2s_log_certs/README: Fix link
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 31 Aug 2015 17:30:10 +0200 |
parents | 1a8c791d365f |
children | db8b256f51ff |
rev | line source |
---|---|
1313 | 1 -- XEP-0313: Message Archive Management for Prosody MUC |
1519
67c80abe742e
mod_mam_muc: Fix add/removal of room method overrides
Kim Alvefur <zash@zash.se>
parents:
1430
diff
changeset
|
2 -- Copyright (C) 2011-2014 Kim Alvefur |
820 | 3 -- |
4 -- This file is MIT/X11 licensed. | |
5 | |
1536
4fb280768efc
mod_mam_muc: Add missing import and change the namespace to MAM v0.3
Kim Alvefur <zash@zash.se>
parents:
1535
diff
changeset
|
6 local xmlns_mam = "urn:xmpp:mam:0"; |
820 | 7 local xmlns_delay = "urn:xmpp:delay"; |
8 local xmlns_forward = "urn:xmpp:forward:0"; | |
1313 | 9 local muc_form_enable_logging = "muc#roomconfig_enablelogging" |
820 | 10 |
11 local st = require "util.stanza"; | |
12 local rsm = module:require "mod_mam/rsm"; | |
13 local jid_bare = require "util.jid".bare; | |
14 local jid_split = require "util.jid".split; | |
1536
4fb280768efc
mod_mam_muc: Add missing import and change the namespace to MAM v0.3
Kim Alvefur <zash@zash.se>
parents:
1535
diff
changeset
|
15 local dataform = require "util.dataforms".new; |
1551
5127f4db9d39
mod_mam_muc: Try to use new MUC API for getting room objects (fixes queries to not yet initialized rooms)
Kim Alvefur <zash@zash.se>
parents:
1548
diff
changeset
|
16 local it = require"util.iterators"; |
1534
4dd6eebc8fbd
mod_mam_muc: Minor moving about of variables
Kim Alvefur <zash@zash.se>
parents:
1533
diff
changeset
|
17 |
1551
5127f4db9d39
mod_mam_muc: Try to use new MUC API for getting room objects (fixes queries to not yet initialized rooms)
Kim Alvefur <zash@zash.se>
parents:
1548
diff
changeset
|
18 -- Support both old and new MUC code |
1534
4dd6eebc8fbd
mod_mam_muc: Minor moving about of variables
Kim Alvefur <zash@zash.se>
parents:
1533
diff
changeset
|
19 local mod_muc = module:depends"muc"; |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
20 local rooms = rawget(mod_muc, "rooms"); |
1551
5127f4db9d39
mod_mam_muc: Try to use new MUC API for getting room objects (fixes queries to not yet initialized rooms)
Kim Alvefur <zash@zash.se>
parents:
1548
diff
changeset
|
21 local each_room = rawget(mod_muc, "each_room") or function() return it.values(rooms); end; |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
22 local new_muc = not rooms; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
23 if new_muc then |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
24 rooms = module:shared"muc/rooms"; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
25 end |
1551
5127f4db9d39
mod_mam_muc: Try to use new MUC API for getting room objects (fixes queries to not yet initialized rooms)
Kim Alvefur <zash@zash.se>
parents:
1548
diff
changeset
|
26 local get_room_from_jid = rawget(mod_muc, "get_room_from_jid") or |
5127f4db9d39
mod_mam_muc: Try to use new MUC API for getting room objects (fixes queries to not yet initialized rooms)
Kim Alvefur <zash@zash.se>
parents:
1548
diff
changeset
|
27 function (jid) |
5127f4db9d39
mod_mam_muc: Try to use new MUC API for getting room objects (fixes queries to not yet initialized rooms)
Kim Alvefur <zash@zash.se>
parents:
1548
diff
changeset
|
28 return rooms[jid]; |
5127f4db9d39
mod_mam_muc: Try to use new MUC API for getting room objects (fixes queries to not yet initialized rooms)
Kim Alvefur <zash@zash.se>
parents:
1548
diff
changeset
|
29 end |
820 | 30 |
1141
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
31 local getmetatable = getmetatable; |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
32 local function is_stanza(x) |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
33 return getmetatable(x) == st.stanza_mt; |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
34 end |
820 | 35 |
36 local tostring = tostring; | |
37 local time_now = os.time; | |
38 local m_min = math.min; | |
39 local timestamp, timestamp_parse = require "util.datetime".datetime, require "util.datetime".parse; | |
1278
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
40 local max_history_length = module:get_option_number("max_history_messages", 1000); |
1430
18f5f1b13353
mod_mam_muc: Use max_history_length as default for "max_archive_query_results"
daurnimator <quae@daurnimator.com>
parents:
1385
diff
changeset
|
41 local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", max_history_length); |
820 | 42 |
1143
8098683b6d6f
mod_mam_muc: Allow archiving to be enabled trough in the room configuration
Kim Alvefur <zash@zash.se>
parents:
1142
diff
changeset
|
43 local log_all_rooms = module:get_option_boolean("muc_log_all_rooms", false); |
8098683b6d6f
mod_mam_muc: Allow archiving to be enabled trough in the room configuration
Kim Alvefur <zash@zash.se>
parents:
1142
diff
changeset
|
44 local log_by_default = module:get_option_boolean("muc_log_by_default", true); |
1142
fabdaa0d99e3
mod_mam_muc: Stap archived messages
Kim Alvefur <zash@zash.se>
parents:
1141
diff
changeset
|
45 |
1571
eed7db9f3157
mod_mam_muc, mod_http_muc_log: Change store name from 'archive2' to 'muc_log' to distinguish it from personal MAM archives. Old data will require migration.
Kim Alvefur <zash@zash.se>
parents:
1551
diff
changeset
|
46 local archive_store = "muc_log"; |
1311
27b2a357c73c
mod_mam_muc: porting archive checks from mod_mam (to avoid tracebacks about calling null functions)
Vadim Misbakh-Soloviov <mva@mva.name>
parents:
1279
diff
changeset
|
47 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
|
48 if not archive or archive.name == "null" then |
1541 | 49 module:log("error", "Could not open archive storage"); |
50 return | |
1311
27b2a357c73c
mod_mam_muc: porting archive checks from mod_mam (to avoid tracebacks about calling null functions)
Vadim Misbakh-Soloviov <mva@mva.name>
parents:
1279
diff
changeset
|
51 elseif not archive.find then |
1541 | 52 module:log("error", "mod_%s does not support archiving, switch to mod_storage_sql2", archive._provided_by); |
53 return | |
1311
27b2a357c73c
mod_mam_muc: porting archive checks from mod_mam (to avoid tracebacks about calling null functions)
Vadim Misbakh-Soloviov <mva@mva.name>
parents:
1279
diff
changeset
|
54 end |
27b2a357c73c
mod_mam_muc: porting archive checks from mod_mam (to avoid tracebacks about calling null functions)
Vadim Misbakh-Soloviov <mva@mva.name>
parents:
1279
diff
changeset
|
55 |
1542
ccb9dc624ebd
mod_mam_muc: Split logic for determining if logging is enabled into a function
Kim Alvefur <zash@zash.se>
parents:
1541
diff
changeset
|
56 local function logging_enabled(room) |
ccb9dc624ebd
mod_mam_muc: Split logic for determining if logging is enabled into a function
Kim Alvefur <zash@zash.se>
parents:
1541
diff
changeset
|
57 if log_all_rooms then |
ccb9dc624ebd
mod_mam_muc: Split logic for determining if logging is enabled into a function
Kim Alvefur <zash@zash.se>
parents:
1541
diff
changeset
|
58 return true; |
ccb9dc624ebd
mod_mam_muc: Split logic for determining if logging is enabled into a function
Kim Alvefur <zash@zash.se>
parents:
1541
diff
changeset
|
59 end |
ccb9dc624ebd
mod_mam_muc: Split logic for determining if logging is enabled into a function
Kim Alvefur <zash@zash.se>
parents:
1541
diff
changeset
|
60 local enabled = room._data.logging; |
ccb9dc624ebd
mod_mam_muc: Split logic for determining if logging is enabled into a function
Kim Alvefur <zash@zash.se>
parents:
1541
diff
changeset
|
61 if enabled == nil then |
ccb9dc624ebd
mod_mam_muc: Split logic for determining if logging is enabled into a function
Kim Alvefur <zash@zash.se>
parents:
1541
diff
changeset
|
62 return log_by_default; |
ccb9dc624ebd
mod_mam_muc: Split logic for determining if logging is enabled into a function
Kim Alvefur <zash@zash.se>
parents:
1541
diff
changeset
|
63 end |
ccb9dc624ebd
mod_mam_muc: Split logic for determining if logging is enabled into a function
Kim Alvefur <zash@zash.se>
parents:
1541
diff
changeset
|
64 return enabled; |
ccb9dc624ebd
mod_mam_muc: Split logic for determining if logging is enabled into a function
Kim Alvefur <zash@zash.se>
parents:
1541
diff
changeset
|
65 end |
ccb9dc624ebd
mod_mam_muc: Split logic for determining if logging is enabled into a function
Kim Alvefur <zash@zash.se>
parents:
1541
diff
changeset
|
66 |
1314
cc9831033f5d
mod_mam_muc: Add and remove method overrides based on configuration instead of modifying room metatable
Kim Alvefur <zash@zash.se>
parents:
1313
diff
changeset
|
67 local send_history, save_to_history; |
cc9831033f5d
mod_mam_muc: Add and remove method overrides based on configuration instead of modifying room metatable
Kim Alvefur <zash@zash.se>
parents:
1313
diff
changeset
|
68 |
cc9831033f5d
mod_mam_muc: Add and remove method overrides based on configuration instead of modifying room metatable
Kim Alvefur <zash@zash.se>
parents:
1313
diff
changeset
|
69 -- Override history methods for all rooms. |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
70 if not new_muc then -- 0.10 or older |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
71 module:hook("muc-room-created", function (event) |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
72 local room = event.room; |
1542
ccb9dc624ebd
mod_mam_muc: Split logic for determining if logging is enabled into a function
Kim Alvefur <zash@zash.se>
parents:
1541
diff
changeset
|
73 if logging_enabled(room) then |
1533
915bdcb35e79
mod_mam_muc: Restructure initialization
Kim Alvefur <zash@zash.se>
parents:
1532
diff
changeset
|
74 room.send_history = send_history; |
915bdcb35e79
mod_mam_muc: Restructure initialization
Kim Alvefur <zash@zash.se>
parents:
1532
diff
changeset
|
75 room.save_to_history = save_to_history; |
1314
cc9831033f5d
mod_mam_muc: Add and remove method overrides based on configuration instead of modifying room metatable
Kim Alvefur <zash@zash.se>
parents:
1313
diff
changeset
|
76 end |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
77 end); |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
78 |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
79 function module.load() |
1551
5127f4db9d39
mod_mam_muc: Try to use new MUC API for getting room objects (fixes queries to not yet initialized rooms)
Kim Alvefur <zash@zash.se>
parents:
1548
diff
changeset
|
80 for room in each_room() do |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
81 if logging_enabled(room) then |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
82 room.send_history = send_history; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
83 room.save_to_history = save_to_history; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
84 end |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
85 end |
1314
cc9831033f5d
mod_mam_muc: Add and remove method overrides based on configuration instead of modifying room metatable
Kim Alvefur <zash@zash.se>
parents:
1313
diff
changeset
|
86 end |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
87 function module.unload() |
1551
5127f4db9d39
mod_mam_muc: Try to use new MUC API for getting room objects (fixes queries to not yet initialized rooms)
Kim Alvefur <zash@zash.se>
parents:
1548
diff
changeset
|
88 for room in each_room() do |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
89 if room.send_history == send_history then |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
90 room.send_history = nil; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
91 room.save_to_history = nil; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
92 end |
1314
cc9831033f5d
mod_mam_muc: Add and remove method overrides based on configuration instead of modifying room metatable
Kim Alvefur <zash@zash.se>
parents:
1313
diff
changeset
|
93 end |
cc9831033f5d
mod_mam_muc: Add and remove method overrides based on configuration instead of modifying room metatable
Kim Alvefur <zash@zash.se>
parents:
1313
diff
changeset
|
94 end |
1533
915bdcb35e79
mod_mam_muc: Restructure initialization
Kim Alvefur <zash@zash.se>
parents:
1532
diff
changeset
|
95 end |
915bdcb35e79
mod_mam_muc: Restructure initialization
Kim Alvefur <zash@zash.se>
parents:
1532
diff
changeset
|
96 |
915bdcb35e79
mod_mam_muc: Restructure initialization
Kim Alvefur <zash@zash.se>
parents:
1532
diff
changeset
|
97 if not log_all_rooms then |
1276
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
98 module:hook("muc-config-form", function(event) |
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
99 local room, form = event.room, event.form; |
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
100 table.insert(form, |
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
101 { |
1313 | 102 name = muc_form_enable_logging, |
1276
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
103 type = "boolean", |
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
104 label = "Enable Logging?", |
1542
ccb9dc624ebd
mod_mam_muc: Split logic for determining if logging is enabled into a function
Kim Alvefur <zash@zash.se>
parents:
1541
diff
changeset
|
105 value = logging_enabled(room), |
1276
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
106 } |
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
107 ); |
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
108 end); |
1143
8098683b6d6f
mod_mam_muc: Allow archiving to be enabled trough in the room configuration
Kim Alvefur <zash@zash.se>
parents:
1142
diff
changeset
|
109 |
1276
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
110 module:hook("muc-config-submitted", function(event) |
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
111 local room, fields, changed = event.room, event.fields, event.changed; |
1313 | 112 local new = fields[muc_form_enable_logging]; |
1276
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
113 if new ~= room._data.logging then |
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
114 room._data.logging = new; |
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
115 if type(changed) == "table" then |
1313 | 116 changed[muc_form_enable_logging] = true; |
1276
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
117 else |
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
118 event.changed = true; |
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
119 end |
1314
cc9831033f5d
mod_mam_muc: Add and remove method overrides based on configuration instead of modifying room metatable
Kim Alvefur <zash@zash.se>
parents:
1313
diff
changeset
|
120 if new then |
cc9831033f5d
mod_mam_muc: Add and remove method overrides based on configuration instead of modifying room metatable
Kim Alvefur <zash@zash.se>
parents:
1313
diff
changeset
|
121 room.send_history = send_history; |
cc9831033f5d
mod_mam_muc: Add and remove method overrides based on configuration instead of modifying room metatable
Kim Alvefur <zash@zash.se>
parents:
1313
diff
changeset
|
122 room.save_to_history = save_to_history; |
cc9831033f5d
mod_mam_muc: Add and remove method overrides based on configuration instead of modifying room metatable
Kim Alvefur <zash@zash.se>
parents:
1313
diff
changeset
|
123 else |
cc9831033f5d
mod_mam_muc: Add and remove method overrides based on configuration instead of modifying room metatable
Kim Alvefur <zash@zash.se>
parents:
1313
diff
changeset
|
124 room.send_history = nil; |
cc9831033f5d
mod_mam_muc: Add and remove method overrides based on configuration instead of modifying room metatable
Kim Alvefur <zash@zash.se>
parents:
1313
diff
changeset
|
125 room.save_to_history = nil; |
cc9831033f5d
mod_mam_muc: Add and remove method overrides based on configuration instead of modifying room metatable
Kim Alvefur <zash@zash.se>
parents:
1313
diff
changeset
|
126 end |
1143
8098683b6d6f
mod_mam_muc: Allow archiving to be enabled trough in the room configuration
Kim Alvefur <zash@zash.se>
parents:
1142
diff
changeset
|
127 end |
1276
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
128 end); |
01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
Kim Alvefur <zash@zash.se>
parents:
1275
diff
changeset
|
129 end |
1143
8098683b6d6f
mod_mam_muc: Allow archiving to be enabled trough in the room configuration
Kim Alvefur <zash@zash.se>
parents:
1142
diff
changeset
|
130 |
1546
fff2858c554f
mod_mam_muc: Remove parsing of 'with' field in MAM form, we currently ignore it anyways
Kim Alvefur <zash@zash.se>
parents:
1543
diff
changeset
|
131 -- Note: We ignore the 'with' field as this is internally used for stanza types |
1535
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
132 local query_form = dataform { |
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
133 { name = "FORM_TYPE"; type = "hidden"; value = xmlns_mam; }; |
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
134 { name = "with"; type = "jid-single"; }; |
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
135 { name = "start"; type = "text-single" }; |
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
136 { name = "end"; type = "text-single"; }; |
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
137 }; |
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
138 |
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
139 -- Serve form |
1627
458c80904525
mod_mam_muc: fix <iq type='get' to='room-bare-jid'> query
Stuart Carnie <stuart.carnie@gmail.com>
parents:
1616
diff
changeset
|
140 module:hook("iq-get/bare/"..xmlns_mam..":query", function(event) |
1535
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
141 local origin, stanza = event.origin, event.stanza; |
1691
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
142 origin.send(st.reply(stanza):add_child(query_form:form())); |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
143 return true; |
1535
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
144 end); |
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
145 |
820 | 146 -- Handle archive queries |
1535
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
147 module:hook("iq-set/bare/"..xmlns_mam..":query", function(event) |
820 | 148 local origin, stanza = event.origin, event.stanza; |
1144
ccb0c5afe658
mod_mam_muc: Fix room lookup, should be indexed by bare jid
Kim Alvefur <zash@zash.se>
parents:
1143
diff
changeset
|
149 local room = stanza.attr.to; |
1146
9fa89dc7a86f
mod_mam_muc: Search the rooms archive correctly (copypaste error from mod_mam)
Kim Alvefur <zash@zash.se>
parents:
1145
diff
changeset
|
150 local room_node = jid_split(room); |
1382
ba17268490b7
mod_mam_muc: Fix to, from on result messages (thanks daurnimator)
Kim Alvefur <zash@zash.se>
parents:
1369
diff
changeset
|
151 local orig_from = stanza.attr.from; |
820 | 152 local query = stanza.tags[1]; |
153 | |
1551
5127f4db9d39
mod_mam_muc: Try to use new MUC API for getting room objects (fixes queries to not yet initialized rooms)
Kim Alvefur <zash@zash.se>
parents:
1548
diff
changeset
|
154 local room_obj = get_room_from_jid(room); |
820 | 155 if not room_obj then |
1145
5a00f9bec6e7
mod_mam_muc: Send item-not-found if the requested room does not exist
Kim Alvefur <zash@zash.se>
parents:
1144
diff
changeset
|
156 return origin.send(st.error_reply(stanza, "cancel", "item-not-found")) |
820 | 157 end |
1382
ba17268490b7
mod_mam_muc: Fix to, from on result messages (thanks daurnimator)
Kim Alvefur <zash@zash.se>
parents:
1369
diff
changeset
|
158 local from = jid_bare(orig_from); |
820 | 159 |
1140
402cb9b604eb
mod_mam_muc: Send proper error reply when one is not allowed to query archive
Kim Alvefur <zash@zash.se>
parents:
1139
diff
changeset
|
160 -- Banned or not a member of a members-only room? |
1312
a48cf3ccdf9c
mod_mam_muc: Use public API of rooms for authorization check
Kim Alvefur <zash@zash.se>
parents:
1311
diff
changeset
|
161 local from_affiliation = room_obj:get_affiliation(from); |
a48cf3ccdf9c
mod_mam_muc: Use public API of rooms for authorization check
Kim Alvefur <zash@zash.se>
parents:
1311
diff
changeset
|
162 if from_affiliation == "outcast" -- banned |
1325
b21236b6b8d8
Backed out changeset 853a382c9bd6
Kim Alvefur <zash@zash.se>
parents:
1324
diff
changeset
|
163 or room_obj:get_members_only() and not from_affiliation then -- members-only, not a member |
1140
402cb9b604eb
mod_mam_muc: Send proper error reply when one is not allowed to query archive
Kim Alvefur <zash@zash.se>
parents:
1139
diff
changeset
|
164 return origin.send(st.error_reply(stanza, "auth", "forbidden")) |
820 | 165 end |
166 | |
1138
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
167 local qid = query.attr.queryid; |
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
168 |
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
169 -- Search query parameters |
1546
fff2858c554f
mod_mam_muc: Remove parsing of 'with' field in MAM form, we currently ignore it anyways
Kim Alvefur <zash@zash.se>
parents:
1543
diff
changeset
|
170 local qstart, qend; |
1535
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
171 local form = query:get_child("x", "jabber:x:data"); |
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
172 if form then |
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
173 local err; |
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
174 form, err = query_form:data(form); |
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
175 if err then |
1691
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
176 origin.send(st.error_reply(stanza, "modify", "bad-request", select(2, next(err)))); |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
177 return true; |
1535
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
178 end |
1546
fff2858c554f
mod_mam_muc: Remove parsing of 'with' field in MAM form, we currently ignore it anyways
Kim Alvefur <zash@zash.se>
parents:
1543
diff
changeset
|
179 qstart, qend = form["start"], form["end"]; |
1535
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
180 end |
820 | 181 |
1138
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
182 if qstart or qend then -- Validate timestamps |
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
183 local vstart, vend = (qstart and timestamp_parse(qstart)), (qend and timestamp_parse(qend)) |
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
184 if (qstart and not vstart) or (qend and not vend) then |
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
185 origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid timestamp")) |
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
186 return true |
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
187 end |
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
188 qstart, qend = vstart, vend; |
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
189 end |
820 | 190 |
1141
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
191 -- RSM stuff |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
192 local qset = rsm.get(query); |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
193 local qmax = m_min(qset and qset.max or default_max_items, max_max_items); |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
194 local reverse = qset and qset.before or false; |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
195 |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
196 local before, after = qset and qset.before, qset and qset.after; |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
197 if type(before) ~= "string" then before = nil; end |
820 | 198 |
1138
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
199 -- Load all the data! |
1146
9fa89dc7a86f
mod_mam_muc: Search the rooms archive correctly (copypaste error from mod_mam)
Kim Alvefur <zash@zash.se>
parents:
1145
diff
changeset
|
200 local data, err = archive:find(room_node, { |
1141
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
201 start = qstart; ["end"] = qend; -- Time range |
1691
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
202 limit = qmax + 1; |
1141
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
203 before = before; after = after; |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
204 reverse = reverse; |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
205 total = true; |
1547
e98c335c6554
mod_mam_muc: Limit search to groupchat messages (we use the internal 'with' field stanza types)
Kim Alvefur <zash@zash.se>
parents:
1546
diff
changeset
|
206 with = "message<groupchat"; |
1141
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
207 }); |
1138
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
208 |
1141
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
209 if not data then |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
210 return origin.send(st.error_reply(stanza, "cancel", "internal-server-error")); |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
211 end |
1691
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
212 local total = err; |
1138
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
213 |
1535
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
214 origin.send(st.reply(stanza)) |
1534
4dd6eebc8fbd
mod_mam_muc: Minor moving about of variables
Kim Alvefur <zash@zash.se>
parents:
1533
diff
changeset
|
215 local msg_reply_attr = { to = stanza.attr.from, from = stanza.attr.to }; |
4dd6eebc8fbd
mod_mam_muc: Minor moving about of variables
Kim Alvefur <zash@zash.se>
parents:
1533
diff
changeset
|
216 |
1691
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
217 local results = {}; |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
218 |
1141
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
219 -- Wrap it in stuff and deliver |
1691
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
220 local first, last; |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
221 local count = 0; |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
222 local complete = "true"; |
1141
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
223 for id, item, when in data do |
1691
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
224 count = count + 1; |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
225 if count > qmax then |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
226 complete = nil; |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
227 break; |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
228 end |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
229 local fwd_st = st.message(msg_reply_attr) |
1141
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
230 :tag("result", { xmlns = xmlns_mam, queryid = qid, id = id }) |
1138
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
231 :tag("forwarded", { xmlns = xmlns_forward }) |
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
232 :tag("delay", { xmlns = xmlns_delay, stamp = timestamp(when) }):up(); |
1141
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
233 |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
234 if not is_stanza(item) then |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
235 item = st.deserialize(item); |
1138
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
236 end |
1141
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
237 item.attr.xmlns = "jabber:client"; |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
238 fwd_st:add_child(item); |
820 | 239 |
1141
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
240 if not first then first = id; end |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
241 last = id; |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
242 |
1691
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
243 if reverse then |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
244 results[count] = fwd_st; |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
245 else |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
246 origin.send(fwd_st); |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
247 end |
1138
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
248 end |
1691
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
249 if reverse then |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
250 for i = #results, 1, -1 do |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
251 origin.send(results[i]); |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
252 end |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
253 end |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
254 |
1138
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
255 -- That's all folks! |
5c97ee75cadb
mod_mam_muc: Switch to iq-get hook and drop some indentation
Kim Alvefur <zash@zash.se>
parents:
820
diff
changeset
|
256 module:log("debug", "Archive query %s completed", tostring(qid)); |
820 | 257 |
1141
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
258 if reverse then first, last = last, first; end |
1691
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
259 origin.send(st.message(msg_reply_attr) |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
260 :tag("fin", { xmlns = xmlns_mam, queryid = qid, complete = complete }) |
1535
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
261 :add_child(rsm.generate { |
1691
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
262 first = first, last = last, count = total })); |
1a8c791d365f
mod_mam_muc: d20cfc5ba827 .. cd87a2eba8f2 here too (uh, duplicated code)
Kim Alvefur <zash@zash.se>
parents:
1679
diff
changeset
|
263 return true; |
820 | 264 end); |
265 | |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
266 module:hook("muc-get-history", function (event) |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
267 local room = event.room; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
268 if not logging_enabled(room) then return end |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
269 local room_jid = room.jid; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
270 local maxstanzas = event.maxstanzas; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
271 local maxchars = event.maxchars; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
272 local since = event.since; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
273 local to = event.to; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
274 |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
275 -- Load all the data! |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
276 local query = { |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
277 limit = m_min(maxstanzas or 20, max_history_length); |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
278 start = since; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
279 reverse = true; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
280 with = "message<groupchat"; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
281 } |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
282 module:log("debug", require"util.serialization".serialize(query)) |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
283 local data, err = archive:find(jid_split(room_jid), query); |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
284 |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
285 if not data then |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
286 module:log("error", "Could not fetch history: %s", tostring(err)); |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
287 return |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
288 end |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
289 |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
290 local history, i = {}, 1; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
291 |
1650
66d67f0bae16
mod_mam_muc: Cleanup [luacheck]
Kim Alvefur <zash@zash.se>
parents:
1649
diff
changeset
|
292 for _, item, when in data do |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
293 item.attr.to = to; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
294 item:tag("delay", { xmlns = "urn:xmpp:delay", from = room_jid, stamp = timestamp(when) }):up(); -- XEP-0203 |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
295 if maxchars then |
1649
ab4073468dfb
mod_mam_muc: Fix character limit again(?)
Kim Alvefur <zash@zash.se>
parents:
1636
diff
changeset
|
296 local chars = #tostring(item); |
1636
7fa0c41792c7
mod_mam_muc: Fix character limit
Kim Alvefur <zash@zash.se>
parents:
1627
diff
changeset
|
297 if maxchars - chars < 0 then |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
298 break |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
299 end |
1649
ab4073468dfb
mod_mam_muc: Fix character limit again(?)
Kim Alvefur <zash@zash.se>
parents:
1636
diff
changeset
|
300 maxchars = maxchars - chars; |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
301 end |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
302 history[i], i = item, i+1; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
303 -- module:log("debug", tostring(item)); |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
304 end |
1650
66d67f0bae16
mod_mam_muc: Cleanup [luacheck]
Kim Alvefur <zash@zash.se>
parents:
1649
diff
changeset
|
305 function event.next_stanza() |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
306 i = i - 1; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
307 return history[i]; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
308 end |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
309 return true; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
310 end, 1); |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
311 |
1519
67c80abe742e
mod_mam_muc: Fix add/removal of room method overrides
Kim Alvefur <zash@zash.se>
parents:
1430
diff
changeset
|
312 function send_history(self, to, stanza) |
1278
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
313 local maxchars, maxstanzas, seconds, since; |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
314 local history_tag = stanza:find("{http://jabber.org/protocol/muc}x/history") |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
315 if history_tag then |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
316 module:log("debug", tostring(history_tag)); |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
317 local history_attr = history_tag.attr; |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
318 maxchars = tonumber(history_attr.maxchars); |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
319 maxstanzas = tonumber(history_attr.maxstanzas); |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
320 seconds = tonumber(history_attr.seconds); |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
321 since = history_attr.since; |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
322 if since then |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
323 since = timestamp_parse(since); |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
324 end |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
325 if seconds then |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
326 since = math.max(os.time() - seconds, since or 0); |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
327 end |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
328 end |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
329 |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
330 local event = { |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
331 room = self; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
332 to = to; -- `to` is required to calculate the character count for `maxchars` |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
333 maxchars = maxchars, maxstanzas = maxstanzas, since = since; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
334 next_stanza = function() end; -- events should define this iterator |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
335 }; |
1278
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
336 |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
337 module:fire_event("muc-get-history", event); |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
338 |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
339 for msg in event.next_stanza, event do |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
340 self:_route_stanza(msg); |
1278
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
341 end |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
342 end |
40f077b18dfe
mod_mam_muc: Override sending of room history and use archives
Kim Alvefur <zash@zash.se>
parents:
1277
diff
changeset
|
343 |
820 | 344 -- Handle messages |
1519
67c80abe742e
mod_mam_muc: Fix add/removal of room method overrides
Kim Alvefur <zash@zash.se>
parents:
1430
diff
changeset
|
345 function save_to_history(self, stanza) |
1279
2118a2eeb1d5
mod_mam_muc: Override method for storing history messages instead of hooking stanza events
Kim Alvefur <zash@zash.se>
parents:
1278
diff
changeset
|
346 local room = jid_split(self.jid); |
820 | 347 |
1279
2118a2eeb1d5
mod_mam_muc: Override method for storing history messages instead of hooking stanza events
Kim Alvefur <zash@zash.se>
parents:
1278
diff
changeset
|
348 -- Policy check |
1542
ccb9dc624ebd
mod_mam_muc: Split logic for determining if logging is enabled into a function
Kim Alvefur <zash@zash.se>
parents:
1541
diff
changeset
|
349 if not logging_enabled(self) then return end -- Don't log |
1143
8098683b6d6f
mod_mam_muc: Allow archiving to be enabled trough in the room configuration
Kim Alvefur <zash@zash.se>
parents:
1142
diff
changeset
|
350 |
1279
2118a2eeb1d5
mod_mam_muc: Override method for storing history messages instead of hooking stanza events
Kim Alvefur <zash@zash.se>
parents:
1278
diff
changeset
|
351 module:log("debug", "We're logging this") |
820 | 352 -- And stash it |
1385
da9469e68dee
mod_mam_muc: Place stanza type in 'with' column; when sending history, only send messages with type=groupchat
daurnimator <quae@daurnimator.com>
parents:
1382
diff
changeset
|
353 local with = stanza.name |
da9469e68dee
mod_mam_muc: Place stanza type in 'with' column; when sending history, only send messages with type=groupchat
daurnimator <quae@daurnimator.com>
parents:
1382
diff
changeset
|
354 if stanza.attr.type then |
da9469e68dee
mod_mam_muc: Place stanza type in 'with' column; when sending history, only send messages with type=groupchat
daurnimator <quae@daurnimator.com>
parents:
1382
diff
changeset
|
355 with = with .. "<" .. stanza.attr.type |
da9469e68dee
mod_mam_muc: Place stanza type in 'with' column; when sending history, only send messages with type=groupchat
daurnimator <quae@daurnimator.com>
parents:
1382
diff
changeset
|
356 end |
1535
efbb047c01e7
mod_mam_muc: Update to XEP-0313 v 0.3
Kim Alvefur <zash@zash.se>
parents:
1534
diff
changeset
|
357 archive:append(room, nil, time_now(), with, stanza); |
820 | 358 end |
359 | |
1543
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
360 module:hook("muc-broadcast-message", function (event) |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
361 local room, stanza = event.room, event.stanza; |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
362 if stanza:get_child("body") then |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
363 save_to_history(room, stanza); |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
364 end |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
365 end); |
57fb9ce21f9c
mod_mam_muc: Add compatibility with the new MUC code in trunk
Kim Alvefur <zash@zash.se>
parents:
1542
diff
changeset
|
366 |
1616
28411e97db94
mod_mam_muc: support to disable presence logging via muc_log_presences
Stuart Carnie <stuart.carnie@gmail.com>
parents:
1571
diff
changeset
|
367 if module:get_option_boolean("muc_log_presences", true) then |
28411e97db94
mod_mam_muc: support to disable presence logging via muc_log_presences
Stuart Carnie <stuart.carnie@gmail.com>
parents:
1571
diff
changeset
|
368 module:hook("muc-occupant-joined", function (event) |
28411e97db94
mod_mam_muc: support to disable presence logging via muc_log_presences
Stuart Carnie <stuart.carnie@gmail.com>
parents:
1571
diff
changeset
|
369 save_to_history(event.room, st.stanza("presence", { from = event.nick })); |
28411e97db94
mod_mam_muc: support to disable presence logging via muc_log_presences
Stuart Carnie <stuart.carnie@gmail.com>
parents:
1571
diff
changeset
|
370 end); |
28411e97db94
mod_mam_muc: support to disable presence logging via muc_log_presences
Stuart Carnie <stuart.carnie@gmail.com>
parents:
1571
diff
changeset
|
371 module:hook("muc-occupant-left", function (event) |
28411e97db94
mod_mam_muc: support to disable presence logging via muc_log_presences
Stuart Carnie <stuart.carnie@gmail.com>
parents:
1571
diff
changeset
|
372 save_to_history(event.room, st.stanza("presence", { type = "unavailable", from = event.nick })); |
28411e97db94
mod_mam_muc: support to disable presence logging via muc_log_presences
Stuart Carnie <stuart.carnie@gmail.com>
parents:
1571
diff
changeset
|
373 end); |
28411e97db94
mod_mam_muc: support to disable presence logging via muc_log_presences
Stuart Carnie <stuart.carnie@gmail.com>
parents:
1571
diff
changeset
|
374 end |
1548
d3c847070618
mod_mam_muc: Store joins and leaves
Kim Alvefur <zash@zash.se>
parents:
1547
diff
changeset
|
375 |
1277
999891a9ae5d
mod_mam_muc: Remove archives when a room is destroyed
Kim Alvefur <zash@zash.se>
parents:
1276
diff
changeset
|
376 module:hook("muc-room-destroyed", function(event) |
1540
0c26b1638f8c
call archive API with username only
Stuart Carnie <stuart.carnie@gmail.com>
parents:
1536
diff
changeset
|
377 local username = jid_split(event.room.jid); |
0c26b1638f8c
call archive API with username only
Stuart Carnie <stuart.carnie@gmail.com>
parents:
1536
diff
changeset
|
378 archive:delete(username); |
1277
999891a9ae5d
mod_mam_muc: Remove archives when a room is destroyed
Kim Alvefur <zash@zash.se>
parents:
1276
diff
changeset
|
379 end); |
999891a9ae5d
mod_mam_muc: Remove archives when a room is destroyed
Kim Alvefur <zash@zash.se>
parents:
1276
diff
changeset
|
380 |
1141
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
381 -- TODO should we perhaps log presence as well? |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
382 -- And role/affiliation changes? |
1091be1c3aba
mod_mam_muc: Switch to new stanza storage API
Kim Alvefur <zash@zash.se>
parents:
1140
diff
changeset
|
383 |
820 | 384 module:add_feature(xmlns_mam); |
1679
c77e9522dc66
mod_mam_muc: Advertise MAM feature on bare JID room disco#info (only effective after prosody 57bc52f67564)
Kim Alvefur <zash@zash.se>
parents:
1650
diff
changeset
|
385 |
c77e9522dc66
mod_mam_muc: Advertise MAM feature on bare JID room disco#info (only effective after prosody 57bc52f67564)
Kim Alvefur <zash@zash.se>
parents:
1650
diff
changeset
|
386 module:hook("muc-disco#info", function(event) |
c77e9522dc66
mod_mam_muc: Advertise MAM feature on bare JID room disco#info (only effective after prosody 57bc52f67564)
Kim Alvefur <zash@zash.se>
parents:
1650
diff
changeset
|
387 event.reply:tag("feature", {var=xmlns_mam}):up(); |
c77e9522dc66
mod_mam_muc: Advertise MAM feature on bare JID room disco#info (only effective after prosody 57bc52f67564)
Kim Alvefur <zash@zash.se>
parents:
1650
diff
changeset
|
388 end); |