about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-01-20 13:56:37 +0100
committerGitHub <noreply@github.com>2019-01-20 13:56:37 +0100
commitaa362ab73dc7121104b3c01800152b9fc56ea396 (patch)
treef0f5879a51325856887a2e32a4c3f9654af61aab /app/models
parent530d29148ca0c5bf29f6fa516b1ef4f91d95894b (diff)
parent5145c81620efbd5cf8dc911858d17d1fa888c996 (diff)
Merge pull request #888 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/models')
-rw-r--r--app/models/status.rb4
-rw-r--r--app/models/tombstone.rb16
-rw-r--r--app/models/user.rb3
3 files changed, 20 insertions, 3 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index e709b16c8..4566c0d20 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -504,7 +504,7 @@ class Status < ApplicationRecord
     return if direct_visibility?
 
     account&.increment_count!(:statuses_count)
-    reblog&.increment_count!(:reblogs_count) if reblog?
+    reblog&.increment_count!(:reblogs_count) if reblog? && (public_visibility? || unlisted_visibility?)
     thread&.increment_count!(:replies_count) if in_reply_to_id.present? && (public_visibility? || unlisted_visibility?)
   end
 
@@ -512,7 +512,7 @@ class Status < ApplicationRecord
     return if direct_visibility? || marked_for_mass_destruction?
 
     account&.decrement_count!(:statuses_count)
-    reblog&.decrement_count!(:reblogs_count) if reblog?
+    reblog&.decrement_count!(:reblogs_count) if reblog? && (public_visibility? || unlisted_visibility?)
     thread&.decrement_count!(:replies_count) if in_reply_to_id.present? && (public_visibility? || unlisted_visibility?)
   end
 
diff --git a/app/models/tombstone.rb b/app/models/tombstone.rb
new file mode 100644
index 000000000..997bb65fd
--- /dev/null
+++ b/app/models/tombstone.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+# == Schema Information
+#
+# Table name: tombstones
+#
+#  id         :bigint(8)        not null, primary key
+#  account_id :bigint(8)
+#  uri        :string           not null
+#  created_at :datetime         not null
+#  updated_at :datetime         not null
+#
+
+class Tombstone < ApplicationRecord
+  belongs_to :account
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index 83ccce948..0425c1772 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -362,7 +362,8 @@ class User < ApplicationRecord
   end
 
   def regenerate_feed!
-    Redis.current.setnx("account:#{account_id}:regeneration", true) && Redis.current.expire("account:#{account_id}:regeneration", 1.day.seconds)
+    return unless Redis.current.setnx("account:#{account_id}:regeneration", true)
+    Redis.current.expire("account:#{account_id}:regeneration", 1.day.seconds)
     RegenerationWorker.perform_async(account_id)
   end