Software /
code /
prosody-modules
Comparison
mod_muc_search/mod_muc_search.lua @ 4137:5f4bcaad18ee
mod_muc_search: Some changes predating version control
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 17 Aug 2018 11:16:46 +0200 |
parent | 4136:d2a9aa27169d |
comparison
equal
deleted
inserted
replaced
4136:d2a9aa27169d | 4137:5f4bcaad18ee |
---|---|
1 -- mod_muc_search | |
2 -- https://muclumbus.jabbercat.org/docs/api#xmpp | |
3 -- TODO | |
4 -- Result set management (pagination, limits) | |
5 -- Sorting | |
6 -- min_users | |
7 | |
1 local dataforms = require "util.dataforms"; | 8 local dataforms = require "util.dataforms"; |
2 local st = require "util.stanza"; | 9 local st = require "util.stanza"; |
3 | 10 |
4 local mod_muc = module:depends("muc"); | 11 local mod_muc = module:depends("muc"); |
5 assert(mod_muc.live_rooms, "Missing required MUC API. Prosody >= hg:f5c43e829d93 required") | 12 assert(mod_muc.live_rooms, "Missing required MUC API. Prosody >= hg:f5c43e829d93 required"); |
6 | 13 |
7 local search_form = dataforms.new { | 14 local search_form = dataforms.new { |
8 { | 15 { |
9 type = "hidden"; | 16 type = "hidden"; |
10 value = "https://xmlns.zombofant.net/muclumbus/search/1.0#params"; | 17 value = "https://xmlns.zombofant.net/muclumbus/search/1.0#params"; |
77 module:log("debug", "Got query: %q", query); | 84 module:log("debug", "Got query: %q", query); |
78 | 85 |
79 local result = st.reply(stanza) | 86 local result = st.reply(stanza) |
80 :tag("result", { xmlns = "https://xmlns.zombofant.net/muclumbus/search/1.0" }); | 87 :tag("result", { xmlns = "https://xmlns.zombofant.net/muclumbus/search/1.0" }); |
81 | 88 |
82 for room in mod_muc.live_rooms() do | 89 for room in mod_muc.live_rooms() do -- TODO s/live/all/ but preferably along with pagination/rsm |
83 | |
84 if room:get_public() and not room:get_members_only() then | 90 if room:get_public() and not room:get_members_only() then |
85 module:log("debug", "Looking at room %s %q", room.jid, room._data); | 91 module:log("debug", "Looking at room %s %q", room.jid, room._data); |
86 if (query.sinname and room:get_name():find(query.q, 1, true)) | 92 if (query.sinname and room:get_name():find(query.q, 1, true)) |
87 or (query.sindescription and (room:get_description() or ""):find(query.q, 1, true)) | 93 or (query.sindescription and (room:get_description() or ""):find(query.q, 1, true)) |
88 or (query.sinaddr and room.jid:find(query.q, 1, true)) then | 94 or (query.sinaddr and room.jid:find(query.q, 1, true)) then |