Merge branch 'main' into glitch-soc/merge-upstream
This commit is contained in:
@ -14,6 +14,8 @@
|
||||
#
|
||||
|
||||
class AccountConversation < ApplicationRecord
|
||||
include Redisable
|
||||
|
||||
after_commit :push_to_streaming_api
|
||||
|
||||
belongs_to :account
|
||||
@ -109,7 +111,7 @@ class AccountConversation < ApplicationRecord
|
||||
end
|
||||
|
||||
def subscribed_to_timeline?
|
||||
Redis.current.exists?("subscribed:#{streaming_channel}")
|
||||
redis.exists?("subscribed:#{streaming_channel}")
|
||||
end
|
||||
|
||||
def streaming_channel
|
||||
|
@ -1,6 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AccountSuggestions::GlobalSource < AccountSuggestions::Source
|
||||
include Redisable
|
||||
|
||||
def key
|
||||
:global
|
||||
end
|
||||
@ -28,7 +30,7 @@ class AccountSuggestions::GlobalSource < AccountSuggestions::Source
|
||||
end
|
||||
|
||||
def account_ids_for_locale(locale)
|
||||
Redis.current.zrevrange("follow_recommendations:#{locale}", 0, -1).map(&:to_i)
|
||||
redis.zrevrange("follow_recommendations:#{locale}", 0, -1).map(&:to_i)
|
||||
end
|
||||
|
||||
def to_ordered_list_key(account)
|
||||
|
@ -6,6 +6,6 @@ module Redisable
|
||||
private
|
||||
|
||||
def redis
|
||||
Redis.current
|
||||
Thread.current[:redis] ||= RedisConfiguration.new.connection
|
||||
end
|
||||
end
|
||||
|
@ -24,6 +24,7 @@ class CustomFilter < ApplicationRecord
|
||||
).freeze
|
||||
|
||||
include Expireable
|
||||
include Redisable
|
||||
|
||||
belongs_to :account
|
||||
|
||||
@ -51,7 +52,7 @@ class CustomFilter < ApplicationRecord
|
||||
|
||||
def remove_cache
|
||||
Rails.cache.delete("filters:#{account_id}")
|
||||
Redis.current.publish("timeline:#{account_id}", Oj.dump(event: :filters_changed))
|
||||
redis.publish("timeline:#{account_id}", Oj.dump(event: :filters_changed))
|
||||
end
|
||||
|
||||
def context_must_be_valid
|
||||
|
@ -19,6 +19,7 @@ class EncryptedMessage < ApplicationRecord
|
||||
self.inheritance_column = nil
|
||||
|
||||
include Paginable
|
||||
include Redisable
|
||||
|
||||
scope :up_to, ->(id) { where(arel_table[:id].lteq(id)) }
|
||||
|
||||
@ -38,7 +39,7 @@ class EncryptedMessage < ApplicationRecord
|
||||
end
|
||||
|
||||
def subscribed_to_timeline?
|
||||
Redis.current.exists?("subscribed:#{streaming_channel}")
|
||||
redis.exists?("subscribed:#{streaming_channel}")
|
||||
end
|
||||
|
||||
def streaming_channel
|
||||
|
@ -1,6 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class FollowRecommendationFilter
|
||||
include Redisable
|
||||
|
||||
KEYS = %i(
|
||||
language
|
||||
status
|
||||
@ -17,7 +19,7 @@ class FollowRecommendationFilter
|
||||
if params['status'] == 'suppressed'
|
||||
Account.joins(:follow_recommendation_suppression).order(FollowRecommendationSuppression.arel_table[:id].desc).to_a
|
||||
else
|
||||
account_ids = Redis.current.zrevrange("follow_recommendations:#{@language}", 0, -1).map(&:to_i)
|
||||
account_ids = redis.zrevrange("follow_recommendations:#{@language}", 0, -1).map(&:to_i)
|
||||
accounts = Account.where(id: account_ids).index_by(&:id)
|
||||
|
||||
account_ids.map { |id| accounts[id] }.compact
|
||||
|
@ -52,6 +52,7 @@ class User < ApplicationRecord
|
||||
|
||||
include Settings::Extend
|
||||
include UserRoles
|
||||
include Redisable
|
||||
|
||||
# The home and list feeds will be stored in Redis for this amount
|
||||
# of time, and status fan-out to followers will include only people
|
||||
@ -464,7 +465,7 @@ class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def regenerate_feed!
|
||||
RegenerationWorker.perform_async(account_id) if Redis.current.set("account:#{account_id}:regeneration", true, nx: true, ex: 1.day.seconds)
|
||||
RegenerationWorker.perform_async(account_id) if redis.set("account:#{account_id}:regeneration", true, nx: true, ex: 1.day.seconds)
|
||||
end
|
||||
|
||||
def needs_feed_update?
|
||||
|
Reference in New Issue
Block a user