Appease the dog overlords
This commit is contained in:
parent
ee9c48fd06
commit
22a84ab818
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class User < ApplicationRecord
|
class User < ApplicationRecord # rubocop:disable Metrics/ClassLength
|
||||||
include User::Relationship
|
include User::Relationship
|
||||||
include User::Relationship::Follow
|
include User::Relationship::Follow
|
||||||
include User::Relationship::Block
|
include User::Relationship::Block
|
||||||
|
|
|
@ -15,7 +15,7 @@ class QuestionWorker
|
||||||
user.followers.each do |f|
|
user.followers.each do |f|
|
||||||
next if f.inbox_locked?
|
next if f.inbox_locked?
|
||||||
next if f.banned?
|
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)
|
next if user.muting?(question.user)
|
||||||
|
|
||||||
inbox = Inbox.create(user_id: f.id, question_id:, new: true)
|
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}"
|
logger.info "failed to ask question: #{e.message}"
|
||||||
Sentry.capture_exception(e)
|
Sentry.capture_exception(e)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def muted?(user, question)
|
||||||
|
MuteRule.where(user:).any? { |rule| rule.applies_to? question }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
# many times, by many people!
|
# many times, by many people!
|
||||||
|
|
||||||
class AddRpush < ActiveRecord::Migration[5.0]
|
class AddRpush < ActiveRecord::Migration[5.0]
|
||||||
|
# rubocop:disable all
|
||||||
def self.migrations
|
def self.migrations
|
||||||
[CreateRapnsNotifications, CreateRapnsFeedback,
|
[CreateRapnsNotifications, CreateRapnsFeedback,
|
||||||
AddAlertIsJsonToRapnsNotifications, AddAppToRapns,
|
AddAlertIsJsonToRapnsNotifications, AddAppToRapns,
|
||||||
|
@ -41,8 +42,6 @@ class AddRpush < ActiveRecord::Migration[5.0]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Rails/MigrationClassName
|
|
||||||
|
|
||||||
class CreateRapnsNotifications < ActiveRecord::Migration[5.0]
|
class CreateRapnsNotifications < ActiveRecord::Migration[5.0]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :rapns_notifications do |t|
|
create_table :rapns_notifications do |t|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Rpush200Updates < ActiveRecord::Migration[5.0]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.update_type(model, from, to)
|
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
|
end
|
||||||
|
|
||||||
def self.up
|
def self.up
|
||||||
|
|
|
@ -44,7 +44,6 @@ describe QuestionWorker do
|
||||||
it "respects inbox locks" do
|
it "respects inbox locks" do
|
||||||
user.followers.first.update(privacy_lock_inbox: true)
|
user.followers.first.update(privacy_lock_inbox: true)
|
||||||
|
|
||||||
|
|
||||||
expect { subject }
|
expect { subject }
|
||||||
.to(
|
.to(
|
||||||
change { Inbox.where(user_id: user.followers.ids, question_id:, new: true).count }
|
change { Inbox.where(user_id: user.followers.ids, question_id:, new: true).count }
|
||||||
|
@ -71,15 +70,15 @@ describe QuestionWorker do
|
||||||
Rpush::Webpush::App.create(
|
Rpush::Webpush::App.create(
|
||||||
name: "webpush",
|
name: "webpush",
|
||||||
certificate: { public_key: "AAAA", private_key: "AAAA", subject: "" }.to_json,
|
certificate: { public_key: "AAAA", private_key: "AAAA", subject: "" }.to_json,
|
||||||
connections: 1,
|
connections: 1
|
||||||
)
|
)
|
||||||
|
|
||||||
WebPushSubscription.create!(
|
WebPushSubscription.create!(
|
||||||
user: receiver,
|
user: receiver,
|
||||||
subscription: {
|
subscription: {
|
||||||
endpoint: "This will not be used",
|
endpoint: "This will not be used",
|
||||||
keys: {},
|
keys: {}
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
receiver.follow(user)
|
receiver.follow(user)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue