Fixes #3554 - Zammad sends mails even though there is no email address visible in TO or CC fields (any more)
This commit is contained in:
parent
28bbd774c2
commit
3486390843
3 changed files with 72 additions and 2 deletions
|
@ -75,6 +75,9 @@ class App.TicketZoomArticleNew extends App.Controller
|
||||||
if data.position is 'end'
|
if data.position is 'end'
|
||||||
@placeCaretAtEnd(@textarea.get(0))
|
@placeCaretAtEnd(@textarea.get(0))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# fixes email validation issue right after new ticket creation
|
||||||
|
@tokanice(data.type.name)
|
||||||
)
|
)
|
||||||
|
|
||||||
# add article attachment
|
# add article attachment
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
* Edit: Felix
|
* Edit: Felix
|
||||||
* - remove maxTokenWidth
|
* - remove maxTokenWidth
|
||||||
*
|
*
|
||||||
|
* Edit: Romit
|
||||||
|
* - allow to remove token by clearing it's text manually
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function (factory) {
|
(function (factory) {
|
||||||
|
@ -233,7 +236,10 @@
|
||||||
this.$element.trigger(createEvent)
|
this.$element.trigger(createEvent)
|
||||||
|
|
||||||
// Bail out if there if attributes are empty or event was defaultPrevented
|
// Bail out if there if attributes are empty or event was defaultPrevented
|
||||||
if (!createEvent.attrs || createEvent.isDefaultPrevented()) return
|
if (!createEvent.attrs || createEvent.isDefaultPrevented()) {
|
||||||
|
this.updateTokensOnEditDiscard(triggerChange)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var $token = $('<div class="token" />')
|
var $token = $('<div class="token" />')
|
||||||
.append('<span class="token-label" />')
|
.append('<span class="token-label" />')
|
||||||
|
@ -303,10 +309,21 @@
|
||||||
return this.$element.get(0)
|
return this.$element.get(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
, updateTokensOnEditDiscard: function(triggerChange) {
|
||||||
|
// if the field is being edited, update original field's value
|
||||||
|
if(this.$input.data('edit') && triggerChange) {
|
||||||
|
// Trigger change event on the original field
|
||||||
|
this.$element.val( this.getTokensList() ).trigger( $.Event('change', { initiator: 'tokenfield' }) )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
, setTokens: function (tokens, add, triggerChange) {
|
, setTokens: function (tokens, add, triggerChange) {
|
||||||
if (!add) this.$wrapper.find('.token').remove()
|
if (!add) this.$wrapper.find('.token').remove()
|
||||||
|
|
||||||
if (!tokens) return
|
if (!tokens) {
|
||||||
|
this.updateTokensOnEditDiscard(triggerChange)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof triggerChange === 'undefined') {
|
if (typeof triggerChange === 'undefined') {
|
||||||
triggerChange = true
|
triggerChange = true
|
||||||
|
|
50
spec/system/ticket/update/email_reply_spec.rb
Normal file
50
spec/system/ticket/update/email_reply_spec.rb
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'Ticket > Update > Email Reply', current_user_id: -> { current_user.id }, type: :system, time_zone: 'Europe/London' do
|
||||||
|
let(:group) { Group.find_by(name: 'Users') }
|
||||||
|
let(:ticket) { create(:ticket, group: group) }
|
||||||
|
let(:ticket_article) { create(:ticket_article, ticket: ticket, from: 'Example Name <asdf1@example.com>') }
|
||||||
|
let(:customer) { create(:customer) }
|
||||||
|
let(:current_user) { customer }
|
||||||
|
|
||||||
|
before do
|
||||||
|
visit "ticket/zoom/#{ticket_article.ticket.id}"
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when TO field is being edited' do
|
||||||
|
|
||||||
|
it 'shows error dialog when updated value is an invalid email' do
|
||||||
|
within(:active_content) do
|
||||||
|
click_reply
|
||||||
|
|
||||||
|
find('.token').double_click
|
||||||
|
find('.js-to', visible: false).sibling('.token-input').set('test')
|
||||||
|
find('.js-textarea').set('welcome to the community')
|
||||||
|
find('.js-submitDropdown button.js-submit').click
|
||||||
|
|
||||||
|
expect(page).to have_text 'Need recipient in "To" or "Cc".'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'updates article when updated value is a valid email' do
|
||||||
|
within(:active_content) do
|
||||||
|
click_reply
|
||||||
|
|
||||||
|
find('.token').double_click
|
||||||
|
find('.js-to', visible: false).sibling('.token-input').set('user@test.com')
|
||||||
|
find('.js-textarea').set('welcome to the community')
|
||||||
|
find('.js-submitDropdown button.js-submit').click
|
||||||
|
|
||||||
|
expect(page).to have_text 'welcome to the community'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def click_reply
|
||||||
|
click '.js-ArticleAction[data-type=emailReply]'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in a new issue