Guard for not room
authorStephen Paul Weber <singpolyma@singpolyma.net>
Tue, 30 Apr 2024 15:06:03 -0500
changeset 5900 5b95e06d75d5
parent 5885 66e7d46b1d4b
child 5901 896e7c7bf87f
Guard for not room
mod_muc_restrict_avatars/mod_muc_restrict_avatars.lua
--- a/mod_muc_restrict_avatars/mod_muc_restrict_avatars.lua	Tue Apr 09 14:44:52 2024 -0500
+++ b/mod_muc_restrict_avatars/mod_muc_restrict_avatars.lua	Tue Apr 30 15:06:03 2024 -0500
@@ -30,7 +30,7 @@
 	local room, fields, changed = event.room, event.fields, event.changed;
 	local restrict_avatars = fields["restrict_avatars"];
 
-	if restrict_avatars ~= is_avatar_restriction_enabled(room) then
+	if room and restrict_avatars ~= is_avatar_restriction_enabled(room) then
 		-- Update room settings based on the submitted value
 		room._data.restrict_avatars = restrict_avatars;
 		-- Mark the configuration as changed
@@ -46,7 +46,7 @@
 module:hook("presence/full", function(event)
 	local stanza = event.stanza;
 	local room = mod_muc.get_room_from_jid(bare_jid(stanza.attr.to));
-	if not room:get_affiliation(stanza.attr.from) then
+	if room and not room:get_affiliation(stanza.attr.from) then
 		if is_avatar_restriction_enabled(room) then
 			stanza:maptags(filter_avatar_advertisement);
 		end