summaryrefslogtreecommitdiff
path: root/app/services/concerns/akismet_methods.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/concerns/akismet_methods.rb')
-rw-r--r--app/services/concerns/akismet_methods.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/services/concerns/akismet_methods.rb b/app/services/concerns/akismet_methods.rb
new file mode 100644
index 00000000000..1cbcf0d47b9
--- /dev/null
+++ b/app/services/concerns/akismet_methods.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module AkismetMethods
+ def spammable_owner
+ @user ||= User.find(spammable_owner_id)
+ end
+
+ def spammable_owner_id
+ @owner_id ||=
+ if spammable.respond_to?(:author_id)
+ spammable.author_id
+ elsif spammable.respond_to?(:creator_id)
+ spammable.creator_id
+ end
+ end
+
+ def akismet
+ @akismet ||= AkismetService.new(
+ spammable_owner.name,
+ spammable_owner.email,
+ spammable.spammable_text,
+ options
+ )
+ end
+end