anteo / redmine_custom_workflows

Allows to create custom workflows for Redmine
http://www.redmine.org/plugins/custom-workflows
GNU General Public License v2.0
178 stars 72 forks source link

Send mail to the author when an issue is created #330

Closed Hernan22 closed 7 months ago

Hernan22 commented 7 months ago

Hello, thank you all for the work done on the plugin.

I am trying to implement a ticket system in redmine, whereby the customer can create a ticket via email. I want the customer to receive a notification email when the issue is created. Redmine allows this if the option "I don't want to be notified of changes that I make myself" is unchecked, but this generates the inconvenience that all client actions, like notes, will be notified. With the plugin I can send an email notification only when the ticket is created, which is perfect, but I have problems customizing the email. I would like it to be the same as the notification that Redmine sends if the option is unchecked, is it possible to do this? I tried to use templates but was unsuccessful.

This is my code:

before_save if new_record? @var = 1 end

after_save if @var > 0 CustomWorkflowMailer.deliver_custom_email(@issue.author, "[Ticket creado en #{@issue.project} ##{@issue.id}]", "#{@issue.description}") end

picman commented 7 months ago

I've restored the original functionality of the ability to use email templates. You can send such an email as follows:

Before script:

@var = new_record?

After script:

if @var && id
    sbj = "[#{project.name} - #{tracker.name} ##{id}]"
    sbj += " (#{status.name})" if Setting.show_status_changes_in_mail_subject?
    sbj += " #{subject}"
  CustomWorkflowMailer.deliver_custom_email(
    User.current,
    subject: sbj,
    template_name: 'mailer/issue_add',
    template_params: { 
      issue: self,
      issue_url: Rails.application.routes.url_helpers.url_for(controller: 'issues', action: 'show', id: id, host: 'localhost:3000')
    })
end

Could you test the functionality in the devel branch?

Hernan22 commented 7 months ago

It works, thank you!

picman commented 7 months ago

Great!