FIX: relies only on staff? and prefer defined? for memoization

FIX: relies only on staff? and prefer defined? for memoization

diff --git a/plugin.rb b/plugin.rb
index e0be3b4..5a4a32d 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -127,18 +127,18 @@ after_initialize do
   end
 
   add_to_class(:user, :can_create_event?) do
-    @can_create_event ||=
-      begin
-        return true if admin? || staff?
-        allowed_groups = SiteSetting.discourse_post_event_allowed_on_groups.split('|').compact
-        allowed_groups.present? && groups.where(id: allowed_groups).exists? ?
-          :true : :false
-      end
-    @can_create_event == :true
+    return @can_create_event if defined?(@can_create_event)
+    @can_create_event = begin
+      return true if staff?
+      allowed_groups = SiteSetting.discourse_post_event_allowed_on_groups.split('|').compact
+      allowed_groups.present? && groups.where(id: allowed_groups).exists?
+    rescue
+      false
+    end
   end
 
   add_to_class(:guardian, :can_act_on_invitee?) do |invitee|
-    user && (user.staff? || user.admin? || user.id == invitee.user_id)
+    user && (user.staff? || user.id == invitee.user_id)
   end
 
   add_to_class(:guardian, :can_create_event?) { user && user.can_create_event? }
@@ -148,12 +148,13 @@ after_initialize do
   end
 
   add_to_class(:user, :can_act_on_event?) do |event|
-    @can_act_on_event ||=
-      begin
-        return true if admin? || staff?
-        can_create_event? && event.post.user_id == id ? :true : :false
-      end
-    @can_act_on_event == :true
+    return @can_act_on_event if defined?(@can_act_on_event)
+    @can_act_on_event = begin
+      return true if admin?
+      can_create_event? && event.post.user_id == id
+    rescue
+      false
+    end
   end
 
   add_to_class(:guardian, :can_act_on_event?) { |event| user && user.can_act_on_event?(event) }

GitHub sha: 4e7c7989