Fixed issue #573 - email forward of article (like regular email client forward - e. g. forward customers message to third party contact).

This commit is contained in:
Martin Edenhofer 2017-12-05 16:12:52 +01:00
parent 75ac4252f3
commit 712acdfe2a
6 changed files with 122 additions and 4 deletions

View file

@ -461,6 +461,7 @@ class App.TicketZoom extends App.Controller
ui: @
highligher: @highligher
ticket_article_ids: @ticket_article_ids
form_id: @form_id
)
new App.TicketCustomerAvatar(

View file

@ -10,6 +10,13 @@ class EmailReply extends App.Controller
icon: 'reply'
href: '#'
}
actions.push {
name: 'forward'
type: 'emailForward'
#icon: 'forward'
icon: 'info'
href: '#'
}
recipients = []
if article.sender.name is 'Customer'
if article.from
@ -57,6 +64,13 @@ class EmailReply extends App.Controller
icon: 'reply'
href: '#'
}
actions.push {
name: 'forward'
type: 'emailForward'
#icon: 'forward'
icon: 'info'
href: '#'
}
if article.sender.name is 'Agent' && article.type.name is 'phone'
actions.push {
name: 'reply'
@ -64,17 +78,27 @@ class EmailReply extends App.Controller
icon: 'reply'
href: '#'
}
actions.push {
name: 'forward'
type: 'emailForward'
#icon: 'forward'
icon: 'info'
href: '#'
}
actions
@perform: (articleContainer, type, ticket, article, ui) ->
return true if type isnt 'emailReply' && type isnt 'emailReplyAll'
return true if type isnt 'emailReply' && type isnt 'emailReplyAll' && type isnt 'emailForward'
if type isnt 'emailReply'
if type is 'emailReply'
@emailReply(false, ticket, article, ui)
else if type is 'emailReplyAll'
@emailReply(true, ticket, article, ui)
else if type isnt 'emailReplyAll'
@emailReply(false, ticket, article, ui)
else if type is 'emailForward'
@emailForward(ticket, article, ui)
true
@ -132,4 +156,49 @@ class EmailReply extends App.Controller
true
@emailForward: (ticket, article, ui) ->
ui.scrollToCompose()
signaturePosition = 'top'
body = ''
if article.content_type.match('html')
body = App.Utils.textCleanup(article.body)
if article.content_type.match('plain')
body = App.Utils.textCleanup(article.body)
body = App.Utils.text2html(body)
body = "<br/><div>---Begin forwarded message:---<br/><br/></div><div><blockquote type=\"cite\">#{body}</blockquote></div><div><br></div>"
articleNew = {}
articleNew.body = body
type = App.TicketArticleType.findByAttribute(name:'email')
App.Event.trigger('ui::ticket::setArticleType', {
ticket: ticket
type: type
article: articleNew
signaturePosition: signaturePosition
})
# add attachments to form
App.Ajax.request(
id: "ticket_attachment_clone#{ui.form_id}"
type: 'POST'
url: "#{App.Config.get('api_path')}/ticket_attachment_upload_clone_by_article/#{article.id}"
data: JSON.stringify(form_id: ui.form_id)
processData: true
success: (data, status, xhr) ->
return if _.isEmpty(data.attachments)
App.Event.trigger('ui::ticket::addArticleAttachent', {
ticket: ticket
article: article
attachments: data.attachments
form_id: ui.form_id
})
)
true
App.Config.set('200-EmailReply', EmailReply, 'TicketZoomArticleAction')

View file

@ -70,6 +70,14 @@ class App.TicketZoomArticleNew extends App.Controller
@textarea.focus()
)
# add article attachment
@bind('ui::ticket::addArticleAttachent', (data) =>
return if data.ticket.id.toString() isnt @ticket_id.toString()
return if _.isEmpty(data.attachments)
for file in data.attachments
@renderAttachment(file)
)
# reset new article screen
@bind('ui::ticket::taskReset', (data) =>
return if data.ticket_id.toString() isnt @ticket_id.toString()

View file

@ -20,6 +20,7 @@ class App.TicketZoomArticleView extends App.Controller
el: el
ui: @ui
highligher: @highligher
form_id: @form_id
)
if !@ticketArticleInsertByIndex(index, el)
all.push el
@ -193,6 +194,7 @@ class ArticleViewItem extends App.ObserverController
ticket: @ticket
article: article
lastAttributres: @lastAttributres
form_id: @form_id
)
# set see more

View file

@ -208,6 +208,43 @@ class TicketArticlesController < ApplicationController
}
end
# POST /ticket_attachment_upload_clone_by_article
def ticket_attachment_upload_clone_by_article
article = Ticket::Article.find(params[:article_id])
access!(article.ticket, 'read')
raise Exceptions::NotAuthorized, 'Need form_id to attach attachmeints.' if params[:form_id].blank?
existing_attachments = Store.list(
object: 'UploadCache',
o_id: params[:form_id],
).to_a
new_attachments = []
article.attachments.each do |new_attachment|
next if new_attachment.preferences['Content-ID'].present?
already_added = false
existing_attachments.each do |local_attachment|
next if local_attachment.filename != new_attachment.filename || local_attachment.size != new_attachment.size
already_added = true
break
end
next if already_added == true
file = Store.add(
object: 'UploadCache',
o_id: params[:form_id],
data: new_attachment.content,
filename: new_attachment.filename,
preferences: new_attachment.preferences,
)
new_attachments.push file
end
render json: {
attachments: new_attachments,
}
end
# GET /ticket_attachment/:ticket_id/:article_id/:id
def attachment
ticket = Ticket.lookup(id: params[:ticket_id])

View file

@ -44,6 +44,7 @@ Zammad::Application.routes.draw do
match api_path + '/ticket_attachment/:ticket_id/:article_id/:id', to: 'ticket_articles#attachment', via: :get
match api_path + '/ticket_attachment_upload', to: 'ticket_articles#ticket_attachment_upload_add', via: :post
match api_path + '/ticket_attachment_upload', to: 'ticket_articles#ticket_attachment_upload_delete', via: :delete
match api_path + '/ticket_attachment_upload_clone_by_article/:article_id', to: 'ticket_articles#ticket_attachment_upload_clone_by_article', via: :post
match api_path + '/ticket_article_plain/:id', to: 'ticket_articles#article_plain', via: :get
end