diff --git a/app/views/helpdesk/note_edit.html.erb b/app/views/helpdesk/note_edit.html.erb
new file mode 100644
index 0000000..df8c122
--- /dev/null
+++ b/app/views/helpdesk/note_edit.html.erb
@@ -0,0 +1 @@
+<%= @text.html_safe %>
\ No newline at end of file
diff --git a/app/views/helpdesk/note_edit.text.erb b/app/views/helpdesk/note_edit.text.erb
new file mode 100644
index 0000000..c5dcb7d
--- /dev/null
+++ b/app/views/helpdesk/note_edit.text.erb
@@ -0,0 +1 @@
+<%= ActionView::Base.full_sanitizer.sanitize(@text) %>
\ No newline at end of file
diff --git a/lib/helpdesk_mailer.rb b/lib/helpdesk_mailer.rb
index e185453..3e621b4 100644
--- a/lib/helpdesk_mailer.rb
+++ b/lib/helpdesk_mailer.rb
@@ -3,6 +3,7 @@
# uses this method-name too in their mailer. This is the reason
# why we need our own Mailer class.
#
+
class HelpdeskMailer < ActionMailer::Base
helper :application
@@ -16,12 +17,12 @@ def self.default_url_options
# Sending email notifications to the supportclient
def email_to_supportclient(issue, params)
- # issue, recipient, journal=nil, text='', copy_to=nil
+ # issue, recipient, journal=nil, text='', copy_to=nil
recipient = params[:recipient]
journal = params[:journal]
text = params[:text]
- carbon_copy = params[:carbon_copy]
+ carbon_copy = params[:carbon_copy]
redmine_headers 'Project' => issue.project.identifier,
'Issue-Id' => issue.id,
@@ -53,33 +54,49 @@ def email_to_supportclient(issue, params)
if d.property == 'attachment'
a = Attachment.find(d.prop_key)
begin
- attachments[a.filename] = File.read(a.diskfile)
+ if ['image/png', 'image/jpg', 'image/gif', 'image/jpeg'].include? a.content_type
+ attachments.inline[a.filename] = File.read(a.diskfile)
+ image_url = attachments.inline[a.filename].url
+ text = text.gsub("!#{a.filename}!", "")
+ else
+ attachments[a.filename] = File.read(a.diskfile)
+ end
rescue
# ignore rescue
end
end
end
end
+
if @message_id_object
headers[:message_id] = "<#{self.class.message_id_for(@message_id_object)}>"
end
if @references_objects
headers[:references] = @references_objects.collect {|o| "<#{self.class.references_for(o)}>"}.join(' ')
end
+
# create mail object to deliver
mail = if text.present? || reply.present?
+
# sending out the journal note to the support client
# or the first reply message
- t = text.present? ? "#{text}\n\n#{footer}" : reply
+ t = text.present? ? text : reply
+ t = expand_macros("#{t}\n\n#{footer}", issue, journal)
+
+ @text = t.gsub(/\n/,"
")
mail(
:from => sender.present? && sender || Setting.mail_from,
:reply_to => sender.present? && sender || Setting.mail_from,
:to => recipient,
:subject => subject,
- :body => expand_macros(t, issue, journal),
+ :template_path => 'helpdesk',
+ :template_name => 'note_edit',
+ # :body => expand_macros(t, issue, journal),
+ #:body => text,
:date => Time.zone.now,
:cc => carbon_copy
)
+
else
# fallback to a regular notifications email with redmine view
@issue = issue
diff --git a/lib/macro_expander.rb b/lib/macro_expander.rb
index 20bfa0f..bb42ece 100644
--- a/lib/macro_expander.rb
+++ b/lib/macro_expander.rb
@@ -19,6 +19,7 @@ def expand
expand_project
end
expand_user unless @journal.nil?
+ expand_optional_user
expand_base
@string
@@ -48,6 +49,14 @@ def expand_user
expand_user_cf(u)
end
+ def expand_optional_user
+ if @journal.nil?
+ @string.gsub!("##user-name-optional##", "")
+ else
+ @string.gsub!("##user-name-optional##", @journal.user.name)
+ end
+ end
+
def expand_user_cf(user)
CustomField.where(
"type = 'UserCustomField'").each do |user_cf|