comparison mod_http_muc_log/mod_http_muc_log.lua @ 4970:8c7b7db69f5b

mod_http_muc_log: Drop support for pre-0.11 MUC API The oldest supported Prosody branch is 0.11, therefore we can drop code for the MUC API of Prosody 0.10 and before. The module:shared("rooms") method was never even in a release...
author Kim Alvefur <zash@zash.se>
date Sat, 02 Jul 2022 02:30:02 +0200
parents 479d618c9e6d
children 3bcefa9cf1ca
comparison
equal deleted inserted replaced
4969:889e1695e935 4970:8c7b7db69f5b
1 local mt = require"util.multitable"; 1 local mt = require"util.multitable";
2 local datetime = require"util.datetime"; 2 local datetime = require"util.datetime";
3 local jid_split = require"util.jid".split; 3 local jid_split = require"util.jid".split;
4 local nodeprep = require"util.encodings".stringprep.nodeprep; 4 local nodeprep = require"util.encodings".stringprep.nodeprep;
5 local it = require"util.iterators";
6 local url = require"socket.url"; 5 local url = require"socket.url";
7 local os_time, os_date = os.time, os.date; 6 local os_time, os_date = os.time, os.date;
8 local httplib = require "util.http"; 7 local httplib = require "util.http";
9 local render_funcs = {}; 8 local render_funcs = {};
10 local render = require"util.interpolation".new("%b{}", require"util.stanza".xml_escape, render_funcs); 9 local render = require"util.interpolation".new("%b{}", require"util.stanza".xml_escape, render_funcs);
11 10
12 local archive = module:open_store("muc_log", "archive"); 11 local archive = module:open_store("muc_log", "archive");
13 12
14 -- Support both old and new MUC code 13 -- Prosody 0.11+ MUC API
15 local mod_muc = module:depends"muc"; 14 local mod_muc = module:depends"muc";
16 local rooms = rawget(mod_muc, "rooms"); 15 local each_room = mod_muc.each_room;
17 local each_room = rawget(mod_muc, "each_room") or function() return it.values(rooms); end; 16 local get_room_from_jid = mod_muc.get_room_from_jid;
18 local new_muc = not rooms;
19 if new_muc then
20 rooms = module:shared"muc/rooms";
21 end
22 local get_room_from_jid = rawget(mod_muc, "get_room_from_jid") or
23 function (jid)
24 return rooms[jid];
25 end
26 17
27 local function get_room(name) 18 local function get_room(name)
28 local jid = name .. '@' .. module.host; 19 local jid = name .. '@' .. module.host;
29 return get_room_from_jid(jid); 20 return get_room_from_jid(jid);
30 end 21 end