diff options
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/fan_out_on_write_service.rb | 7 | ||||
-rw-r--r-- | app/services/process_hashtags_service.rb | 2 | ||||
-rw-r--r-- | app/services/remove_hashtags_service.rb | 21 | ||||
-rw-r--r-- | app/services/remove_status_service.rb | 6 | ||||
-rw-r--r-- | app/services/revoke_status_service.rb | 10 | ||||
-rw-r--r-- | app/services/update_status_service.rb | 12 |
6 files changed, 37 insertions, 21 deletions
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index 2e3061b07..8a37c7695 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -31,11 +31,8 @@ class FanOutOnWriteService < BaseService return end - return unless status.public_visibility? - - deliver_to_hashtags(status) - - return if status.reply? && status.in_reply_to_account_id != status.account_id && !Setting.show_replies_in_public_timelines + deliver_to_hashtags(status) if status.distributable? + return if !status.public_visibility? || (status.reply? && status.in_reply_to_account_id != status.account_id) deliver_to_media(status) if status.media_attachments.any? deliver_to_public(status) if status.local? diff --git a/app/services/process_hashtags_service.rb b/app/services/process_hashtags_service.rb index 1f0d64323..5ec5ea0c2 100644 --- a/app/services/process_hashtags_service.rb +++ b/app/services/process_hashtags_service.rb @@ -13,7 +13,7 @@ class ProcessHashtagsService < BaseService status.tags << tag records << tag - TrendingTags.record_use!(tag, status.account, status.created_at) if status.public_visibility? + TrendingTags.record_use!(tag, status.account, status.created_at) if status.distributable? end return unless status.distributable? diff --git a/app/services/remove_hashtags_service.rb b/app/services/remove_hashtags_service.rb new file mode 100644 index 000000000..6bf77a068 --- /dev/null +++ b/app/services/remove_hashtags_service.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class RemoveHashtagsService < BaseService + def call(status, tags) + tags = status.tags.matching_name(tags) if tags.is_a?(Array) + + status.account.featured_tags.where(tag: tags).each do |featured_tag| + featured_tag.decrement(status.id) + end + + if status.distributable? + delete_payload = Oj.dump(event: :delete, payload: status.id.to_s) + tags.pluck(:name).each do |hashtag| + redis.publish("timeline:hashtag:#{hashtag.mb_chars.downcase}", delete_payload) + redis.publish("timeline:hashtag:#{hashtag.mb_chars.downcase}:local", delete_payload) if status.local? + end + end + + status.tags -= tags + end +end diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb index 4d3dc13db..72ef6a9ec 100644 --- a/app/services/remove_status_service.rb +++ b/app/services/remove_status_service.rb @@ -139,7 +139,7 @@ class RemoveStatusService < BaseService featured_tag.decrement(@status.id) end - return unless @status.public_visibility? + return unless @status.distributable? @tags.each do |hashtag| redis.publish("timeline:hashtag:#{hashtag.mb_chars.downcase}", @payload) @@ -148,7 +148,7 @@ class RemoveStatusService < BaseService end def remove_from_public - return unless @status.public_visibility? + return unless @status.distributable? redis.publish('timeline:public', @payload) if @status.local? @@ -159,7 +159,7 @@ class RemoveStatusService < BaseService end def remove_from_media - return unless @status.public_visibility? + return unless @status.distributable? redis.publish('timeline:public:media', @payload) if @status.local? diff --git a/app/services/revoke_status_service.rb b/app/services/revoke_status_service.rb index b7d7a6e18..95810acd2 100644 --- a/app/services/revoke_status_service.rb +++ b/app/services/revoke_status_service.rb @@ -12,7 +12,7 @@ class RevokeStatusService < BaseService @status = status @account = status.account @account_ids = account_ids - @mentions = status.active_mentions.where(account_id: account_ids) + @mentions = status.mentions.where(account_id: account_ids) @reblogs = status.reblogs.where(account_id: account_ids) RedisLock.acquire(lock_options) do |lock| @@ -21,7 +21,7 @@ class RevokeStatusService < BaseService remove_from_lists remove_from_affected remove_reblogs - remove_from_hashtags unless @status.distributable? + remove_from_hashtags remove_from_public remove_from_media remove_from_direct if status.direct_visibility? @@ -62,7 +62,7 @@ class RevokeStatusService < BaseService featured_tag.decrement(@status.id) end - return unless @status.public_visibility? + return unless @status.distributable? @tags.each do |hashtag| redis.publish("timeline:hashtag:#{hashtag.mb_chars.downcase}", @payload) @@ -71,7 +71,7 @@ class RevokeStatusService < BaseService end def remove_from_public - return if @status.public_visibility? + return if @status.distributable? redis.publish('timeline:public', @payload) if @status.local? @@ -82,7 +82,7 @@ class RevokeStatusService < BaseService end def remove_from_media - return if @status.public_visibility? + return if @status.distributable? redis.publish('timeline:public:media', @payload) if @status.local? diff --git a/app/services/update_status_service.rb b/app/services/update_status_service.rb index 015010588..d0e61d153 100644 --- a/app/services/update_status_service.rb +++ b/app/services/update_status_service.rb @@ -89,13 +89,11 @@ class UpdateStatusService < BaseService featured_tag.decrement(@status.id) end - if @status.public_visibility? - return if @deleted_tag_names.blank? + return unless @status.distributable? && @deleted_tag_names.present? - @deleted_tag_names.each do |hashtag| - redis.publish("timeline:hashtag:#{hashtag.mb_chars.downcase}", @delete_payload) - redis.publish("timeline:hashtag:#{hashtag.mb_chars.downcase}:local", @delete_payload) if @status.local? - end + @deleted_tag_names.each do |hashtag| + redis.publish("timeline:hashtag:#{hashtag.mb_chars.downcase}", @delete_payload) + redis.publish("timeline:hashtag:#{hashtag.mb_chars.downcase}:local", @delete_payload) if @status.local? end end @@ -124,7 +122,7 @@ class UpdateStatusService < BaseService @status.tags << tag new_tag_ids << tag.id - TrendingTags.record_use!(tag, @account, now) if @status.public_visibility? + TrendingTags.record_use!(tag, @account, now) if @status.distributable? end return unless @status.local? && @status.distributable? |