This commit is contained in:
Andrew 2023-04-19 13:36:41 +02:00 committed by GitHub
commit a0cdc60ca5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 28 additions and 13 deletions

View file

@ -29,6 +29,7 @@ module Admin
:send_on_accepted, :send_on_rejected, :send_on_confirmed_without_registration,
:send_on_submitted_proposal,
:submitted_proposal_subject, :submitted_proposal_body,
:send_on_event_comment,
:registration_subject, :accepted_subject, :rejected_subject, :confirmed_without_registration_subject,
:registration_body, :accepted_body, :rejected_body, :confirmed_without_registration_body,
:send_on_conference_dates_updated, :conference_dates_updated_subject, :conference_dates_updated_body,

View file

@ -4,9 +4,7 @@ class EventCommentMailJob < ApplicationJob
queue_as :default
def perform(comment)
conference = comment.commentable.program.conference
User.comment_notifiable(conference).each do |user|
User.comment_notifiable(comment.conference_id).each do |user|
Mailbot.event_comment_mail(comment, user).deliver_now
end
end

View file

@ -57,13 +57,19 @@ class Comment < ApplicationRecord
commentable_str.constantize.find(commentable_id)
end
private
def send_notification
EventCommentMailJob.perform_later(self)
end
def conference_id
commentable.program.conference_id
end
private
def conference
commentable.program.conference
end
def send_notification
return unless conference.email_settings.send_on_event_comment?
EventCommentMailJob.perform_later(self)
end
end

View file

@ -37,7 +37,7 @@ class User < ApplicationRecord
after_save :touch_events
# add scope
scope :comment_notifiable, ->(conference) {joins(:roles).where('roles.name IN (?)', [:organizer, :cfp]).where('roles.resource_type = ? AND roles.resource_id = ?', 'Conference', conference.id)}
scope :comment_notifiable, ->(conference_id) {joins(:roles).where('roles.name IN (?)', [:organizer, :cfp]).where('roles.resource_type = ? AND roles.resource_id = ?', 'Conference', conference_id)}
# scopes for user distributions
scope :recent, lambda {

View file

@ -35,6 +35,10 @@
%a.btn.btn-link.control_label.template_help_link{ 'data-name' => 'registration_help' } Show Help
= render partial: 'help', locals: { id: 'registration_help', show_event_variables: false }
#proposal.tab-pane{ role: 'tabpanel' }
.checkbox
%label
= f.check_box :send_on_event_comment
Send an email to all organizers and CfP team members when a comment is added?
.checkbox
%label
= f.check_box :send_on_submitted_proposal, data: { name: 'email_settings_proposal_submited_subject'}, class: 'send_on_radio'