FIX: Send blog attribute to Akismet to improve accuracy and false positives detection

FIX: Send blog attribute to Akismet to improve accuracy and false positives detection

diff --git a/lib/discourse_akismet/posts_bouncer.rb b/lib/discourse_akismet/posts_bouncer.rb
index fc328eb..69765f7 100644
--- a/lib/discourse_akismet/posts_bouncer.rb
+++ b/lib/discourse_akismet/posts_bouncer.rb
@@ -67,6 +67,7 @@ module DiscourseAkismet
 
     def args_for(post)
       extra_args = {
+        blog: Discourse.base_url,
         content_type: 'forum-post',
         referrer: post.custom_fields['AKISMET_REFERRER'],
         permalink: "#{Discourse.base_url}#{post.url}",
diff --git a/lib/discourse_akismet/users_bouncer.rb b/lib/discourse_akismet/users_bouncer.rb
index f65b8f9..cee8f86 100644
--- a/lib/discourse_akismet/users_bouncer.rb
+++ b/lib/discourse_akismet/users_bouncer.rb
@@ -21,6 +21,29 @@ module DiscourseAkismet
         user.user_auth_token_logs&.last&.client_ip.present?
     end
 
+    def args_for(user)
+      profile = user.user_profile
+      token = user.user_auth_token_logs.last
+
+      extra_args = {
+        blog: Discourse.base_url,
+        content_type: 'signup',
+        permalink: "#{Discourse.base_url}/u/#{user.username_lower}",
+        comment_author: user.username,
+        comment_content: profile.bio_raw,
+        comment_author_url: profile.website,
+        user_ip: token.client_ip.to_s,
+        user_agent: token.user_agent
+      }
+
+      # Sending the email to akismet is optional
+      if SiteSetting.akismet_transmit_email?
+        extra_args[:comment_author_email] = user.email
+      end
+
+      extra_args
+    end
+
     private
 
     def enqueue_job(user)
@@ -51,27 +74,5 @@ module DiscourseAkismet
         )
       end
     end
-
-    def args_for(user)
-      profile = user.user_profile
-      token = user.user_auth_token_logs.last
-
-      extra_args = {
-        content_type: 'signup',
-        permalink: "#{Discourse.base_url}/u/#{user.username_lower}",
-        comment_author: user.username,
-        comment_content: profile.bio_raw,
-        comment_author_url: profile.website,
-        user_ip: token.client_ip.to_s,
-        user_agent: token.user_agent
-      }
-
-      # Sending the email to akismet is optional
-      if SiteSetting.akismet_transmit_email?
-        extra_args[:comment_author_email] = user.email
-      end
-
-      extra_args
-    end
   end
 end
diff --git a/spec/lib/posts_bouncer_spec.rb b/spec/lib/posts_bouncer_spec.rb
index 3d213ba..02eabc9 100644
--- a/spec/lib/posts_bouncer_spec.rb
+++ b/spec/lib/posts_bouncer_spec.rb
@@ -30,6 +30,7 @@ describe DiscourseAkismet::PostsBouncer do
       expect(result[:user_agent]).to eq('Discourse Agent')
       expect(result[:comment_author]).to eq(post.user.username)
       expect(result[:comment_author_email]).to eq(post.user.email)
+      expect(result[:blog]).to eq(Discourse.base_url)
     end
 
     it "will omit email if the site setting is enabled" do
diff --git a/spec/lib/users_bouncer_spec.rb b/spec/lib/users_bouncer_spec.rb
index ddc5d88..9343b71 100644
--- a/spec/lib/users_bouncer_spec.rb
+++ b/spec/lib/users_bouncer_spec.rb
@@ -17,6 +17,23 @@ RSpec.describe DiscourseAkismet::UsersBouncer do
     SiteSetting.akismet_api_key = 'fake_key'
   end
 
+  describe '#args_for' do
+    it "returns args for a user" do
+      profile = user.user_profile
+      token = user.user_auth_token_logs.last
+
+      result = subject.args_for(user)
+      expect(result[:content_type]).to eq('signup')
+      expect(result[:permalink]).to eq("#{Discourse.base_url}/u/#{user.username_lower}")
+      expect(result[:comment_author]).to eq(user.username)
+      expect(result[:comment_content]).to eq(profile.bio_raw)
+      expect(result[:comment_author_url]).to eq(profile.website)
+      expect(result[:user_ip]).to eq(token.client_ip.to_s)
+      expect(result[:user_agent]).to eq(token.user_agent)
+      expect(result[:blog]).to eq(Discourse.base_url)
+    end
+  end
+
   describe "#should_check?" do
 
     it "returns false when setting is disabled" do

GitHub sha: 63690f8a