[redis] More connection pooling changes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class BatchedRemoveStatusService < BaseService
|
||||
include Redisable
|
||||
# include Redisable
|
||||
|
||||
# Delete given statuses and reblogs of them
|
||||
# Dispatch PuSH updates of the deleted statuses, but only local ones
|
||||
|
||||
@@ -34,7 +34,9 @@ class EditStatusService < BaseService
|
||||
postprocess_status!
|
||||
create_revision! revision_text
|
||||
|
||||
redis.setex(idempotency_key, 3_600, @status.id) if idempotency_given?
|
||||
redis.with do |conn|
|
||||
conn.setex(idempotency_key, 3_600, @status.id) if idempotency_given?
|
||||
end
|
||||
|
||||
@status
|
||||
end
|
||||
@@ -91,7 +93,7 @@ class EditStatusService < BaseService
|
||||
end
|
||||
|
||||
def validate_links!
|
||||
raise GabSocial::NotPermittedError if LinkBlock.block?(@text)
|
||||
raise GabSocial::LinkBlockedError if LinkBlock.block?(@text)
|
||||
end
|
||||
|
||||
def language_from_option(str)
|
||||
@@ -119,7 +121,10 @@ class EditStatusService < BaseService
|
||||
end
|
||||
|
||||
def idempotency_duplicate?
|
||||
@idempotency_duplicate = redis.get(idempotency_key)
|
||||
redis.with do |conn|
|
||||
@idempotency_duplicate = conn.get(idempotency_key)
|
||||
end
|
||||
@idempotency_duplicate
|
||||
end
|
||||
|
||||
def status_attributes
|
||||
|
||||
@@ -47,7 +47,9 @@ class PostStatusService < BaseService
|
||||
bump_potential_friendship!
|
||||
end
|
||||
|
||||
redis.setex(idempotency_key, 3_600, @status.id) if idempotency_given?
|
||||
redis.with do |conn|
|
||||
conn.setex(idempotency_key, 3_600, @status.id) if idempotency_given?
|
||||
end
|
||||
|
||||
@status
|
||||
end
|
||||
@@ -200,7 +202,10 @@ class PostStatusService < BaseService
|
||||
end
|
||||
|
||||
def idempotency_duplicate?
|
||||
@idempotency_duplicate = redis.get(idempotency_key)
|
||||
redis.with do |conn|
|
||||
@idempotency_duplicate = conn.get(idempotency_key)
|
||||
end
|
||||
@idempotency_duplicate
|
||||
end
|
||||
|
||||
def scheduled_in_the_past?
|
||||
|
||||
@@ -55,8 +55,10 @@ class RemoveStatusService < BaseService
|
||||
end
|
||||
|
||||
def remove_from_affected
|
||||
@mentions.map(&:account).select(&:local?).each do |account|
|
||||
redis.publish("timeline:#{account.id}", @payload)
|
||||
redis.with do |conn|
|
||||
@mentions.map(&:account).select(&:local?).each do |account|
|
||||
conn.publish("timeline:#{account.id}", @payload)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -73,15 +75,19 @@ class RemoveStatusService < BaseService
|
||||
def remove_from_hashtags
|
||||
return unless @status.public_visibility?
|
||||
|
||||
@tags.each do |hashtag|
|
||||
redis.publish("timeline:hashtag:#{hashtag}", @payload)
|
||||
redis.publish("timeline:hashtag:#{hashtag}:local", @payload) if @status.local?
|
||||
redis.with do |conn|
|
||||
@tags.each do |hashtag|
|
||||
conn.publish("timeline:hashtag:#{hashtag}", @payload)
|
||||
conn.publish("timeline:hashtag:#{hashtag}:local", @payload) if @status.local?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def remove_from_pro
|
||||
if @account.is_pro || @account.is_donor || @account.is_investor || @account.is_verified
|
||||
redis.publish('timeline:pro', @payload)
|
||||
redis.with do |conn|
|
||||
if @account.is_pro || @account.is_donor || @account.is_investor || @account.is_verified
|
||||
conn.publish('timeline:pro', @payload)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user