# HG changeset patch
# User Stephen Paul Weber <singpolyma@singpolyma.net>
# Date 1714507563 18000
# Node ID 5b95e06d75d5a9e60dc06659febbb7c05c0ab80a
# Parent  66e7d46b1d4b90d9848ed348aa61d46d5cd748a3
Guard for not room

diff -r 66e7d46b1d4b -r 5b95e06d75d5 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