Comparison

plugins/muc/mod_muc.lua @ 9081:ce57c69a20e2

MUC: Split long lines [luacheck strict]
author Kim Alvefur <zash@zash.se>
date Fri, 03 Aug 2018 17:48:41 +0200
parent 9079:c040c358d6c0
child 9093:04a284c5b88b
comparison
equal deleted inserted replaced
9080:1b21f8ffaec8 9081:ce57c69a20e2
318 module:hook("muc-room-pre-create", function (event) 318 module:hook("muc-room-pre-create", function (event)
319 local room = event.room; 319 local room = event.room;
320 room:set_public(module:get_option_boolean("muc_room_default_public", false)); 320 room:set_public(module:get_option_boolean("muc_room_default_public", false));
321 room:set_persistent(module:get_option_boolean("muc_room_default_persistent", room:get_persistent())); 321 room:set_persistent(module:get_option_boolean("muc_room_default_persistent", room:get_persistent()));
322 room:set_members_only(module:get_option_boolean("muc_room_default_members_only", room:get_members_only())); 322 room:set_members_only(module:get_option_boolean("muc_room_default_members_only", room:get_members_only()));
323 room:set_allow_member_invites(module:get_option_boolean("muc_room_default_allow_member_invites", room:get_allow_member_invites())); 323 room:set_allow_member_invites(module:get_option_boolean("muc_room_default_allow_member_invites",
324 room:get_allow_member_invites()));
324 room:set_moderated(module:get_option_boolean("muc_room_default_moderated", room:get_moderated())); 325 room:set_moderated(module:get_option_boolean("muc_room_default_moderated", room:get_moderated()));
325 room:set_whois(module:get_option_boolean("muc_room_default_public_jids", room:get_whois() == "anyone") and "anyone" or "moderators"); 326 room:set_whois(module:get_option_boolean("muc_room_default_public_jids",
327 room:get_whois() == "anyone") and "anyone" or "moderators");
326 room:set_changesubject(module:get_option_boolean("muc_room_default_change_subject", room:get_changesubject())); 328 room:set_changesubject(module:get_option_boolean("muc_room_default_change_subject", room:get_changesubject()));
327 room:set_historylength(module:get_option_number("muc_room_default_history_length", room:get_historylength())); 329 room:set_historylength(module:get_option_number("muc_room_default_history_length", room:get_historylength()));
328 room:set_language(event.stanza.attr["xml:lang"] or module:get_option_string("muc_room_default_language")); 330 room:set_language(event.stanza.attr["xml:lang"] or module:get_option_string("muc_room_default_language"));
329 end, 1); 331 end, 1);
330 332
414 local origin, stanza = event.origin, event.stanza; 416 local origin, stanza = event.origin, event.stanza;
415 local room_jid = jid_bare(stanza.attr.to); 417 local room_jid = jid_bare(stanza.attr.to);
416 local room = get_room_from_jid(room_jid); 418 local room = get_room_from_jid(room_jid);
417 419
418 if room and room._data.destroyed then 420 if room and room._data.destroyed then
419 if room._data.locked < os.time() or (is_admin(stanza.attr.from) and stanza.name == "presence" and stanza.attr.type == nil) then 421 if room._data.locked < os.time()
422 or (is_admin(stanza.attr.from) and stanza.name == "presence" and stanza.attr.type == nil) then
420 -- Allow the room to be recreated by admin or after time has passed 423 -- Allow the room to be recreated by admin or after time has passed
421 delete_room(room); 424 delete_room(room);
422 room = nil; 425 room = nil;
423 else 426 else
424 if stanza.attr.type ~= "error" then 427 if stanza.attr.type ~= "error" then
485 for _, room in ipairs(fields.rooms) do 488 for _, room in ipairs(fields.rooms) do
486 get_room_from_jid(room):destroy(); 489 get_room_from_jid(room):destroy();
487 end 490 end
488 return { status = "completed", info = "The following rooms were destroyed:\n"..t_concat(fields.rooms, "\n") }; 491 return { status = "completed", info = "The following rooms were destroyed:\n"..t_concat(fields.rooms, "\n") };
489 end); 492 end);
490 local destroy_rooms_desc = adhoc_new("Destroy Rooms", "http://prosody.im/protocol/muc#destroy", destroy_rooms_handler, "admin"); 493 local destroy_rooms_desc = adhoc_new("Destroy Rooms",
494 "http://prosody.im/protocol/muc#destroy", destroy_rooms_handler, "admin");
491 495
492 module:provides("adhoc", destroy_rooms_desc); 496 module:provides("adhoc", destroy_rooms_desc);
493 end 497 end