From 1ac5226b10d7cbf801cb95553707a20a412f42be Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Sun, 29 Nov 2020 23:46:53 -0600 Subject: Allow republishing --- app/services/publish_status_service.rb | 11 ++++++----- app/services/update_status_service.rb | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'app/services') diff --git a/app/services/publish_status_service.rb b/app/services/publish_status_service.rb index e95c3dacd..351bcd7f3 100644 --- a/app/services/publish_status_service.rb +++ b/app/services/publish_status_service.rb @@ -3,26 +3,27 @@ class PublishStatusService < BaseService include Redisable def call(status) - return if status.published? - - @status = status + @status = status + republishing = status.published? + status.notify = false if republishing update_status! reset_status_caches distribute - bump_potential_friendship! + bump_potential_friendship! unless republishing end private def update_status! - @status.update!(published: true, publish_at: nil, expires_at: @status.expires_at.blank? ? nil : Time.now.utc + (@status.expires_at - @status.created_at)) + @status.update!(published: true, publish_at: nil, created_at: Time.now.utc - 1.second, expires_at: @status.expires_at.blank? ? nil : Time.now.utc + (@status.expires_at - @status.created_at)) ProcessMentionsService.new.call(@status) end def reset_status_caches Rails.cache.delete_matched("statuses/#{@status.id}-*") Rails.cache.delete("statuses/#{@status.id}") + Rails.cache.delete("statuses/*:#{@status.id}") Rails.cache.delete(@status) Rails.cache.delete_matched("format:#{@status.id}:*") redis.zremrangebyscore("spam_check:#{@status.account.id}", @status.id, @status.id) diff --git a/app/services/update_status_service.rb b/app/services/update_status_service.rb index 1765f95cc..1f5876353 100644 --- a/app/services/update_status_service.rb +++ b/app/services/update_status_service.rb @@ -141,6 +141,7 @@ class UpdateStatusService < BaseService def reset_status_caches Rails.cache.delete_matched("statuses/#{@status.id}-*") Rails.cache.delete("statuses/#{@status.id}") + Rails.cache.delete("statuses/*:#{@status.id}") Rails.cache.delete(@status) Rails.cache.delete_matched("format:#{@status.id}:*") redis.zremrangebyscore("spam_check:#{@account.id}", @status.id, @status.id) -- cgit