Appease the dog overlords

This commit is contained in:
Karina Kwiatek 2022-12-26 09:59:56 +00:00
parent ee9c48fd06
commit 22a84ab818
6 changed files with 14 additions and 10 deletions

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
class User < ApplicationRecord
class User < ApplicationRecord # rubocop:disable Metrics/ClassLength
include User::Relationship
include User::Relationship::Follow
include User::Relationship::Block

View File

@ -15,7 +15,7 @@ class QuestionWorker
user.followers.each do |f|
next if f.inbox_locked?
next if f.banned?
next if MuteRule.where(user: f).any? { |rule| rule.applies_to? question }
next if muted?(f, question)
next if user.muting?(question.user)
inbox = Inbox.create(user_id: f.id, question_id:, new: true)
@ -25,4 +25,10 @@ class QuestionWorker
logger.info "failed to ask question: #{e.message}"
Sentry.capture_exception(e)
end
private
def muted?(user, question)
MuteRule.where(user:).any? { |rule| rule.applies_to? question }
end
end

View File

@ -22,6 +22,7 @@
# many times, by many people!
class AddRpush < ActiveRecord::Migration[5.0]
# rubocop:disable all
def self.migrations
[CreateRapnsNotifications, CreateRapnsFeedback,
AddAlertIsJsonToRapnsNotifications, AddAppToRapns,
@ -41,8 +42,6 @@ class AddRpush < ActiveRecord::Migration[5.0]
end
end
# rubocop:disable Rails/MigrationClassName
class CreateRapnsNotifications < ActiveRecord::Migration[5.0]
def self.up
create_table :rapns_notifications do |t|

View File

@ -12,7 +12,7 @@ class Rpush200Updates < ActiveRecord::Migration[5.0]
end
def self.update_type(model, from, to)
model.where(type: from).update_all(type: to)
model.where(type: from).update_all(type: to) # rubocop:disable Rails/SkipsModelValidations
end
def self.up

View File

@ -153,7 +153,7 @@ describe Ajax::WebPushController, :ajax_controller, type: :controller do
let(:other_user) { FactoryBot.create(:user) }
let!(:subscription) do
WebPushSubscription.create(
user: other_user,
user: other_user,
subscription: { endpoint:, keys: {} }
)
end

View File

@ -44,7 +44,6 @@ describe QuestionWorker do
it "respects inbox locks" do
user.followers.first.update(privacy_lock_inbox: true)
expect { subject }
.to(
change { Inbox.where(user_id: user.followers.ids, question_id:, new: true).count }
@ -71,15 +70,15 @@ describe QuestionWorker do
Rpush::Webpush::App.create(
name: "webpush",
certificate: { public_key: "AAAA", private_key: "AAAA", subject: "" }.to_json,
connections: 1,
connections: 1
)
WebPushSubscription.create!(
user: receiver,
subscription: {
endpoint: "This will not be used",
keys: {},
},
keys: {}
}
)
receiver.follow(user)
end