diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-10-22 17:51:38 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2018-10-22 17:51:38 +0200 |
commit | dcded13a996e1b6b87444641eed66fc2d117e1af (patch) | |
tree | 1be2c25853e7196a38b0bebc13e9f5281a24d908 /app/services | |
parent | 4739e0f090a04235669ef81fa432ae90bb62f4c4 (diff) | |
parent | 4f0bdbaaaf6828d7ee6fd6e6023375b727c0afe5 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - .github/ISSUE_TEMPLATE/bug_report.md Took our version. - CONTRIBUTING.md Updated the embedded copy of upstream's version. - README.md Took our version. - app/policies/status_policy.rb Not a real conflict, took code from both. - app/views/layouts/embedded.html.haml Added upstream's changes (dns-prefetch) and fixed `%body.embed` - app/views/settings/preferences/show.html.haml Reverted some of upstream changes, as we have a page dedicated for flavours and skins. - config/initializers/content_security_policy.rb Kept our version of the CSP. - config/initializers/doorkeeper.rb Not a real conflict, took code from both.
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/batched_remove_status_service.rb | 13 | ||||
-rw-r--r-- | app/services/fan_out_on_write_service.rb | 19 | ||||
-rw-r--r-- | app/services/notify_service.rb | 5 | ||||
-rw-r--r-- | app/services/remove_status_service.rb | 10 |
4 files changed, 11 insertions, 36 deletions
diff --git a/app/services/batched_remove_status_service.rb b/app/services/batched_remove_status_service.rb index ebb4034aa..b8ab58938 100644 --- a/app/services/batched_remove_status_service.rb +++ b/app/services/batched_remove_status_service.rb @@ -12,7 +12,7 @@ class BatchedRemoveStatusService < BaseService def call(statuses) statuses = Status.where(id: statuses.map(&:id)).includes(:account, :stream_entry).flat_map { |status| [status] + status.reblogs.includes(:account, :stream_entry).to_a } - @mentions = statuses.map { |s| [s.id, s.mentions.includes(:account).to_a] }.to_h + @mentions = statuses.map { |s| [s.id, s.active_mentions.includes(:account).to_a] }.to_h @tags = statuses.map { |s| [s.id, s.tags.pluck(:name)] }.to_h @stream_entry_batches = [] @@ -39,7 +39,6 @@ class BatchedRemoveStatusService < BaseService # Cannot be batched statuses.each do |status| unpush_from_public_timelines(status) - unpush_from_direct_timelines(status) if status.direct_visibility? batch_salmon_slaps(status) if status.local? end @@ -96,16 +95,6 @@ class BatchedRemoveStatusService < BaseService end end - def unpush_from_direct_timelines(status) - payload = @json_payloads[status.id] - redis.pipelined do - @mentions[status.id].each do |mention| - redis.publish("timeline:direct:#{mention.account.id}", payload) if mention.account.local? - end - redis.publish("timeline:direct:#{status.account.id}", payload) if status.account.local? - end - end - def batch_salmon_slaps(status) return if @mentions[status.id].empty? diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index ab520276b..7f2a91775 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -6,15 +6,14 @@ class FanOutOnWriteService < BaseService def call(status) raise Mastodon::RaceConditionError if status.visibility.nil? - deliver_to_self(status) if status.account.local? - render_anonymous_payload(status) if status.direct_visibility? - deliver_to_mentioned_followers(status) - deliver_to_direct_timelines(status) deliver_to_own_conversation(status) + elsif status.limited_visibility? + deliver_to_mentioned_followers(status) else + deliver_to_self(status) if status.account.local? deliver_to_followers(status) deliver_to_lists(status) end @@ -57,7 +56,7 @@ class FanOutOnWriteService < BaseService end def deliver_to_mentioned_followers(status) - Rails.logger.debug "Delivering status #{status.id} to mentioned followers" + Rails.logger.debug "Delivering status #{status.id} to limited followers" status.mentions.includes(:account).each do |mention| mentioned_account = mention.account @@ -94,16 +93,6 @@ class FanOutOnWriteService < BaseService Redis.current.publish('timeline:public:local:media', @payload) if status.local? end - def deliver_to_direct_timelines(status) - Rails.logger.debug "Delivering status #{status.id} to direct timelines" - - status.mentions.includes(:account).each do |mention| - Redis.current.publish("timeline:direct:#{mention.account.id}", @payload) if mention.account.local? - end - - Redis.current.publish("timeline:direct:#{status.account.id}", @payload) if status.account.local? - end - def deliver_to_own_conversation(status) AccountConversation.add_status(status.account, status) end diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb index 63bf8f17a..49022a844 100644 --- a/app/services/notify_service.rb +++ b/app/services/notify_service.rb @@ -59,9 +59,14 @@ class NotifyService < BaseService @notification.target_status.in_reply_to_account_id == @recipient.id && @notification.target_status.thread&.direct_visibility? end + def from_staff? + @notification.from_account.local? && @notification.from_account.user.present? && @notification.from_account.user.staff? + end + def optional_non_following_and_direct? direct_message? && @recipient.user.settings.interactions['must_be_following_dm'] && + !from_staff? && !following_sender? && !response_to_recipient? end diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb index 1a53093b8..11d28e783 100644 --- a/app/services/remove_status_service.rb +++ b/app/services/remove_status_service.rb @@ -8,7 +8,7 @@ class RemoveStatusService < BaseService @status = status @account = status.account @tags = status.tags.pluck(:name).to_a - @mentions = status.mentions.includes(:account).to_a + @mentions = status.active_mentions.includes(:account).to_a @reblogs = status.reblogs.to_a @stream_entry = status.stream_entry @options = options @@ -21,7 +21,6 @@ class RemoveStatusService < BaseService remove_from_hashtags remove_from_public remove_from_media if status.media_attachments.any? - remove_from_direct if status.direct_visibility? @status.destroy! @@ -153,13 +152,6 @@ class RemoveStatusService < BaseService Redis.current.publish('timeline:public:local:media', @payload) if @status.local? end - def remove_from_direct - @mentions.each do |mention| - Redis.current.publish("timeline:direct:#{mention.account.id}", @payload) if mention.account.local? - end - Redis.current.publish("timeline:direct:#{@account.id}", @payload) if @account.local? - end - def redis Redis.current end |