Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push discovered status through streaming API within a time window #6484

Merged
merged 1 commit into from Feb 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/lib/activitypub/activity.rb
Expand Up @@ -74,7 +74,7 @@ def distribute(status)

# Only continue if the status is supposed to have
# arrived in real-time
return unless @options[:override_timestamps]
return unless @options[:override_timestamps] || status.within_realtime_window?

distribute_to_followers(status)
end
Expand Down
2 changes: 1 addition & 1 deletion app/lib/ostatus/activity/creation.rb
Expand Up @@ -61,7 +61,7 @@ def process_status
Rails.logger.debug "Queuing remote status #{status.id} (#{id}) for distribution"

LinkCrawlWorker.perform_async(status.id) unless status.spoiler_text?
DistributionWorker.perform_async(status.id) if @options[:override_timestamps]
DistributionWorker.perform_async(status.id) if @options[:override_timestamps] || status.within_realtime_window?

status
end
Expand Down
6 changes: 6 additions & 0 deletions app/models/status.rb
Expand Up @@ -80,6 +80,8 @@ class Status < ApplicationRecord

delegate :domain, to: :account, prefix: true

REAL_TIME_WINDOW = 6.hours

def searchable_by(preloaded = nil)
ids = [account_id]

Expand Down Expand Up @@ -108,6 +110,10 @@ def reblog?
!reblog_of_id.nil?
end

def within_realtime_window?
created_at >= REAL_TIME_WINDOW.ago
end

def verb
if destroyed?
:delete
Expand Down