Added check for reply via email if email address is set for group.

This commit is contained in:
Martin Edenhofer 2016-02-25 22:04:51 +01:00
parent 532d562845
commit 1ff11fe3a4
2 changed files with 17 additions and 1 deletions

View file

@ -68,7 +68,8 @@ class App.TicketZoomArticleActions extends App.Controller
] ]
#if @article.type.name is 'note' #if @article.type.name is 'note'
# actions.push [] # actions.push []
if article.type.name is 'email' || article.type.name is 'phone' || article.type.name is 'web' group = @ticket.group
if group.email_address_id && (article.type.name is 'email' || article.type.name is 'phone' || article.type.name is 'web')
actions.push { actions.push {
name: 'reply' name: 'reply'
type: 'emailReply' type: 'emailReply'

View file

@ -8,6 +8,8 @@ class EmailAddress < ApplicationModel
before_create :check_if_channel_exists_set_inactive before_create :check_if_channel_exists_set_inactive
before_update :check_if_channel_exists_set_inactive before_update :check_if_channel_exists_set_inactive
after_create :update_email_address_id
after_update :update_email_address_id
after_destroy :delete_group_reference after_destroy :delete_group_reference
latest_change_support latest_change_support
@ -60,4 +62,17 @@ check and if channel not exists reset configured channels for email addresses
group.email_address_id = nil group.email_address_id = nil
} }
end end
# keep email email address is of inital group filled
def update_email_address_id
not_configured = Group.where(email_address_id: nil).count
total = Group.count
return if not_configured == 0
return if total != 1
group = Group.find_by(email_address_id: nil)
group.email_address_id = id
group.updated_by_id = updated_by_id
group.save
end
end end