diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-08-14 02:41:44 -0500 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-08-30 05:45:18 -0500 |
commit | abfd0c107c8003ba06a118625c49d22df553696f (patch) | |
tree | bb41e6b47b2848233b7830b179a7b2e4df21dd91 /app/services | |
parent | d97a574b07cb60e9c2bdd98ace5049e73ee9b861 (diff) |
[Command Tags] Add #!notify toggle to allow toggling whether or not a post should be locally delivered to timelines/notifications
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/fan_out_on_write_service.rb | 2 | ||||
-rw-r--r-- | app/services/post_status_service.rb | 3 | ||||
-rw-r--r-- | app/services/process_mentions_service.rb | 2 | ||||
-rw-r--r-- | app/services/update_status_service.rb | 2 |
4 files changed, 7 insertions, 2 deletions
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index 6102ed1e5..1e12def33 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -92,7 +92,7 @@ class FanOutOnWriteService < BaseService Rails.logger.debug "Delivering status #{status.id} to public timeline" - Redis.current.set(key, true, ex: 6.hours) + Redis.current.set(key, 1, ex: 6.hours) Redis.current.publish('timeline:public', @payload) if status.local? diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 82588d254..c6a983001 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -27,6 +27,7 @@ class PostStatusService < BaseService # @option [Enumerable] :mentions Optional array of Mentions to include # @option [Enumerable] :tags Option array of tag names to include # @option [Boolean] :publish If true, status will be published + # @option [Boolean] :notify If false, status will not be delivered to local timelines or mentions # @return [Status] def call(account, options = {}) @account = account @@ -91,6 +92,8 @@ class PostStatusService < BaseService @status = @account.statuses.create!(status_attributes) end + @status.notify = @options[:notify] if @options[:notify].present? + process_command_tags_service.call(@account, @status) process_hashtags_service.call(@status, nil, @tag_names) process_mentions_service.call(@status, mentions: @mentions, deliver: @options[:publish]) diff --git a/app/services/process_mentions_service.rb b/app/services/process_mentions_service.rb index 3752cebb9..fea00ef4f 100644 --- a/app/services/process_mentions_service.rb +++ b/app/services/process_mentions_service.rb @@ -31,7 +31,7 @@ class ProcessMentionsService < BaseService mentioned_account = mention.account if mentioned_account.local? - LocalNotificationWorker.perform_async(mentioned_account.id, mention.id, mention.class.name) unless mention.silent? + LocalNotificationWorker.perform_async(mentioned_account.id, mention.id, mention.class.name) unless !@status.notify? || mention.silent? elsif mentioned_account.activitypub? && !@status.local_only? ActivityPub::DeliveryWorker.perform_async(activitypub_json(mentioned_account.domain), mention.status.account_id, mentioned_account.inbox_url) end diff --git a/app/services/update_status_service.rb b/app/services/update_status_service.rb index 05586aa1b..327cc74ea 100644 --- a/app/services/update_status_service.rb +++ b/app/services/update_status_service.rb @@ -147,6 +147,8 @@ class UpdateStatusService < BaseService ActivityPub::DistributionWorker.perform_async(@status.id) if @status.local? && !@status.local_only? + return unless @status.notify? + mentions = @status.active_mentions.includes(:account).where(id: @new_mention_ids, accounts: { domain: nil }) mentions.each { |mention| LocalNotificationWorker.perform_async(mention.account.id, mention.id, mention.class.name) } end |