Address review comments from @nilsding
Co-authored-by: nilsding <nilsding@nilsding.org>
This commit is contained in:
parent
89008364d9
commit
10c224b2fe
|
@ -22,7 +22,7 @@ class Ajax::WebPushController < AjaxController
|
|||
@response[:message] = t(".subscription_count", count: current_user.web_push_subscriptions.count)
|
||||
end
|
||||
|
||||
def unsubscribe
|
||||
def unsubscribe # rubocop:disable Metrics/AbcSize
|
||||
params.permit(:endpoint)
|
||||
|
||||
removed = if params.key?(:endpoint)
|
||||
|
|
|
@ -19,7 +19,7 @@ class QuestionWorker
|
|||
next if user.muting?(question.user)
|
||||
|
||||
inbox = Inbox.create(user_id: f.id, question_id:, new: true)
|
||||
f.push_notification(webpush_app, inbox)
|
||||
f.push_notification(webpush_app, inbox) if webpush_app
|
||||
end
|
||||
rescue StandardError => e
|
||||
logger.info "failed to ask question: #{e.message}"
|
||||
|
|
|
@ -8,6 +8,8 @@ hostname: "justask.rrerr.net"
|
|||
https: true
|
||||
|
||||
email_from: "noreply@justask.rrerr.net"
|
||||
# Required by WebPush spec in case of problems with notifications
|
||||
contact_email: "contact@justask.rrerr.net"
|
||||
|
||||
# Name of the "Anonymous" user. (e.g. "Anonymous Coward", "Arno Nym", "Mr. X", ...)
|
||||
anonymous_name: "Anonymous"
|
||||
|
|
|
@ -7,7 +7,7 @@ class AddWebpushApp < ActiveRecord::Migration[6.1]
|
|||
vapid_keypair = Webpush.generate_key.to_hash
|
||||
app = Rpush::Webpush::App.new
|
||||
app.name = "webpush"
|
||||
app.certificate = vapid_keypair.merge(subject: "user@example.com").to_json # TODO: put an email address here
|
||||
app.certificate = vapid_keypair.merge(subject: APP_CONFIG["contact_email"]).to_json
|
||||
app.connections = 1
|
||||
app.save!
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ module UseCase
|
|||
inbox = ::Inbox.create!(user: target_user, question: question, new: true)
|
||||
|
||||
webpush_app = ::Rpush::App.find_by(name: "webpush")
|
||||
target_user.push_notification(webpush_app, inbox)
|
||||
target_user.push_notification(webpush_app, inbox) if webpush_app
|
||||
|
||||
{
|
||||
status: 201,
|
||||
|
|
Loading…
Reference in New Issue