aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/muc/history.lib.lua8
-rw-r--r--plugins/muc/mod_muc.lua12
-rw-r--r--plugins/muc/muc.lib.lua20
-rw-r--r--plugins/muc/request.lib.lua9
-rw-r--r--plugins/muc/whois.lib.lua3
5 files changed, 34 insertions, 18 deletions
diff --git a/plugins/muc/history.lib.lua b/plugins/muc/history.lib.lua
index 8a1163cf..445aacb9 100644
--- a/plugins/muc/history.lib.lua
+++ b/plugins/muc/history.lib.lua
@@ -177,8 +177,12 @@ module:hook("muc-add-history", function(event)
stanza.attr.to = "";
local ts = gettime();
local stamp = datetime.datetime(ts);
- stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = module.host, stamp = stamp}):up(); -- XEP-0203
- stanza:tag("x", {xmlns = "jabber:x:delay", from = module.host, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated)
+ stanza:tag("delay", { -- XEP-0203
+ xmlns = "urn:xmpp:delay", from = module.host, stamp = stamp
+ }):up();
+ stanza:tag("x", { -- XEP-0091 (deprecated)
+ xmlns = "jabber:x:delay", from = module.host, stamp = datetime.legacy()
+ }):up();
local entry = { stanza = stanza, timestamp = ts };
table.insert(history, entry);
while #history > get_historylength(room) do table.remove(history, 1) end
diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua
index 825dcdcb..58b13936 100644
--- a/plugins/muc/mod_muc.lua
+++ b/plugins/muc/mod_muc.lua
@@ -320,9 +320,11 @@ module:hook("muc-room-pre-create", function (event)
room:set_public(module:get_option_boolean("muc_room_default_public", false));
room:set_persistent(module:get_option_boolean("muc_room_default_persistent", room:get_persistent()));
room:set_members_only(module:get_option_boolean("muc_room_default_members_only", room:get_members_only()));
- room:set_allow_member_invites(module:get_option_boolean("muc_room_default_allow_member_invites", room:get_allow_member_invites()));
+ room:set_allow_member_invites(module:get_option_boolean("muc_room_default_allow_member_invites",
+ room:get_allow_member_invites()));
room:set_moderated(module:get_option_boolean("muc_room_default_moderated", room:get_moderated()));
- room:set_whois(module:get_option_boolean("muc_room_default_public_jids", room:get_whois() == "anyone") and "anyone" or "moderators");
+ room:set_whois(module:get_option_boolean("muc_room_default_public_jids",
+ room:get_whois() == "anyone") and "anyone" or "moderators");
room:set_changesubject(module:get_option_boolean("muc_room_default_change_subject", room:get_changesubject()));
room:set_historylength(module:get_option_number("muc_room_default_history_length", room:get_historylength()));
room:set_language(event.stanza.attr["xml:lang"] or module:get_option_string("muc_room_default_language"));
@@ -416,7 +418,8 @@ for event_name, method in pairs {
local room = get_room_from_jid(room_jid);
if room and room._data.destroyed then
- if room._data.locked < os.time() or (is_admin(stanza.attr.from) and stanza.name == "presence" and stanza.attr.type == nil) then
+ if room._data.locked < os.time()
+ or (is_admin(stanza.attr.from) and stanza.name == "presence" and stanza.attr.type == nil) then
-- Allow the room to be recreated by admin or after time has passed
delete_room(room);
room = nil;
@@ -487,7 +490,8 @@ do -- Ad-hoc commands
end
return { status = "completed", info = "The following rooms were destroyed:\n"..t_concat(fields.rooms, "\n") };
end);
- local destroy_rooms_desc = adhoc_new("Destroy Rooms", "http://prosody.im/protocol/muc#destroy", destroy_rooms_handler, "admin");
+ local destroy_rooms_desc = adhoc_new("Destroy Rooms",
+ "http://prosody.im/protocol/muc#destroy", destroy_rooms_handler, "admin");
module:provides("adhoc", destroy_rooms_desc);
end
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index 89344c53..d12f24b1 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -492,7 +492,8 @@ function room_mt:handle_normal_presence(origin, stanza)
if orig_occupant == nil and not muc_x and stanza.attr.type == nil then
module:log("debug", "Attempted join without <x>, possibly desynced");
- origin.send(st.error_reply(stanza, "cancel", "item-not-found", "You must join the room before sending presence updates"));
+ origin.send(st.error_reply(stanza, "cancel", "item-not-found",
+ "You must join the room before sending presence updates"));
return true;
end
@@ -591,7 +592,8 @@ function room_mt:handle_normal_presence(origin, stanza)
orig_occupant:remove_session(real_jid);
log("debug", "generating nick change for %s", real_jid);
local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user";});
- -- self:build_item_list(orig_occupant, x, false, dest_nick); -- COMPAT: clients get confused if they see other items besides their own
+ -- COMPAT: clients get confused if they see other items besides their own
+ -- self:build_item_list(orig_occupant, x, false, dest_nick);
add_item(x, self:get_affiliation(bare_jid), orig_occupant.role, real_jid, dest_nick);
x:tag("status", {code = "303";}):up();
x:tag("status", {code = "110";}):up();
@@ -635,7 +637,8 @@ function room_mt:handle_normal_presence(origin, stanza)
end
self:publicise_occupant_status(dest_occupant, {base=dest_x,self=self_x});
- if orig_occupant ~= nil and orig_occupant ~= dest_occupant and not is_last_orig_session then -- If user is swapping and wasn't last original session
+ if orig_occupant ~= nil and orig_occupant ~= dest_occupant and not is_last_orig_session then
+ -- If user is swapping and wasn't last original session
log("debug", "session %s split nicks; showing %s rejoining", real_jid, orig_occupant.nick);
-- Show the original nick joining again
local pr = st.clone(orig_occupant:get_presence());
@@ -892,7 +895,8 @@ function room_mt:handle_admin_query_set_command(origin, stanza)
return true;
end
end
- if not item.attr.jid and item.attr.nick then -- COMPAT Workaround for Miranda sending 'nick' instead of 'jid' when changing affiliation
+ if not item.attr.jid and item.attr.nick then
+ -- COMPAT Workaround for Miranda sending 'nick' instead of 'jid' when changing affiliation
local occupant = self:get_occupant_by_nick(self.jid.."/"..item.attr.nick);
if occupant then item.attr.jid = occupant.jid; end
elseif not item.attr.nick and item.attr.jid then
@@ -1131,9 +1135,8 @@ module:hook("muc-decline", function(event)
if not stanza:get_child("body") then
local decline = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("decline");
local reason = decline:get_child_text("reason") or "";
- stanza:tag("body")
- :text(decline.attr.from.." declined your invite to the room "..room.jid..(reason ~= "" and (" ("..reason..")") or ""))
- :up();
+ stanza:body(decline.attr.from.." declined your invite to the room "
+ ..room.jid..(reason ~= "" and (" ("..reason..")") or ""));
end
end);
@@ -1173,8 +1176,9 @@ end
function room_mt:get_affiliation(jid)
local node, host, resource = jid_split(jid);
+ -- Affiliations are granted, revoked, and maintained based on the user's bare JID.
local bare = node and node.."@"..host or host;
- local result = self._affiliations[bare]; -- Affiliations are granted, revoked, and maintained based on the user's bare JID.
+ local result = self._affiliations[bare];
if not result and self._affiliations[host] == "outcast" then result = "outcast"; end -- host banned
return result;
end
diff --git a/plugins/muc/request.lib.lua b/plugins/muc/request.lib.lua
index 1bf02e55..1d9c39f9 100644
--- a/plugins/muc/request.lib.lua
+++ b/plugins/muc/request.lib.lua
@@ -81,7 +81,8 @@ module:hook("muc-voice-request", function(event)
["muc#roomnick"] = nick;
};
- local message = st.message({ type = "normal"; from = event.room.jid }):add_child(voice_request_form:form(formdata)):up();
+ local message = st.message({ type = "normal"; from = event.room.jid })
+ :add_direct_child(voice_request_form:form(formdata));
event.room:broadcast(message, function (_, occupant)
return occupant.role == "moderator";
@@ -105,12 +106,14 @@ module:hook("muc-voice-response", function(event)
end
if not affected_occupant then
- module:log("debug", "%s tried to grant voice to unknown occupant %s", jid_resource(occupant.nick), event.fields["muc#jid"]);
+ module:log("debug", "%s tried to grant voice to unknown occupant %s",
+ jid_resource(occupant.nick), event.fields["muc#jid"]);
return;
end
if affected_occupant.role ~= "visitor" then
- module:log("debug", "%s tried to grant voice to %s but they already have it", jid_resource(occupant.nick), jid_resource(occupant.jid));
+ module:log("debug", "%s tried to grant voice to %s but they already have it",
+ jid_resource(occupant.nick), jid_resource(occupant.jid));
return;
end
diff --git a/plugins/muc/whois.lib.lua b/plugins/muc/whois.lib.lua
index c81ff042..f3070ddf 100644
--- a/plugins/muc/whois.lib.lua
+++ b/plugins/muc/whois.lib.lua
@@ -24,7 +24,8 @@ local function set_whois(room, whois)
end
module:hook("muc-disco#info", function(event)
- event.reply:tag("feature", {var = get_whois(event.room) ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up();
+ local whois = get_whois(event.room) ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous";
+ event.reply:tag("feature", { var = whois }):up();
end);
module:hook("muc-config-form", function(event)