forked from cybrespace/mastodon
Improved configuration from ENV, cleaned up timeline filter methods
to be more readable, add extra logging to process feed service
This commit is contained in:
parent
0400734df7
commit
dbe00a4156
|
@ -12,8 +12,10 @@ class FeedManager
|
||||||
def filter?(timeline_type, status, receiver)
|
def filter?(timeline_type, status, receiver)
|
||||||
if timeline_type == :home
|
if timeline_type == :home
|
||||||
filter_from_home?(status, receiver)
|
filter_from_home?(status, receiver)
|
||||||
else
|
elsif timeline_type == :mentions
|
||||||
filter_from_mentions?(status, receiver)
|
filter_from_mentions?(status, receiver)
|
||||||
|
else
|
||||||
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -59,13 +61,23 @@ class FeedManager
|
||||||
$redis
|
$redis
|
||||||
end
|
end
|
||||||
|
|
||||||
# Filter status out of the home feed if it is a reply to someone the user doesn't follow
|
|
||||||
def filter_from_home?(status, receiver)
|
def filter_from_home?(status, receiver)
|
||||||
replied_to_user = status.reply? ? status.thread.try(:account) : nil
|
should_filter = false
|
||||||
(status.reply? && !(receiver.id == replied_to_user.id || replied_to_user.id == status.account_id || receiver.following?(replied_to_user))) || (status.reblog? && receiver.blocking?(status.reblog.account))
|
|
||||||
|
if status.reply? && !status.thread.account.nil? # Filter out if it's a reply
|
||||||
|
should_filter = !receiver.following?(status.thread.account) # and I'm not following the person it's a reply to
|
||||||
|
should_filter = should_filter && !(receiver.id == status.thread.account_id) # and it's not a reply to me
|
||||||
|
should_filter = should_filter && !(status.account_id == status.thread.account_id) # and it's not a self-reply
|
||||||
|
elsif status.reblog? # Filter out a reblog
|
||||||
|
should_filter = receiver.blocking?(status.reblog.account) # if I'm blocking the reblogged person
|
||||||
|
end
|
||||||
|
|
||||||
|
should_filter
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_from_mentions?(status, receiver)
|
def filter_from_mentions?(status, receiver)
|
||||||
receiver.blocking?(status.account)
|
should_filter = false
|
||||||
|
should_filter = receiver.blocking?(status.account) # Filter if it's from someone I blocked
|
||||||
|
should_filter
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -56,6 +56,7 @@ class ProcessFeedService < BaseService
|
||||||
process_attachments(entry, status)
|
process_attachments(entry, status)
|
||||||
process_attachments(entry.xpath('./activity:object', activity: ACTIVITY_NS), status.reblog) if status.reblog?
|
process_attachments(entry.xpath('./activity:object', activity: ACTIVITY_NS), status.reblog) if status.reblog?
|
||||||
|
|
||||||
|
Rails.logger.debug "Queuing remote status #{status.id} for distribution"
|
||||||
DistributionWorker.perform_async(status.id)
|
DistributionWorker.perform_async(status.id)
|
||||||
return status
|
return status
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,8 +46,8 @@ Rails.application.configure do
|
||||||
|
|
||||||
# Use a different cache store in production.
|
# Use a different cache store in production.
|
||||||
config.cache_store = :redis_store, {
|
config.cache_store = :redis_store, {
|
||||||
host: ENV['REDIS_HOST'] || 'localhost',
|
host: ENV.fetch('REDIS_HOST') { 'localhost' },
|
||||||
port: ENV['REDIS_PORT'] || 6379,
|
port: ENV.fetch('REDIS_PORT') { 6379 },
|
||||||
db: 0,
|
db: 0,
|
||||||
namespace: 'cache'
|
namespace: 'cache'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Neography.configure do |config|
|
Neography.configure do |config|
|
||||||
config.protocol = "http"
|
config.protocol = "http"
|
||||||
config.server = ENV['NEO4J_HOST'] || 'localhost'
|
config.server = ENV.fetch('NEO4J_HOST') { 'localhost' }
|
||||||
config.port = ENV['NEO4J_PORT'] || 7474
|
config.port = ENV.fetch('NEO4J_PORT') { 7474 }
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
port = ENV.fetch('PORT') { 3000 }
|
||||||
|
|
||||||
Rails.application.configure do
|
Rails.application.configure do
|
||||||
config.x.local_domain = ENV['LOCAL_DOMAIN'] || "localhost:#{ENV['PORT'] || 3000}"
|
config.x.local_domain = ENV.fetch('LOCAL_DOMAIN') { "localhost:#{port}" }
|
||||||
config.x.hub_url = ENV['HUB_URL'] || 'https://pubsubhubbub.superfeedr.com'
|
config.x.hub_url = ENV.fetch('HUB_URL') { 'https://pubsubhubbub.superfeedr.com' }
|
||||||
config.x.use_https = ENV['LOCAL_HTTPS'] == 'true'
|
config.x.use_https = ENV['LOCAL_HTTPS'] == 'true'
|
||||||
config.x.use_s3 = ENV['S3_ENABLED'] == 'true'
|
config.x.use_s3 = ENV['S3_ENABLED'] == 'true'
|
||||||
|
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
$redis = Redis.new(host: ENV['REDIS_HOST'] || 'localhost', port: ENV['REDIS_PORT'] || 6379, driver: :hiredis)
|
$redis = Redis.new({
|
||||||
|
host: ENV.fetch('REDIS_HOST') { 'localhost' },
|
||||||
|
port: ENV.fetch('REDIS_PORT') { 6379 },
|
||||||
|
driver: :hiredis
|
||||||
|
})
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
host = ENV['REDIS_HOST'] || 'localhost'
|
host = ENV.fetch('REDIS_HOST') { 'localhost' }
|
||||||
port = ENV['REDIS_PORT'] || 6379
|
port = ENV.fetch('REDIS_PORT') { 6379 }
|
||||||
|
|
||||||
Sidekiq.configure_server do |config|
|
Sidekiq.configure_server do |config|
|
||||||
config.redis = { host: host, port: port }
|
config.redis = { host: host, port: port }
|
||||||
|
|
Loading…
Reference in New Issue