diff --git a/app/models/ticket.rb b/app/models/ticket.rb
index e76413c5f..220935ae2 100644
--- a/app/models/ticket.rb
+++ b/app/models/ticket.rb
@@ -738,22 +738,21 @@ perform changes on ticket
}
# get subject
- value['subject'].gsub!(/\#\{config\.(.+?)\}/, '<%= c "\\1", false %>')
- value['subject'].gsub!(/\#\{(.+?)\}/, '<%= d "\\1", false %>')
subject = NotificationFactory::Mailer.template(
templateInline: value['subject'],
locale: 'en-en',
objects: objects,
+ quote: false,
)
subject = subject_build(subject)
- value['body'].gsub!(/\#\{config\.(.+?)\}/, '<%= c "\\1", true %>')
- value['body'].gsub!(/\#\{(.+?)\}/, '<%= d "\\1", true %>')
body = NotificationFactory::Mailer.template(
templateInline: value['body'],
locale: 'en-en',
objects: objects,
+ quote: true,
)
+
Ticket::Article.create(
ticket_id: id,
to: recipient_string,
diff --git a/app/models/ticket/article.rb b/app/models/ticket/article.rb
index 240c0ca96..a152563e5 100644
--- a/app/models/ticket/article.rb
+++ b/app/models/ticket/article.rb
@@ -121,6 +121,49 @@ returns
Ticket::Article.where('ticket_id = ? AND sender_id NOT IN (?)', ticket_id, sender.id).order('created_at DESC').first
end
+=begin
+
+get body as html
+
+ article = Ticket::Article.find(123)
+ article.body_as_html
+
+=end
+
+ def body_as_html
+ return '' if !body
+ return body if content_type && content_type =~ %r{text/html}i
+ body.text2html
+ end
+
+=begin
+
+get body as text
+
+ article = Ticket::Article.find(123)
+ article.body_as_text
+
+=end
+
+ def body_as_text
+ return '' if !body
+ return body if !content_type || content_type.empty? || content_type =~ %r{text/plain}i
+ body.html2text
+ end
+
+=begin
+
+get body as text with quote sign "> " at the beginning of each line
+
+ article = Ticket::Article.find(123)
+ article.body_as_text
+
+=end
+
+ def body_as_text_with_quote
+ body_as_text.word_wrap.message_quote
+ end
+
private
# strip not wanted chars
diff --git a/app/views/mailer/password_change/de.html.erb b/app/views/mailer/password_change/de.html.erb
index 6a433bc4e..24cf7e9b8 100644
--- a/app/views/mailer/password_change/de.html.erb
+++ b/app/views/mailer/password_change/de.html.erb
@@ -1,9 +1,9 @@
-Dein <%= c 'product_name' %> Passwort wurde geändert
+Dein #{config.product_name} Passwort wurde geändert
-
Hallo <%= d 'user.firstname' %>,
+Hallo #{user.firstname},
-das Passwort für Dein <%= c 'product_name' %> Account <%= d 'user.login' %> wurde kürzlich geändert.
+das Passwort für Dein #{config.product_name} Account #{user.login} wurde kürzlich geändert.
Diese Aktivität ist Dir nicht bekannt? In diesen Fall kontaktiere Deinen System-Administrator.
-Dein <%= c 'product_name' %> Team
+Dein #{config.product_name} Team
diff --git a/app/views/mailer/password_change/en.html.erb b/app/views/mailer/password_change/en.html.erb
index 81eb723b5..80236ad12 100644
--- a/app/views/mailer/password_change/en.html.erb
+++ b/app/views/mailer/password_change/en.html.erb
@@ -1,9 +1,9 @@
-Your <%= c 'product_name' %> password has been changed
+Your #{product_name} password has been changed
-Hi <%= d 'user.firstname' %>,
+Hi #{user.firstname},
-The password for your <%= c 'product_name' %> account <%= d 'user.login' %> has been changed recently.
+The password for your #{product_name} account #{user.login} has been changed recently.
This activity is not known to you? If not, contact your system administrator.
-Your <%= c 'product_name' %> Team
+Your #{product_name} Team
diff --git a/app/views/mailer/password_reset/de.html.erb b/app/views/mailer/password_reset/de.html.erb
index 13d2f4f7b..fd03cff03 100644
--- a/app/views/mailer/password_reset/de.html.erb
+++ b/app/views/mailer/password_reset/de.html.erb
@@ -1,15 +1,15 @@
-Zurücksetzen Deines <%= c 'product_name' %> Passworts
+Zurücksetzen Deines #{config.product_name} Passworts
-Hallo <%= d 'user.firstname' %>,
+Hallo #{user.firstname},
-wir haben eine Anfrage zum Zurücksetzen des Passworts für <%= c 'product_name' %> Account <%= d 'user.login' %> erhalten.
+wir haben eine Anfrage zum Zurücksetzen des Passworts für #{config.product_name} Account #{user.login} erhalten.
Wenn Sie Ihr Passwort zurückzusetzen wollen, klicken Sie auf den unten stehenden Link (oder kopieren Sie die URL in den Browser einfügen):
-
+
Dieser Link führt Sie zu einer Seite, auf der Sie Ihr Passwort ändern können.
Wenn Sie Ihr Passwort nicht zurücksetzen wollen, ignorieren Sie diese Meldung. Das Passwort bleibt unverändert.
-Dein <%= c 'product_name' %> Team
+Dein #{config.product_name} Team
diff --git a/app/views/mailer/password_reset/en.html.erb b/app/views/mailer/password_reset/en.html.erb
index c673eead8..3a993b785 100644
--- a/app/views/mailer/password_reset/en.html.erb
+++ b/app/views/mailer/password_reset/en.html.erb
@@ -1,15 +1,15 @@
-Reset your <%= c 'product_name' %> password
+Reset your #{config.product_name} password
-Hi <%= d 'user.firstname' %>,
+Hi #{user.firstname},
-We received a request to reset the password for your <%= c 'product_name' %> account <%= d 'user.login' %>.
+We received a request to reset the password for your #{config.product_name} account #{user.login}.
If you want to reset your password, click on the link below (or copy and paste the URL into your browser):
-
+
This link takes you to a page where you can change your password.
If you don't want to reset your password, please ignore this message. Your password will not be reseted.
-Your <%= c 'product_name' %> Team
+Your #{config.product_name} Team
diff --git a/app/views/mailer/signup/de.html.erb b/app/views/mailer/signup/de.html.erb
index 9c76b8dca..d5a5ecf6c 100644
--- a/app/views/mailer/signup/de.html.erb
+++ b/app/views/mailer/signup/de.html.erb
@@ -1,9 +1,9 @@
-Bestätigung des <%= c 'product_name' %> Accounts, <%= d 'user.firstname' %> <%= d 'user.lastname' %>
+Bestätigung des #{config.product_name} Accounts, #{user.firstname} #{user.lastname}
-Hallo <%= d 'user.firstname' %>,
+Hallo #{user.firstname},
-bestätige Deine E-Mail-Adresse um Deine Registrierung bei <%= c 'product_name' %> abzuschließen. Es ist einfach - klick einfach auf den Link unten.
+bestätige Deine E-Mail-Adresse um Deine Registrierung bei #{config.product_name} abzuschließen. Es ist einfach - klick einfach auf den Link unten.
-
+
-Dein <%= c 'product_name' %> Team
+Dein #{config.product_name} Team
diff --git a/app/views/mailer/signup/en.html.erb b/app/views/mailer/signup/en.html.erb
index 168f1d067..f03b586a0 100644
--- a/app/views/mailer/signup/en.html.erb
+++ b/app/views/mailer/signup/en.html.erb
@@ -1,9 +1,9 @@
-Confirm your <%= c 'product_name' %> account, <%= d 'user.firstname' %> <%= d 'user.lastname' %>
+Confirm your #{config.product_name} account, #{user.firstname} #{user.lastname}
-Hi <%= d 'user.firstname' %>,
+Hi #{user.firstname},
-Confirm your email address to complete your <%= c 'product_name' %> account. It's easy, just click the link below.
+Confirm your email address to complete your #{config.product_name} account. It's easy, just click the link below.
-
+
-Your <%= c 'product_name' %> Team
+Your #{config.product_name} Team
diff --git a/app/views/mailer/test_ticket/de.html.erb b/app/views/mailer/test_ticket/de.html.erb
index cf4fe7d43..4e36a4b39 100644
--- a/app/views/mailer/test_ticket/de.html.erb
+++ b/app/views/mailer/test_ticket/de.html.erb
@@ -1,9 +1,9 @@
Test Ticket!
-Hallo <%= d 'agent.firstname' %>,
+Hallo #{agent.firstname},
dies ist ein Test Ticket. Ich bin ein Kunde und benötige Hilfe! :)
-<%= d 'customer.fullname' %>
+#{customer.fullname}
Das Zammad Projekt
diff --git a/app/views/mailer/test_ticket/en.html.erb b/app/views/mailer/test_ticket/en.html.erb
index fd1d00929..557c902eb 100644
--- a/app/views/mailer/test_ticket/en.html.erb
+++ b/app/views/mailer/test_ticket/en.html.erb
@@ -1,9 +1,9 @@
Test Ticket!
-Dear <%= d 'agent.firstname' %>,
+Dear #{agent.firstname},
This is a test ticket. I'm a customer and I need some help! :)
-<%= d 'customer.fullname' %>
+#{customer.fullname}
The Zammad Project
diff --git a/app/views/mailer/ticket_create/de.html.erb b/app/views/mailer/ticket_create/de.html.erb
index b1db98e71..bc666a485 100644
--- a/app/views/mailer/ticket_create/de.html.erb
+++ b/app/views/mailer/ticket_create/de.html.erb
@@ -1,24 +1,24 @@
-Neues Ticket (<%= d 'ticket.title' %>)
+Neues Ticket (#{ticket.title})
-Hallo <%= d 'recipient.firstname' %>,
+Hallo #{recipient.firstname},
-es wurde ein neues Ticket (<%= d 'ticket.title' %>) von "<%= d 'current_user.longname' %>" erstellt.
+es wurde ein neues Ticket (#{ticket.title}) von "#{current_user.longname}" erstellt.
-<%= t 'Group' %>: <%= d 'ticket.group.name' %>
-<%= t 'Owner' %>: <%= d 'ticket.owner.fullname' %>
-<%= t 'State' %>: <%= t d 'ticket.state.name' %>
+#{t('Group')}: #{ticket.group.name}
+#{t('Owner')}: #{ticket.owner.fullname}
+#{t('State')}: #{t(ticket.state.name)}
<% if @objects[:article] %>
- <%= t 'Information' %>:
+ #{t('Information')}:
- <%= a_html 'article' %>
+ #{article.body_as_html}
<% end %>
diff --git a/app/views/mailer/ticket_create/en.html.erb b/app/views/mailer/ticket_create/en.html.erb
index 408fe77b7..009784232 100644
--- a/app/views/mailer/ticket_create/en.html.erb
+++ b/app/views/mailer/ticket_create/en.html.erb
@@ -1,24 +1,24 @@
-New Ticket (<%= d 'ticket.title' %>)
+New Ticket (#{ticket.title})
-Hi <%= d 'recipient.firstname' %>,
+Hi #{recipient.firstname},
-A new ticket (<%= d 'ticket.title' %>) has been created by "<%= d 'current_user.longname' %>".
+A new ticket (#{ticket.title}) has been created by "#{current_user.longname}".
-<%= t 'Group' %>: <%= d 'ticket.group.name' %>
-<%= t 'Owner' %>: <%= d 'ticket.owner.fullname' %>
-<%= t 'State' %>: <%= t d 'ticket.state.name' %>
+#{t('Group')}: #{ticket.group.name}
+#{t('Owner')}: #{ticket.owner.fullname}
+#{t('State')}: #{t(ticket.state.name)}
<% if @objects[:article] %>
- <%= t 'Information' %>:
+ #{t('Information')}:
- <%= a_html 'article' %>
+ #{article.body_as_html}
<% end %>
diff --git a/app/views/mailer/ticket_escalation/de.html.erb b/app/views/mailer/ticket_escalation/de.html.erb
index 86ba3da5d..ea71cd93d 100644
--- a/app/views/mailer/ticket_escalation/de.html.erb
+++ b/app/views/mailer/ticket_escalation/de.html.erb
@@ -1,18 +1,18 @@
-Ticket ist eskaliert (<%= d 'ticket.title' %>)
+Ticket ist eskaliert (#{ticket.title})
-Hallo <%= d 'recipient.firstname' %>,
+Hallo #{recipient.firstname},
-Ticket (<%= d 'ticket.title' %>) von "<%= d 'ticket.customer.longname' %>" ist seit "<%= d 'ticket.escalation_at' %>" eskaliert!
+Ticket (#{ticket.title}) von "#{ticket.customer.longname}" ist seit "#{ticket.escalation_at}" eskaliert!
<% if @objects[:article] %>
- <%= t 'Information' %>:
+ #{t('Information')}:
- <%= a_html 'article' %>
+ #{article.body_as_html}
<% end %>
diff --git a/app/views/mailer/ticket_escalation/en.html.erb b/app/views/mailer/ticket_escalation/en.html.erb
index 078a55262..bb779fba0 100644
--- a/app/views/mailer/ticket_escalation/en.html.erb
+++ b/app/views/mailer/ticket_escalation/en.html.erb
@@ -1,18 +1,18 @@
-Ticket is escalated (<%= d 'ticket.title' %>)
+Ticket is escalated (#{ticket.title})
-Hi <%= d 'recipient.firstname' %>,
+Hi #{recipient.firstname},
-A ticket (<%= d 'ticket.title' %>) from "<%= d 'ticket.customer.longname' %>" is escalated since "<%= d 'ticket.escalation_at' %>"!
+A ticket (#{ticket.title}) from "#{ticket.customer.longname}" is escalated since "#{ticket.escalation_at}"!
<% if @objects[:article] %>
- <%= t 'Information' %>:
+ #{t('Information')}:
- <%= a_html 'article' %>
+ #{article.body_as_html}
<% end %>
diff --git a/app/views/mailer/ticket_escalation_warning/de.html.erb b/app/views/mailer/ticket_escalation_warning/de.html.erb
index d78d8fe48..6a20eb8a7 100644
--- a/app/views/mailer/ticket_escalation_warning/de.html.erb
+++ b/app/views/mailer/ticket_escalation_warning/de.html.erb
@@ -1,18 +1,18 @@
-Ticket wird eskalieren (<%= d 'ticket.title' %>)
+Ticket wird eskalieren (#{ticket.title})
-Hallo <%= d 'recipient.firstname' %>,
+Hallo #{recipient.firstname},
-Ticket (<%= d 'ticket.title' %>) von "<%= d 'ticket.customer.longname' %>" wird um "<%= d 'ticket.escalation_at' %>" eskalieren!
+Ticket (#{ticket.title}) von "#{ticket.customer.longname}" wird um "#{ticket.escalation_at}" eskalieren!
<% if @objects[:article] %>
- <%= t 'Information' %>:
+ #{t('Information')}:
- <%= a_html 'article' %>
+ #{article.body_as_html}
<% end %>
diff --git a/app/views/mailer/ticket_escalation_warning/en.html.erb b/app/views/mailer/ticket_escalation_warning/en.html.erb
index 0952efc91..3750ebe39 100644
--- a/app/views/mailer/ticket_escalation_warning/en.html.erb
+++ b/app/views/mailer/ticket_escalation_warning/en.html.erb
@@ -1,18 +1,18 @@
-Ticket will escalate (<%= d 'ticket.title' %>)
+Ticket will escalate (#{ticket.title})
-Hi <%= d 'recipient.firstname' %>,
+Hi #{recipient.firstname},
-A ticket (<%= d 'ticket.title' %>) from "<%= d 'ticket.customer.longname' %>" will escalate at "<%= d 'ticket.escalation_at' %>"!
+A ticket (#{ticket.title}) from "#{ticket.customer.longname}" will escalate at "#{ticket.escalation_at}"!
<% if @objects[:article] %>
- <%= t 'Information' %>:
+ #{t('Information')}:
- <%= a_html 'article' %>
+ #{article.body_as_html}
<% end %>
diff --git a/app/views/mailer/ticket_reminder_reached/de.html.erb b/app/views/mailer/ticket_reminder_reached/de.html.erb
index 275660959..1e4e1785f 100644
--- a/app/views/mailer/ticket_reminder_reached/de.html.erb
+++ b/app/views/mailer/ticket_reminder_reached/de.html.erb
@@ -1,18 +1,18 @@
-Warten auf Erinnerung erreicht! (<%= d 'ticket.title' %>)
+Warten auf Erinnerung erreicht! (#{ticket.title})
-Hallo <%= d 'recipient.firstname' %>,
+Hallo #{recipient.firstname},
-dieses Ticket benötigt Deine Aufmerksamkeit, warten auf Erinnerung für (<%= d 'ticket.title' %>) mit dem Kunden "<%= d 'ticket.customer.longname' %>" ist erreicht.
+dieses Ticket benötigt Deine Aufmerksamkeit, warten auf Erinnerung für (#{ticket.title}) mit dem Kunden "#{ticket.customer.longname}" ist erreicht.
<% if @objects[:article] %>
- <%= t 'Information' %>:
+ #{t('Information')}:
- <%= a_html 'article' %>
+ #{article.body_as_html}
<% end %>
diff --git a/app/views/mailer/ticket_reminder_reached/en.html.erb b/app/views/mailer/ticket_reminder_reached/en.html.erb
index 65f7b5440..5998d8830 100644
--- a/app/views/mailer/ticket_reminder_reached/en.html.erb
+++ b/app/views/mailer/ticket_reminder_reached/en.html.erb
@@ -1,18 +1,18 @@
-Reminder reached (<%= d 'ticket.title' %>)
+Reminder reached (#{ticket.title})
-Hi <%= d 'recipient.firstname' %>,
+Hi #{recipient.firstname},
-A ticket needs attention, reminder reached for (<%= d 'ticket.title' %>) with customer "<%= d 'ticket.customer.longname' %>".
+A ticket needs attention, reminder reached for (#{ticket.title}) with customer "#{ticket.customer.longname}".
<% if @objects[:article] %>
- <%= t 'Information' %>:
+ #{t('Information')}:
- <%= a_html 'article' %>
+ #{article.body_as_html}
<% end %>
diff --git a/app/views/mailer/ticket_update/de.html.erb b/app/views/mailer/ticket_update/de.html.erb
index 6930d2c01..bc2afff05 100644
--- a/app/views/mailer/ticket_update/de.html.erb
+++ b/app/views/mailer/ticket_update/de.html.erb
@@ -1,14 +1,14 @@
-Ticket aktualisiert (<%= d 'ticket.title' %>)
+Ticket aktualisiert (#{ticket.title})
-Hi <%= d 'recipient.firstname' %>,
+Hi #{recipient.firstname},
-Ticket (<%= d 'ticket.title' %>) wurde von "<%= d 'current_user.longname' %>" aktualisiert.
+Ticket (#{ticket.title}) wurde von "#{current_user.longname}" aktualisiert.
<% if @objects[:changes] && !@objects[:changes].empty? %>
- <%= t 'Changes' %>:
+ #{t('Changes')}:
<% @objects[:changes].each do |key, value| %>
<%= t key %>: <%= h value[0] %> -> <%= h value[1] %>
<% end %>
@@ -17,13 +17,13 @@ Ticket (<%= d 'ticket.title' %>) wurde von "
<%= d 'current_user.longname' %><
<% if @objects[:article] %>
- <%= t 'Information' %>:
+ #{t('Information')}:
- <%= a_html 'article' %>
+ #{article.body_as_html}
<% end %>
diff --git a/app/views/mailer/ticket_update/en.html.erb b/app/views/mailer/ticket_update/en.html.erb
index 220874bcc..c0dd35ec2 100644
--- a/app/views/mailer/ticket_update/en.html.erb
+++ b/app/views/mailer/ticket_update/en.html.erb
@@ -1,14 +1,14 @@
-Updated Ticket (<%= d 'ticket.title' %>)
+Updated Ticket (#{ticket.title})
-Hi <%= d 'recipient.firstname' %>,
+Hi #{recipient.firstname},
-Ticket (<%= d 'ticket.title' %>) has been updated by "<%= d 'current_user.longname' %>".
+Ticket (#{ticket.title}) has been updated by "#{current_user.longname}".
<% if @objects[:changes] && !@objects[:changes].empty? %>
- <%= t 'Changes' %>:
+ #{t('Changes')}:
<% @objects[:changes].each do |key, value| %>
<%= t key %>: <%= h value[0] %> -> <%= h value[1] %>
<% end %>
@@ -17,13 +17,13 @@ Ticket (<%= d 'ticket.title' %>) has been updated by "
<%= d 'current_user.lon
<% if @objects[:article] %>
- <%= t 'Information' %>:
+ #{t('Information')}:
- <%= a_html 'article' %>
+ #{article.body_as_html}
<% end %>
diff --git a/app/views/mailer/user_device_new/de.html.erb b/app/views/mailer/user_device_new/de.html.erb
index 889cd7b9a..a4b283ae9 100644
--- a/app/views/mailer/user_device_new/de.html.erb
+++ b/app/views/mailer/user_device_new/de.html.erb
@@ -1,19 +1,19 @@
-<%= c 'product_name' %>-Anmeldung erfasst von einem neuen Gerät
+#{config.product_name}-Anmeldung erfasst von einem neuen Gerät
-Hallo <%= d 'user.firstname' %>,
+Hallo #{user.firstname},
-es sieht aus, als ob Du Dich mit einem neuen Gerät um "<%= d 'user_device.created_at' %>" angemeldet hast:
+es sieht aus, als ob Du Dich mit einem neuen Gerät um "#{user_device.created_at}" angemeldet hast:
-Dein Gerät: <%= d 'user_device.name' %>
-Deine Lokation (relativ): <%= d 'user_device.location' %>
-Deine IP: <%= d 'user_device.ip' %>
+Dein Gerät: #{user_device.name}
+Deine Lokation (relativ): #{user_device.location}
+Deine IP: #{user_device.ip}
Das Gerät wurde in die Liste der bekannten Geräte hinzugefügt, diese Liste kannst Du hier einsehen:
-<%= c 'http_type' %>://<%= c 'fqdn' %>/#profile/devices
+#{config.http_type}://#{config.fqdn}/#profile/devices
Wenn dies nicht Du warst, entferne das Gerät aus der Liste, ändere Dein Account-Passwort und kontaktieren Deinen Administrator. Jemand könnte unberechtigten Zugriff auf Dein Konto bekommen haben.
-Dein <%= c 'product_name' %> Team
+Dein #{config.product_name} Team
diff --git a/app/views/mailer/user_device_new/en.html.erb b/app/views/mailer/user_device_new/en.html.erb
index 71b792281..70fc2bbd7 100644
--- a/app/views/mailer/user_device_new/en.html.erb
+++ b/app/views/mailer/user_device_new/en.html.erb
@@ -1,19 +1,19 @@
-<%= c 'product_name' %> signin detected from a new device
+#{config.product_name} signin detected from a new device
-Hi <%= d 'user.firstname' %>,
+Hi #{user.firstname},
-It looks like you signed into your account using a new device on "<%= d 'user_device.created_at' %>":
+It looks like you signed into your account using a new device on "#{user_device.created_at}":
-Your device: <%= d 'user_device.name' %>
-Your location (relative): <%= d 'user_device.location' %>
-Your IP: <%= d 'user_device.ip' %>
+Your device: #{user_device.name}
+Your location (relative): #{user_device.location}
+Your IP: #{user_device.ip}
Your device has been added to your list of known devices, which you can view here:
-<%= c 'http_type' %>://<%= c 'fqdn' %>/#profile/devices
+#{config.http_type}://#{config.fqdn}/#profile/devices
If this wasn't you, remove the device, changing your account password, and contacting your administrator. Somebody might have gained unauthorized access to your account.
-Your <%= c 'product_name' %> Team
+Your #{config.product_name} Team
diff --git a/app/views/mailer/user_device_new_location/de.html.erb b/app/views/mailer/user_device_new_location/de.html.erb
index 31b7fd816..d59269bcf 100644
--- a/app/views/mailer/user_device_new_location/de.html.erb
+++ b/app/views/mailer/user_device_new_location/de.html.erb
@@ -1,19 +1,19 @@
-<%= c 'product_name' %>-Anmeldung von einem anderen Land erfasst
+#{config.product_name}-Anmeldung von einem anderen Land erfasst
-Hallo <%= d 'user.firstname' %>,
+Hallo #{user.firstname},
-es sieht aus, als ob Du Dich um "<%= d 'user_device.created_at' %>" von einem bekannten Gerät aus einem anderen Land angemeldet hast:
+es sieht aus, als ob Du Dich um "#{user_device.created_at}" von einem bekannten Gerät aus einem anderen Land angemeldet hast:
-Dein Gerät: <%= d 'user_device.name' %>
-Deine Lokation (relativ): <%= d 'user_device.location' %>
-Deine IP: <%= d 'user_device.ip' %>
+Dein Gerät: #{user_device.name}
+Deine Lokation (relativ): #{user_device.location}
+Deine IP: #{user_device.ip}
Das neue Land wurde in die Liste der bekannten Geräte hinzugefügt, diese Liste kannst Du hier einsehen:
-<%= c 'http_type' %>://<%= c 'fqdn' %>/#profile/devices
+#{config.http_type}://#{config.fqdn}/#profile/devices
Wenn dies nicht Du warst, entferne die neue Lokation aus der Liste, ändere Dein Account-Passwort und kontaktieren Deinen Administrator. Jemand könnte unberechtigten Zugriff auf Dein Konto bekommen haben.
-Dein <%= c 'product_name' %> Team
+Dein #{config.product_name} Team
diff --git a/app/views/mailer/user_device_new_location/en.html.erb b/app/views/mailer/user_device_new_location/en.html.erb
index 2cdfb5a6f..6b9119591 100644
--- a/app/views/mailer/user_device_new_location/en.html.erb
+++ b/app/views/mailer/user_device_new_location/en.html.erb
@@ -1,19 +1,19 @@
-<%= c 'product_name' %> signin detected from a new country
+#{config.product_name} signin detected from a new country
-Hi <%= d 'user.firstname' %>,
+Hi #{user.firstname},
-It looks like you used your account with an known device but from a new country on "<%= d 'user_device.created_at' %>":
+It looks like you used your account with an known device but from a new country on "#{user_device.created_at}":
-Your device: <%= d 'user_device.name' %>
-Your location (relative): <%= d 'user_device.location' %>
-Your IP: <%= d 'user_device.ip' %>
+Your device: #{user_device.name}
+Your location (relative): #{user_device.location}
+Your IP: #{user_device.ip}
The country has been added to your list of known devices, which you can view here:
-<%= c 'http_type' %>://<%= c 'fqdn' %>/#profile/devices
+#{config.http_type}://#{config.fqdn}/#profile/devices
If this wasn't you, remove the device, changing your account password, and contacting your administrator. Somebody might have gained unauthorized access to your account.
-Your <%= c 'product_name' %> Team
+Your #{config.product_name} Team
diff --git a/app/views/mailer/user_invite/de.html.erb b/app/views/mailer/user_invite/de.html.erb
index b83a06dd8..48504b298 100644
--- a/app/views/mailer/user_invite/de.html.erb
+++ b/app/views/mailer/user_invite/de.html.erb
@@ -1,13 +1,13 @@
-Einladung zu <%= c 'product_name' %> über <%= c 'fqdn' %>
+Einladung zu #{config.product_name} über #{config.fqdn}
-Hallo <%= d 'user.firstname' %>,
+Hallo #{user.firstname},
-Ich (<%= d 'current_user.firstname' %> <%= d 'current_user.lastname' %>) möchte Dich zu <%= c 'product_name' %> einladen - unsere Kundensupport / Ticket System Platform.
+Ich (#{current_user.firstname} #{current_user.lastname}) möchte Dich zu #{config.product_name} einladen - unsere Kundensupport / Ticket System Platform.
-Um sich anzumelden kann
hier das Password gesetzt werden.
+Um sich anzumelden kann
hier das Password gesetzt werden.
Enjoy,
-<%= d 'current_user.firstname' %> <%= d 'current_user.lastname' %>
+#{current_user.firstname} #{current_user.lastname}
-Dein <%= c 'product_name' %> Team
+Dein #{config.product_name} Team
diff --git a/app/views/mailer/user_invite/en.html.erb b/app/views/mailer/user_invite/en.html.erb
index 0dea44860..52e3b39db 100644
--- a/app/views/mailer/user_invite/en.html.erb
+++ b/app/views/mailer/user_invite/en.html.erb
@@ -1,13 +1,13 @@
-Invitation to <%= c 'product_name' %> at <%= c 'fqdn' %>
+Invitation to #{config.product_name} at #{config.fqdn}
-Hi <%= d 'user.firstname' %>,
+Hi #{user.firstname},
-I (<%= d 'current_user.firstname' %> <%= d 'current_user.lastname' %>) invite you to <%= c 'product_name' %> - our customer support / ticket system platform.
+I (#{current_user.firstname} #{current_user.lastname}) invite you to #{config.product_name} - our customer support / ticket system platform.
-Click
here and set your password.
+Click
here and set your password.
Enjoy,
-<%= d 'current_user.firstname' %> <%= d 'current_user.lastname' %>
+#{current_user.firstname} #{current_user.lastname}
-Your <%= c 'product_name' %> Team
+Your #{config.product_name} Team
diff --git a/app/views/slack/ticket_create/en.md.erb b/app/views/slack/ticket_create/en.md.erb
index 0d8268e39..e35162286 100644
--- a/app/views/slack/ticket_create/en.md.erb
+++ b/app/views/slack/ticket_create/en.md.erb
@@ -1,9 +1,9 @@
-# <%= d 'ticket.title' %>
-_<<%= c 'http_type' %>://<%= c 'fqdn' %>/#ticket/zoom/<%= d 'ticket.id' %>|Ticket#<%= d 'ticket.number' %>>: Created by <%= d 'current_user.longname' %> at <%= d 'ticket.updated_at' %>_
-* <%= t 'Group' %>: <%= d 'ticket.group.name' %>
-* <%= t 'Owner' %>: <%= d 'ticket.owner.fullname' %>
-* <%= t 'State' %>: <%= t d 'ticket.state.name' %>
+# #{ticket.title}
+_<#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}|Ticket##{ticket.number}>: Created by #{current_user.longname} at #{ticket.updated_at}_
+* #{t('Group')}: #{ticket.group.name}
+* #{t('Owner')}: #{ticket.owner.fullname}
+* #{t('State')}: #{t(ticket.state.name)}
<% if @objects[:article] %>
-<%= a_text 'article' %>
+#{article.body_as_text}
<% end %>
diff --git a/app/views/slack/ticket_escalation/en.md.erb b/app/views/slack/ticket_escalation/en.md.erb
index e9d232544..9cd928ab3 100644
--- a/app/views/slack/ticket_escalation/en.md.erb
+++ b/app/views/slack/ticket_escalation/en.md.erb
@@ -1,7 +1,7 @@
-# <%= d 'ticket.title' %>
-_<<%= c 'http_type' %>://<%= c 'fqdn' %>/#ticket/zoom/<%= d 'ticket.id' %>|Ticket#<%= d 'ticket.number' %>>: Escalated at <%= d 'ticket.escalation_at' %>_
-A ticket (<%= d 'ticket.title' %>) from "<%= d 'ticket.customer.longname' %>" is escalated since "<%= d 'ticket.escalation_at' %>"!
+# #{ticket.title}
+_<#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}|Ticket##{ticket.number}>: Escalated at #{ticket.escalation_at}_
+A ticket (#{ticket.title}) from "#{ticket.customer.longname}" is escalated since "#{ticket.escalation_at}"!
<% if @objects[:article] %>
-<%= a_text 'article' %>
+#{article.body_as_text}
<% end %>
diff --git a/app/views/slack/ticket_escalation_warning/en.md.erb b/app/views/slack/ticket_escalation_warning/en.md.erb
index 15068b0fb..ae976b512 100644
--- a/app/views/slack/ticket_escalation_warning/en.md.erb
+++ b/app/views/slack/ticket_escalation_warning/en.md.erb
@@ -1,7 +1,7 @@
-# <%= d 'ticket.title' %>
-_<<%= c 'http_type' %>://<%= c 'fqdn' %>/#ticket/zoom/<%= d 'ticket.id' %>|Ticket#<%= d 'ticket.number' %>>: Will escalate at <%= d 'ticket.escalation_at' %>_
-A ticket (<%= d 'ticket.title' %>) from "<%= d 'ticket.customer.longname' %>" will escalate at "<%= d 'ticket.escalation_at' %>"!
+# #{ticket.title}
+_<#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}|Ticket##{ticket.number}>: Will escalate at #{ticket.escalation_at}_
+A ticket (#{ticket.title}) from "#{ticket.customer.longname}" will escalate at "#{ticket.escalation_at}"!
<% if @objects[:article] %>
-<%= a_text 'article' %>
+#{article.body_as_text}
<% end %>
diff --git a/app/views/slack/ticket_reminder_reached/en.md.erb b/app/views/slack/ticket_reminder_reached/en.md.erb
index 8ae47fc71..7156b6464 100644
--- a/app/views/slack/ticket_reminder_reached/en.md.erb
+++ b/app/views/slack/ticket_reminder_reached/en.md.erb
@@ -1,7 +1,7 @@
-# <%= d 'ticket.title' %>
-_<<%= c 'http_type' %>://<%= c 'fqdn' %>/#ticket/zoom/<%= d 'ticket.id' %>|Ticket#<%= d 'ticket.number' %>>: Reminder reached!_
-A ticket needs attention, reminder reached for (<%= d 'ticket.title' %>) with customer "*<%= d 'ticket.customer.longname' %>*".
+# #{ticket.title}
+_<#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}|Ticket##{ticket.number}>: Reminder reached!_
+A ticket needs attention, reminder reached for (#{ticket.title}) with customer "*#{ticket.customer.longname}*".
<% if @objects[:article] %>
-<%= a_text 'article' %>
+#{article.body_as_text}
<% end %>
diff --git a/app/views/slack/ticket_update/en.md.erb b/app/views/slack/ticket_update/en.md.erb
index fe1a80e29..e8a9f86de 100644
--- a/app/views/slack/ticket_update/en.md.erb
+++ b/app/views/slack/ticket_update/en.md.erb
@@ -1,5 +1,5 @@
-# <%= d 'ticket.title' %>
-_<<%= c 'http_type' %>://<%= c 'fqdn' %>/#ticket/zoom/<%= d 'ticket.id' %>|Ticket#<%= d 'ticket.number' %>>: Updated by <%= d 'current_user.longname' %> at <%= d 'ticket.updated_at' %>_
+# #{ticket.title}
+_<#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}|Ticket##{ticket.number}>: Updated by #{current_user.longname} at #{ticket.updated_at}_
<% if @objects[:changes] && !@objects[:changes].empty? %>
<% @objects[:changes].each do |key, value| %>
* <%= t key %>: <%= h value[0] %> -> <%= h value[1] %>
@@ -7,5 +7,5 @@ _<<%= c 'http_type' %>://<%= c 'fqdn' %>/#ticket/zoom/<%= d 'ticket.id' %>|Ticke
<% end %>
<% if @objects[:article] %>
-<%= a_text 'article' %>
+#{article.body_as_text}
<% end %>
diff --git a/lib/notification_factory/mailer.rb b/lib/notification_factory/mailer.rb
index ca70330c4..79895fb84 100644
--- a/lib/notification_factory/mailer.rb
+++ b/lib/notification_factory/mailer.rb
@@ -6,7 +6,7 @@ get notification settings for user and notification type
result = NotificationFactory::Mailer.notification_settings(user, ticket, type)
- type: create | update | reminder_reached | pending
+ type: create | update | reminder_reached | escalation (escalation_warning)
returns
@@ -21,6 +21,15 @@ returns
=end
def self.notification_settings(user, ticket, type)
+
+ # map types if needed
+ map = {
+ 'escalation_warning' => 'escalation'
+ }
+ if map[type]
+ type = map[type]
+ end
+
return if !user.preferences
return if !user.preferences['notification_config']
matrix = user.preferences['notification_config']['matrix']
@@ -190,11 +199,12 @@ retunes
)
result = NotificationFactory::Mailer.template(
- templateInline: "Invitation to <%= c 'product_name' %> at <%= c 'fqdn' %>",
+ templateInline: "Invitation to \#{config.product_name} at \#{config.fqdn}",
locale: 'en-us',
objects: {
recipient: User.find(2),
},
+ quote: true, # html quoting
)
only raw subject/body
@@ -221,7 +231,7 @@ returns
def self.template(data)
if data[:templateInline]
- return NotificationFactory::Renderer.new(data[:objects], data[:locale], data[:templateInline], false).render
+ return NotificationFactory::Renderer.new(data[:objects], data[:locale], data[:templateInline], data[:quote]).render
end
template = NotificationFactory.template_read(
diff --git a/lib/notification_factory/renderer.rb b/lib/notification_factory/renderer.rb
index 86e60814f..e8d4a8697 100644
--- a/lib/notification_factory/renderer.rb
+++ b/lib/notification_factory/renderer.rb
@@ -9,7 +9,7 @@ examples how to use
ticket: Ticket.first,
},
'de-de',
- 'some template <%= d "ticket.title", false %> <%= c "fqdn", false %>',
+ 'some template #{ticket.title} {config.fqdn}',
false
).render
@@ -18,7 +18,7 @@ examples how to use
ticket: Ticket.first,
},
'de-de',
- 'some template <%= d "ticket.title", true %> <%= c "fqdn", true %>',
+ 'some template #{ticket.title} #{config.fqdn}',
).render
=end
@@ -26,7 +26,7 @@ examples how to use
def initialize(objects, locale, template, escape = true)
@objects = objects
@locale = locale || 'en-us'
- @template = NotificationFactory::Template.new(template)
+ @template = NotificationFactory::Template.new(template, escape)
@escape = escape
end
@@ -41,6 +41,25 @@ examples how to use
# do validaton, ignore some methodes
return "\#{#{key} / not allowed}" if !data_key_valid?(key)
+ # aliases
+ map = {
+ 'article.body' => 'article.body_as_text_with_quote.text2html',
+ }
+ if map[key]
+ key = map[key]
+ end
+
+ # escape in html mode
+ if escape
+ no_escape = {
+ 'article.body_as_html' => true,
+ 'article.body_as_text_with_quote.text2html' => true,
+ }
+ if no_escape[key]
+ escape = false
+ end
+ end
+
value = nil
object_methods = key.split('.')
object_name = object_methods.shift
@@ -76,7 +95,11 @@ examples how to use
value = "\#{#{object_name}.#{object_methods_s} / no such method}"
break
end
- object_refs = object_refs.send(method.to_sym)
+ begin
+ object_refs = object_refs.send(method.to_sym)
+ rescue => e
+ object_refs = "\#{#{object_name}.#{object_methods_s} / e.message}"
+ end
}
placeholder = if !value
object_refs
@@ -100,27 +123,6 @@ examples how to use
escaping(translation, escape)
end
- # a_html - article body in html
- # a_html(article)
- def a_html(article)
- content_type = d "#{article}.content_type", false
- if content_type =~ /html/
- return d "#{article}.body", false
- end
- d("#{article}.body", false).text2html
- end
-
- # a_text - article body in text
- # a_text(article)
- def a_text(article)
- content_type = d "#{article}.content_type", false
- body = d "#{article}.body", false
- if content_type =~ /html/
- body = body.html2text
- end
- (body.strip + "\n").gsub(/^(.*?)$/, '> \\1')
- end
-
# h - htmlEscape
# h('fqdn', htmlEscape)
def h(key)
@@ -137,7 +139,7 @@ examples how to use
end
def data_key_valid?(key)
- return false if key =~ /`|\.(|\s*)(save|destroy|delete|remove|drop|update|create|new|all|where|find)/i
+ return false if key =~ /`|\.(|\s*)(save|destroy|delete|remove|drop|update|create|new|all|where|find)/i && key !~ /(update|create)d_at/i
true
end
diff --git a/lib/notification_factory/slack.rb b/lib/notification_factory/slack.rb
index c0102e460..da8dc3b6c 100644
--- a/lib/notification_factory/slack.rb
+++ b/lib/notification_factory/slack.rb
@@ -33,8 +33,8 @@ returns
type: 'slack',
)
- message_subject = NotificationFactory::Renderer.new(data[:objects], data[:locale], template[:subject]).render
- message_body = NotificationFactory::Renderer.new(data[:objects], data[:locale], template[:body]).render
+ message_subject = NotificationFactory::Renderer.new(data[:objects], data[:locale], template[:subject], false).render
+ message_body = NotificationFactory::Renderer.new(data[:objects], data[:locale], template[:body], false).render
if !data[:raw]
application_template = NotificationFactory.application_template_read(
@@ -43,7 +43,7 @@ returns
)
data[:objects][:message] = message_body
data[:objects][:standalone] = data[:standalone]
- message_body = NotificationFactory::Renderer.new(data[:objects], data[:locale], application_template).render
+ message_body = NotificationFactory::Renderer.new(data[:objects], data[:locale], application_template, false).render
end
{
subject: message_subject.strip!,
diff --git a/lib/notification_factory/template.rb b/lib/notification_factory/template.rb
index 7da6e8efe..76dbe7c53 100644
--- a/lib/notification_factory/template.rb
+++ b/lib/notification_factory/template.rb
@@ -5,13 +5,15 @@ class NotificationFactory::Template
examples how to use
cleaned_template = NotificationFactory::Template.new(
- 'some template <%= d "ticket.title", false %> <%= c "fqdn", false %>',
+ 'some template #{ticket.title} #{config.fqdn}',
+ true,
).to_s
=end
- def initialize(template)
+ def initialize(template, escape)
@template = template
+ @escape = escape
end
def to_s
@@ -23,7 +25,35 @@ examples how to use
def strip_html
# some browsers start adding HTML tags
# fixes https://github.com/zammad/zammad/issues/385
- @template.gsub!(%r{#\{\s*<[^>]+>([^<]+)[^>]+>\s*\}}, '\1')
- @template.gsub!(/#\{\s*<[^>]+>([^<]+)\s*\}/, '\1')
+ @template.gsub!(/\#\{\s*t\((.+?)\)\s*\}/m) do
+ content = $1
+ if content =~ /^'(.+?)'$/
+ "<%= t \"#{strip_content($1)}\", #{@escape} %>"
+ else
+ "<%= t d\"#{strip_variable(content)}\", #{@escape} %>"
+ end
+ end
+ @template.gsub!(/\#\{\s*config\.(.+?)\s*\}/m) do
+ "<%= c \"#{strip_variable($1)}\", #{@escape} %>"
+ end
+ @template.gsub!(/\#\{(.*?)\}/m) do
+ "<%= d \"#{strip_variable($1)}\", #{@escape} %>"
+ end
end
+
+ def strip_content(string)
+ return string if !string
+ string.gsub!(/\t|\r|\n/, '')
+ string.gsub!(/"/, '\"')
+ string
+ end
+
+ def strip_variable(string)
+ return string if !string
+ string.gsub!(/\t|\r|\n|"|'|§|;/, '')
+ string.gsub!(/\s*/, '')
+ string.gsub!(/<.+?>/, '')
+ string
+ end
+
end
diff --git a/test/unit/notification_factory_renderer_test.rb b/test/unit/notification_factory_renderer_test.rb
index a6e5bb0e7..d091afeec 100644
--- a/test/unit/notification_factory_renderer_test.rb
+++ b/test/unit/notification_factory_renderer_test.rb
@@ -3,29 +3,40 @@ require 'test_helper'
class NotificationFactoryRendererTest < ActiveSupport::TestCase
- # TODO: should be mocked somehow
- Translation.load('de-de')
-
# RSpec incoming!
def described_class
NotificationFactory::Renderer
end
- Group = Struct.new(:name)
- State = Struct.new(:name)
- User = Struct.new(:firstname, :lastname, :longname, :fullname)
- Ticket = Struct.new(:id, :title, :group, :owner, :state)
-
- group = Group.new('Users')
- state = State.new('new')
- owner = User.new('Notificationxxx', 'Agent1yyy', 'Notificationxxx Agent1yyy', 'Notificationxxx Agent1yyy (Zammad)')
- current_user = User.new('CurrentUserxxx', 'Agent2yyy', 'CurrentUserxxx Agent2yyy', 'CurrentUserxxx Agent2yyy (Zammad)')
- recipient = User.new('Recipientxxx', 'Customer1yyy', 'Recipientxxx Customer1yyy', 'Recipientxxx Customer1yyy (Zammad)')
- ticket = Ticket.new(1, 'Welcome to Zammad!', group, owner, state)
+ group = Group.new(name: 'Users')
+ owner = User.new(firstname: 'Notificationxxx', lastname: 'Agent1yyy')
+ current_user = User.new(firstname: 'CurrentUserxxx', lastname: 'Agent2yyy')
+ recipient = User.new(firstname: 'Recipientxxx', lastname: 'Customer1yyy')
+ state = Ticket::State.new(name: 'new')
+ ticket = Ticket.new(
+ id: 1,
+ title: 'Welcome to Zammad!',
+ group: group,
+ owner: owner,
+ state: state,
+ created_at: Time.zone.parse('2016-11-12 12:00:00 UTC'),
+ updated_at: Time.zone.parse('2016-11-12 14:00:00 UTC'),
+ )
+ article_html1 = Ticket::Article.new(
+ body: 'test hello
some new line',
+ content_type: 'text/html',
+ )
+ article_plain1 = Ticket::Article.new(
+ body: "test hello\nsome new line",
+ content_type: 'text/plain',
+ )
+ article_plain2 = Ticket::Article.new(
+ body: "test hello\nsome new line",
+ )
test 'replace object attribute' do
- template = "<%= d 'ticket.title' %>"
+ template = "\#{ticket.title}"
result = described_class.new(
{
ticket: ticket,
@@ -35,7 +46,27 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML(ticket.title), result)
- template = "<%= d 'ticket. title' %>"
+ template = "\#{ticket.created_at}"
+ result = described_class.new(
+ {
+ ticket: ticket,
+ },
+ 'en-us',
+ template,
+ ).render
+ assert_equal(ticket.created_at.to_s, result)
+
+ template = "\#{ticket.updated_at}"
+ result = described_class.new(
+ {
+ ticket: ticket,
+ },
+ 'en-us',
+ template,
+ ).render
+ assert_equal(ticket.updated_at.to_s, result)
+
+ template = "\#{ticket. title}"
result = described_class.new(
{
ticket: ticket,
@@ -45,7 +76,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML(ticket.title), result)
- template = "<%= d 'ticket.\n title' %>"
+ template = "\#{ticket.\n title}"
result = described_class.new(
{
ticket: ticket,
@@ -55,7 +86,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML(ticket.title), result)
- template = "<%= d 'ticket.\t title' %>"
+ template = "\#{ticket.\t title}"
result = described_class.new(
{
ticket: ticket,
@@ -65,7 +96,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML(ticket.title), result)
- template = "<%= d 'ticket.\t\n title\t' %>"
+ template = "\#{ticket.\t\n title\t}"
result = described_class.new(
{
ticket: ticket,
@@ -75,13 +106,50 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML(ticket.title), result)
+ template = "\#{ticket.\" title\t}"
+ result = described_class.new(
+ {
+ ticket: ticket,
+ },
+ 'en-us',
+ template,
+ ).render
+ assert_equal(CGI.escapeHTML(ticket.title), result)
+
+ template = "some test
\#{article.body}"
+ result = described_class.new(
+ {
+ article: article_html1,
+ },
+ 'en-us',
+ template,
+ ).render
+ assert_equal('some test
> test hello
> some new line
', result)
+
+ result = described_class.new(
+ {
+ article: article_plain1,
+ },
+ 'en-us',
+ template,
+ ).render
+ assert_equal('some test
> test <b>hello</b>
> some new line
', result)
+
+ result = described_class.new(
+ {
+ article: article_plain2,
+ },
+ 'en-us',
+ template,
+ ).render
+ assert_equal('some test
> test <b>hello</b>
> some new line
', result)
+
end
test 'config' do
- setting = 'fqdn'
- template = "<%= c '#{setting}' %>"
-
+ setting = 'fqdn'
+ template = "\#{config.#{setting}}"
result = described_class.new(
{
ticket: ticket,
@@ -89,13 +157,11 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
'en-us',
template,
).render
-
assert_equal(Setting.get(setting), result)
setting1 = 'fqdn'
setting2 = 'product_name'
- template = "some <%= c '#{setting1}' %> and <%= c '#{setting2}' %>"
-
+ template = "some \#{config.#{setting1}} and \#{config.#{setting2}}"
result = described_class.new(
{
ticket: ticket,
@@ -103,14 +169,25 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
'en-us',
template,
).render
+ assert_equal("some #{Setting.get(setting1)} and #{Setting.get(setting2)}", result)
+ setting1 = 'fqdn'
+ setting2 = 'product_name'
+ template = "some \#{ config.#{setting1}} and \#{\tconfig.#{setting2}}"
+ result = described_class.new(
+ {
+ ticket: ticket,
+ },
+ 'en-us',
+ template,
+ ).render
assert_equal("some #{Setting.get(setting1)} and #{Setting.get(setting2)}", result)
end
test 'translation' do
- template = "<%= t 'new' %>"
-
+ #template = "<%= t 'new' %>"
+ template = "\#{t('new')}"
result = described_class.new(
{
ticket: ticket,
@@ -118,11 +195,9 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
'de-de',
template,
).render
-
assert_equal('neu', result)
- template = "some text <%= t 'new' %> and <%= t 'open' %>"
-
+ template = "some text \#{t('new')} and \#{t('open')}"
result = described_class.new(
{
ticket: ticket,
@@ -130,14 +205,33 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
'de-de',
template,
).render
+ assert_equal('some text neu and offen', result)
+ template = "some text \#{t('new') } and \#{ t('open')}"
+ result = described_class.new(
+ {
+ ticket: ticket,
+ },
+ 'de-de',
+ template,
+ ).render
+ assert_equal('some text neu and offen', result)
+
+ template = "some text \#{\nt('new') } and \#{ t('open')\t}"
+ result = described_class.new(
+ {
+ ticket: ticket,
+ },
+ 'de-de',
+ template,
+ ).render
assert_equal('some text neu and offen', result)
end
test 'chained function calls' do
- template = "<%= t d 'ticket.state.name' %>"
+ template = "\#{t(ticket.state.name)}"
result = described_class.new(
{
@@ -152,7 +246,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
test 'not existing object and attribute' do
- template = "<%= d '' %>"
+ template = "\#{}"
result = described_class.new(
{
ticket: ticket,
@@ -162,7 +256,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{no such object}'), result)
- template = "<%= d 'notexsiting.notexsiting' %>"
+ template = "\#{notexsiting.notexsiting}"
result = described_class.new(
{
ticket: ticket,
@@ -172,7 +266,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{notexsiting / no such object}'), result)
- template = "<%= d 'ticket.notexsiting' %>"
+ template = "\#{ticket.notexsiting}"
result = described_class.new(
{
ticket: ticket,
@@ -182,7 +276,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{ticket.notexsiting / no such method}'), result)
- template = "<%= d 'ticket.' %>"
+ template = "\#{ticket.}"
result = described_class.new(
{
ticket: ticket,
@@ -192,7 +286,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{ticket. / no such method}'), result)
- template = "<%= d 'ticket.title.notexsiting' %>"
+ template = "\#{ticket.title.notexsiting}"
result = described_class.new(
{
ticket: ticket,
@@ -202,7 +296,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{ticket.title.notexsiting / no such method}'), result)
- template = "<%= d 'ticket.notexsiting.notexsiting' %>"
+ template = "\#{ticket.notexsiting.notexsiting}"
result = described_class.new(
{
ticket: ticket,
@@ -212,7 +306,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{ticket.notexsiting / no such method}'), result)
- template = "<%= d 'notexsiting' %>"
+ template = "\#{notexsiting}"
result = described_class.new(
{
ticket: ticket,
@@ -222,7 +316,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{notexsiting / no such object}'), result)
- template = "<%= d 'notexsiting.' %>"
+ template = "\#{notexsiting.}"
result = described_class.new(
{
ticket: ticket,
@@ -232,7 +326,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{notexsiting / no such object}'), result)
- template = "<%= d 'string' %>"
+ template = "\#{string}"
result = described_class.new(
{
string: 'some string',
@@ -242,7 +336,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('some string'), result)
- template = "<%= d 'fixum' %>"
+ template = "\#{fixum}"
result = described_class.new(
{
fixum: 123,
@@ -252,7 +346,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('123'), result)
- template = "<%= d 'float' %>"
+ template = "\#{float}"
result = described_class.new(
{
float: 123.99,
@@ -266,7 +360,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
test 'data key validation' do
- template = "<%= d 'ticket.title `echo 1`' %>"
+ template = "\#{ticket.title `echo 1`}"
result = described_class.new(
{
ticket: ticket,
@@ -274,9 +368,9 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
'en-us',
template,
).render
- assert_equal(CGI.escapeHTML('#{ticket.title `echo 1` / not allowed}'), result)
+ assert_equal(CGI.escapeHTML('#{ticket.title`echo1` / not allowed}'), result)
- template = "<%= d 'ticket.destroy' %>"
+ template = "\#{ticket.destroy}"
result = described_class.new(
{
ticket: ticket,
@@ -286,7 +380,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{ticket.destroy / not allowed}'), result)
- template = "<%= d 'ticket.save' %>"
+ template = "\#{ticket.save}"
result = described_class.new(
{
ticket: ticket,
@@ -296,7 +390,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{ticket.save / not allowed}'), result)
- template = "<%= d 'ticket.update' %>"
+ template = "\#{ticket.update}"
result = described_class.new(
{
ticket: ticket,
@@ -306,37 +400,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{ticket.update / not allowed}'), result)
- template = "<%= d 'ticket.delete' %>"
- result = described_class.new(
- {
- ticket: ticket,
- },
- 'en-us',
- template,
- ).render
- assert_equal(CGI.escapeHTML('#{ticket.delete / not allowed}'), result)
-
- template = "<%= d 'ticket.remove' %>"
- result = described_class.new(
- {
- ticket: ticket,
- },
- 'en-us',
- template,
- ).render
- assert_equal(CGI.escapeHTML('#{ticket.remove / not allowed}'), result)
-
- template = "<%= d 'ticket.drop' %>"
- result = described_class.new(
- {
- ticket: ticket,
- },
- 'en-us',
- template,
- ).render
- assert_equal(CGI.escapeHTML('#{ticket.drop / not allowed}'), result)
-
- template = "<%= d 'ticket.create' %>"
+ template = "\#{ticket.create}"
result = described_class.new(
{
ticket: ticket,
@@ -346,7 +410,47 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{ticket.create / not allowed}'), result)
- template = "<%= d 'ticket.new' %>"
+ template = "\#{ticket.delete}"
+ result = described_class.new(
+ {
+ ticket: ticket,
+ },
+ 'en-us',
+ template,
+ ).render
+ assert_equal(CGI.escapeHTML('#{ticket.delete / not allowed}'), result)
+
+ template = "\#{ticket.remove}"
+ result = described_class.new(
+ {
+ ticket: ticket,
+ },
+ 'en-us',
+ template,
+ ).render
+ assert_equal(CGI.escapeHTML('#{ticket.remove / not allowed}'), result)
+
+ template = "\#{ticket.drop}"
+ result = described_class.new(
+ {
+ ticket: ticket,
+ },
+ 'en-us',
+ template,
+ ).render
+ assert_equal(CGI.escapeHTML('#{ticket.drop / not allowed}'), result)
+
+ template = "\#{ticket.create}"
+ result = described_class.new(
+ {
+ ticket: ticket,
+ },
+ 'en-us',
+ template,
+ ).render
+ assert_equal(CGI.escapeHTML('#{ticket.create / not allowed}'), result)
+
+ template = "\#{ticket.new}"
result = described_class.new(
{
ticket: ticket,
@@ -356,7 +460,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{ticket.new / not allowed}'), result)
- template = "<%= d 'ticket.update_att' %>"
+ template = "\#{ticket.update_att}"
result = described_class.new(
{
ticket: ticket,
@@ -366,7 +470,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{ticket.update_att / not allowed}'), result)
- template = "<%= d 'ticket.all' %>"
+ template = "\#{ticket.all}"
result = described_class.new(
{
ticket: ticket,
@@ -376,7 +480,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{ticket.all / not allowed}'), result)
- template = "<%= d 'ticket.find' %>"
+ template = "\#{ticket.find}"
result = described_class.new(
{
ticket: ticket,
@@ -386,7 +490,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{ticket.find / not allowed}'), result)
- template = "<%= d 'ticket.where' %>"
+ template = "\#{ticket.where}"
result = described_class.new(
{
ticket: ticket,
@@ -396,7 +500,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(CGI.escapeHTML('#{ticket.where / not allowed}'), result)
- template = "<%= d 'ticket. destroy' %>"
+ template = "\#{ticket. destroy}"
result = described_class.new(
{
ticket: ticket,
@@ -404,9 +508,9 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
'en-us',
template,
).render
- assert_equal(CGI.escapeHTML('#{ticket. destroy / not allowed}'), result)
+ assert_equal(CGI.escapeHTML('#{ticket.destroy / not allowed}'), result)
- template = "<%= d 'ticket.\n destroy' %>"
+ template = "\#{ticket.\n destroy}"
result = described_class.new(
{
ticket: ticket,
@@ -414,9 +518,9 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
'en-us',
template,
).render
- assert_equal(CGI.escapeHTML("\#{ticket.\n destroy / not allowed}"), result)
+ assert_equal(CGI.escapeHTML("\#{ticket.destroy / not allowed}"), result)
- template = "<%= d 'ticket.\t destroy' %>"
+ template = "\#{ticket.\t destroy}"
result = described_class.new(
{
ticket: ticket,
@@ -424,9 +528,9 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
'en-us',
template,
).render
- assert_equal(CGI.escapeHTML("\#{ticket.\t destroy / not allowed}"), result)
+ assert_equal(CGI.escapeHTML("\#{ticket.destroy / not allowed}"), result)
- template = "<%= d 'ticket.\r destroy' %>"
+ template = "\#{ticket.\r destroy}"
result = described_class.new(
{
ticket: ticket,
@@ -434,7 +538,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
'en-us',
template,
).render
- assert_equal(CGI.escapeHTML("\#{ticket.\r destroy / not allowed}"), result)
+ assert_equal(CGI.escapeHTML("\#{ticket.destroy / not allowed}"), result)
end
diff --git a/test/unit/notification_factory_slack_template_test.rb b/test/unit/notification_factory_slack_template_test.rb
index d746c4b42..cb3b349f0 100644
--- a/test/unit/notification_factory_slack_template_test.rb
+++ b/test/unit/notification_factory_slack_template_test.rb
@@ -78,7 +78,7 @@ class NotificationFactorySlackTemplateTest < ActiveSupport::TestCase
)
assert_match('# Welcome to Zammad!', result[:subject])
- assert_match('User<b>xxx</b>', result[:body])
+ assert_match('Userxxx', result[:body])
assert_match('Created by', result[:body])
assert_match('test123', result[:body])
assert_no_match('Dein', result[:body])
@@ -113,7 +113,7 @@ class NotificationFactorySlackTemplateTest < ActiveSupport::TestCase
},
)
assert_match('# Welcome to Zammad!', result[:subject])
- assert_match('User<b>xxx</b>', result[:body])
+ assert_match('Userxxx', result[:body])
assert_match('state: aaa -> bbb', result[:body])
assert_match('group: xxx -> yyy', result[:body])
assert_no_match('Dein', result[:body])
diff --git a/test/unit/notification_factory_template_test.rb b/test/unit/notification_factory_template_test.rb
index c8ad841f7..baee7c7ea 100644
--- a/test/unit/notification_factory_template_test.rb
+++ b/test/unit/notification_factory_template_test.rb
@@ -11,48 +11,69 @@ class NotificationFactoryTemplateTest < ActiveSupport::TestCase
test 'regular browser html' do
# ensures https://github.com/zammad/zammad/issues/385
- template_before = '<%= d "#{ticket.id}" %>'
- template_after = '<%= d "ticket.id" %>'
+ template_before = '#{ticket.id}'
+ template_after = '<%= d "ticket.id", true %>'
- result = described_class.new(template_before).to_s
+ result = described_class.new(template_before, true).to_s
+ assert_equal(template_after, result)
+
+ template_before = '#{config.fqdn}'
+ template_after = '<%= d "config.fqdn", true %>'
+
+ result = described_class.new(template_before, true).to_s
assert_equal(template_after, result)
end
test 'spaced browser html' do
# ensures https://github.com/zammad/zammad/issues/385
- template_before = '<%= d "#{ ticket.id } " %>'
- template_after = '<%= d "ticket.id " %>'
+ template_before = '#{ ticket.id }'
+ template_after = '<%= d "ticket.id", true %>'
- result = described_class.new(template_before).to_s
+ result = described_class.new(template_before, true).to_s
assert_equal(template_after, result)
end
test 'broken browser html' do
# ensures https://github.com/zammad/zammad/issues/385
- template_before = '<%= d "#{ticket.id }" %>'
- template_after = '<%= d "ticket.id " %>'
+ template_before = '#{ticket.id }'
+ template_after = '<%= d "ticket.id", true %>'
- result = described_class.new(template_before).to_s
+ result = described_class.new(template_before, true).to_s
assert_equal(template_after, result)
end
test 'empty tag' do
- template_before = '<%= d "#{}" %>'
- template_after = '<%= d "#{}" %>'
+ template_before = '#{}'
+ template_after = '<%= d "", true %>'
- result = described_class.new(template_before).to_s
+ result = described_class.new(template_before, true).to_s
assert_equal(template_after, result)
end
test 'empty tag with space' do
- template_before = '<%= d "#{ }" %>'
- template_after = '<%= d "#{ }" %>'
+ template_before = '#{ }'
+ template_after = '<%= d "", false %>'
- result = described_class.new(template_before).to_s
+ result = described_class.new(template_before, false).to_s
+ assert_equal(template_after, result)
+ end
+
+ test 'translation' do
+
+ template_before = "\#{t('some text')}"
+ template_after = '<%= t "some text", false %>'
+
+ result = described_class.new(template_before, false).to_s
+ assert_equal(template_after, result)
+
+ template_before = "\#{t('some \"text\"')}"
+ template_after = '<%= t "some \"text\"", false %>'
+
+ result = described_class.new(template_before, false).to_s
assert_equal(template_after, result)
end
diff --git a/test/unit/ticket_trigger_test.rb b/test/unit/ticket_trigger_test.rb
index 9b9adf90b..5d86c2659 100644
--- a/test/unit/ticket_trigger_test.rb
+++ b/test/unit/ticket_trigger_test.rb
@@ -13,7 +13,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
},
perform: {
'notification.email' => {
- 'body' => 'some text
#{ticket.customer.lastname}
#{ticket.title}',
+ 'body' => 'some text
#{ticket.customer.lastname}
#{ticket.title}
#{article.body}',
'recipient' => 'ticket_customer',
'subject' => 'Thanks for your inquiry (#{ticket.title})!',
},
@@ -60,12 +60,25 @@ class TicketTriggerTest < ActiveSupport::TestCase
created_by_id: 1,
)
assert(ticket1, 'ticket1 created')
+ Ticket::Article.create(
+ ticket_id: ticket1.id,
+ from: 'some_sender@example.com',
+ to: 'some_recipient@example.com',
+ subject: 'some subject',
+ message_id: 'some@id',
+ body: "some message note\nnew line",
+ internal: false,
+ sender: Ticket::Article::Sender.find_by(name: 'Agent'),
+ type: Ticket::Article::Type.find_by(name: 'note'),
+ updated_by_id: 1,
+ created_by_id: 1,
+ )
assert_equal('some title äöüß', ticket1.title, 'ticket1.title verify')
assert_equal('Users', ticket1.group.name, 'ticket1.group verify')
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
- assert_equal(0, ticket1.articles.count, 'ticket1.articles verify')
+ assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
Observer::Transaction.commit
@@ -75,13 +88,14 @@ class TicketTriggerTest < ActiveSupport::TestCase
assert_equal('Users', ticket1.group.name, 'ticket1.group verify')
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
assert_equal('3 high', ticket1.priority.name, 'ticket1.priority verify')
- assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
+ assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
assert_equal(%w(aa kk), Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
article1 = ticket1.articles.last
assert_match('Zammad ', article1.from)
assert_match('nicole.braun@zammad.org', article1.to)
assert_match('Thanks for your inquiry (some title äöüß)!', article1.subject)
assert_match('Braun
some <b>title</b>', article1.body)
+ assert_match('> some message <b>note</b>
> new line', article1.body)
assert_equal('text/html', article1.content_type)
ticket1.priority = Ticket::Priority.lookup(name: '2 normal')
@@ -93,7 +107,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
assert_equal('Users', ticket1.group.name, 'ticket1.group verify')
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
- assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
+ assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
assert_equal(%w(aa kk), Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
ticket1.state = Ticket::State.lookup(name: 'open')
@@ -105,7 +119,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
assert_equal('Users', ticket1.group.name, 'ticket1.group verify')
assert_equal('open', ticket1.state.name, 'ticket1.state verify')
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
- assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
+ assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
assert_equal(%w(aa kk), Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
ticket1.state = Ticket::State.lookup(name: 'new')
@@ -118,7 +132,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
assert_equal('Users', ticket1.group.name, 'ticket1.group verify')
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
assert_equal('3 high', ticket1.priority.name, 'ticket1.priority verify')
- assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
+ assert_equal(3, ticket1.articles.count, 'ticket1.articles verify')
assert_equal(%w(aa kk), Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
article1 = ticket1.articles.last
assert_match('Zammad ', article1.from)
@@ -155,6 +169,56 @@ class TicketTriggerTest < ActiveSupport::TestCase
assert_equal(0, ticket2.articles.count, 'ticket2.articles verify')
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket2.id))
+ ticket3 = Ticket.create(
+ title: "some title\n äöüß3",
+ group: Group.lookup(name: 'Users'),
+ customer: User.lookup(email: 'nicole.braun@zammad.org'),
+ state: Ticket::State.lookup(name: 'new'),
+ priority: Ticket::Priority.lookup(name: '2 normal'),
+ updated_by_id: 1,
+ created_by_id: 1,
+ )
+ assert(ticket3, 'ticket3 created')
+ Ticket::Article.create(
+ ticket_id: ticket3.id,
+ from: 'some_sender@example.com',
+ to: 'some_recipient@example.com',
+ subject: 'some subject',
+ message_id: 'some@id',
+ content_type: 'text/html',
+ body: 'some message note
new line',
+ internal: false,
+ sender: Ticket::Article::Sender.find_by(name: 'Agent'),
+ type: Ticket::Article::Type.find_by(name: 'note'),
+ updated_by_id: 1,
+ created_by_id: 1,
+ )
+
+ assert_equal('some title äöüß3', ticket3.title, 'ticket3.title verify')
+ assert_equal('Users', ticket3.group.name, 'ticket3.group verify')
+ assert_equal('new', ticket3.state.name, 'ticket3.state verify')
+ assert_equal('2 normal', ticket3.priority.name, 'ticket3.priority verify')
+ assert_equal(1, ticket3.articles.count, 'ticket3.articles verify')
+ assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket3.id))
+
+ Observer::Transaction.commit
+
+ ticket3 = Ticket.lookup(id: ticket3.id)
+ assert_equal('some title äöüß3', ticket3.title, 'ticket3.title verify')
+ assert_equal('Users', ticket3.group.name, 'ticket3.group verify')
+ assert_equal('new', ticket3.state.name, 'ticket3.state verify')
+ assert_equal('3 high', ticket3.priority.name, 'ticket3.priority verify')
+ assert_equal(2, ticket3.articles.count, 'ticket3.articles verify')
+ assert_equal(%w(aa kk), Tag.tag_list(object: 'Ticket', o_id: ticket3.id))
+ article3 = ticket3.articles.last
+ assert_match('Zammad ', article3.from)
+ assert_match('nicole.braun@zammad.org', article3.to)
+ assert_match('Thanks for your inquiry (some title äöüß3)!', article3.subject)
+ assert_match('Braun
some <b>title</b>', article3.body)
+ assert_match('> some message note
> new line', article3.body)
+ assert_no_match('> some message <b>note</b>
> new line', article3.body)
+ assert_equal('text/html', article3.content_type)
+
Trigger.destroy_all
end