1
0

Change Redis#exists calls to Redis#exists? to avoid deprecation warning (#14191)

This commit is contained in:
Eugen Rochko 2020-07-01 19:05:21 +02:00 committed by GitHub
parent e9ea960773
commit 6d23d40420
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 38 additions and 33 deletions

28
.gitignore vendored
View File

@ -17,36 +17,36 @@
/log/* /log/*
!/log/.keep !/log/.keep
/tmp /tmp
coverage /coverage
public/system /public/system
public/assets /public/assets
public/packs /public/packs
public/packs-test /public/packs-test
.env .env
.env.production .env.production
.env.development .env.development
node_modules/ /node_modules/
build/ /build/
# Ignore Vagrant files # Ignore Vagrant files
.vagrant/ .vagrant/
# Ignore Capistrano customizations # Ignore Capistrano customizations
config/deploy/* /config/deploy/*
# Ignore IDE files # Ignore IDE files
.vscode/ .vscode/
.idea/ .idea/
# Ignore postgres + redis + elasticsearch volume optionally created by docker-compose # Ignore postgres + redis + elasticsearch volume optionally created by docker-compose
postgres /postgres
redis /redis
elasticsearch /elasticsearch
# ignore Helm lockfile, dependency charts, and local values file # ignore Helm lockfile, dependency charts, and local values file
chart/Chart.lock /chart/Chart.lock
chart/charts/*.tgz /chart/charts/*.tgz
chart/values.yaml /chart/values.yaml
# Ignore Apple files # Ignore Apple files
.DS_Store .DS_Store

View File

@ -444,8 +444,6 @@ GEM
rack (>= 1.0, < 3) rack (>= 1.0, < 3)
rack-cors (1.1.1) rack-cors (1.1.1)
rack (>= 2.0.0) rack (>= 2.0.0)
rack-protection (2.0.8.1)
rack
rack-proxy (0.6.5) rack-proxy (0.6.5)
rack rack
rack-test (1.1.0) rack-test (1.1.0)
@ -570,11 +568,10 @@ GEM
nokogiri (>= 1.8.0) nokogiri (>= 1.8.0)
nokogumbo (~> 2.0) nokogumbo (~> 2.0)
semantic_range (2.3.0) semantic_range (2.3.0)
sidekiq (6.0.7) sidekiq (6.1.0)
connection_pool (>= 2.2.2) connection_pool (>= 2.2.2)
rack (~> 2.0) rack (~> 2.0)
rack-protection (>= 2.0.0) redis (>= 4.2.0)
redis (>= 4.1.0)
sidekiq-bulk (0.2.0) sidekiq-bulk (0.2.0)
sidekiq sidekiq
sidekiq-scheduler (3.0.1) sidekiq-scheduler (3.0.1)

View File

@ -132,7 +132,7 @@ class ActivityPub::Activity
end end
def delete_arrived_first?(uri) def delete_arrived_first?(uri)
redis.exists("delete_upon_arrival:#{@account.id}:#{uri}") redis.exists?("delete_upon_arrival:#{@account.id}:#{uri}")
end end
def delete_later!(uri) def delete_later!(uri)

View File

@ -33,7 +33,7 @@ class ActivityPub::Activity::Move < ActivityPub::Activity
end end
def processed? def processed?
redis.exists("move_in_progress:#{@account.id}") redis.exists?("move_in_progress:#{@account.id}")
end end
def mark_as_processing! def mark_as_processing!

View File

@ -169,7 +169,7 @@ class FeedManager
private private
def push_update_required?(timeline_id) def push_update_required?(timeline_id)
redis.exists("subscribed:#{timeline_id}") redis.exists?("subscribed:#{timeline_id}")
end end
def blocks_or_mutes?(receiver_id, account_ids, context) def blocks_or_mutes?(receiver_id, account_ids, context)

View File

@ -108,7 +108,7 @@ class AccountConversation < ApplicationRecord
end end
def subscribed_to_timeline? def subscribed_to_timeline?
Redis.current.exists("subscribed:#{streaming_channel}") Redis.current.exists?("subscribed:#{streaming_channel}")
end end
def streaming_channel def streaming_channel

View File

@ -32,16 +32,13 @@ class EncryptedMessage < ApplicationRecord
private private
def push_to_streaming_api def push_to_streaming_api
Rails.logger.info(streaming_channel)
Rails.logger.info(subscribed_to_timeline?)
return if destroyed? || !subscribed_to_timeline? return if destroyed? || !subscribed_to_timeline?
PushEncryptedMessageWorker.perform_async(id) PushEncryptedMessageWorker.perform_async(id)
end end
def subscribed_to_timeline? def subscribed_to_timeline?
Redis.current.exists("subscribed:#{streaming_channel}") Redis.current.exists?("subscribed:#{streaming_channel}")
end end
def streaming_channel def streaming_channel

View File

@ -8,6 +8,6 @@ class HomeFeed < Feed
end end
def regenerating? def regenerating?
redis.exists("account:#{@id}:regeneration") redis.exists?("account:#{@id}:regeneration")
end end
end end

View File

@ -14,7 +14,7 @@ class PublishAnnouncementReactionWorker
payload = Oj.dump(event: :'announcement.reaction', payload: payload) payload = Oj.dump(event: :'announcement.reaction', payload: payload)
FeedManager.instance.with_active_accounts do |account| FeedManager.instance.with_active_accounts do |account|
redis.publish("timeline:#{account.id}", payload) if redis.exists("subscribed:timeline:#{account.id}") redis.publish("timeline:#{account.id}", payload) if redis.exists?("subscribed:timeline:#{account.id}")
end end
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
true true

View File

@ -15,7 +15,7 @@ class PublishScheduledAnnouncementWorker
payload = Oj.dump(event: :announcement, payload: payload) payload = Oj.dump(event: :announcement, payload: payload)
FeedManager.instance.with_active_accounts do |account| FeedManager.instance.with_active_accounts do |account|
redis.publish("timeline:#{account.id}", payload) if redis.exists("subscribed:timeline:#{account.id}") redis.publish("timeline:#{account.id}", payload) if redis.exists?("subscribed:timeline:#{account.id}")
end end
end end

View File

@ -8,7 +8,7 @@ class UnpublishAnnouncementWorker
payload = Oj.dump(event: :'announcement.delete', payload: announcement_id.to_s) payload = Oj.dump(event: :'announcement.delete', payload: announcement_id.to_s)
FeedManager.instance.with_active_accounts do |account| FeedManager.instance.with_active_accounts do |account|
redis.publish("timeline:#{account.id}", payload) if redis.exists("subscribed:timeline:#{account.id}") redis.publish("timeline:#{account.id}", payload) if redis.exists?("subscribed:timeline:#{account.id}")
end end
end end
end end

View File

@ -7,6 +7,7 @@ require 'rails/all'
Bundler.require(*Rails.groups) Bundler.require(*Rails.groups)
require_relative '../app/lib/exceptions' require_relative '../app/lib/exceptions'
require_relative '../lib/redis/namespace_extensions'
require_relative '../lib/paperclip/url_generator_extensions' require_relative '../lib/paperclip/url_generator_extensions'
require_relative '../lib/paperclip/attachment_extensions' require_relative '../lib/paperclip/attachment_extensions'
require_relative '../lib/paperclip/media_type_spoof_detector_extensions' require_relative '../lib/paperclip/media_type_spoof_detector_extensions'

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
Redis.exists_returns_integer = false
redis_connection = Redis.new( redis_connection = Redis.new(
url: ENV['REDIS_URL'], url: ENV['REDIS_URL'],
driver: :hiredis driver: :hiredis

View File

@ -0,0 +1,12 @@
# frozen_string_literal: true
class Redis
module NamespaceExtensions
def exists?(*args, &block)
call_with_namespace('exists?', *args, &block)
end
end
end
Redis::Namespace::COMMANDS['exists?'] = [:first]
Redis::Namespace.prepend(Redis::NamespaceExtensions)