W
W
WordPress WooCommerce2017-04-18 17:20:38
JavaScript
WordPress WooCommerce, 2017-04-18 17:20:38

How to get the issue id & id of the initiator through the ticket creation hook?

redmine has a hook controller_issues_new_after_save - which allows you to catch the issue creation event inside the project.
we write a plugin, we hang ourselves on this hook:

class HelpDeskHooksListener < Redmine::Hook::ViewListener

  def controller_issues_new_after_save(context={})

    Rails.logger.debug "================================my======================================="
    Rails.logger.info context[:issue]
    # Rails.logger.info JSON.pretty_generate(context[:issue])

    if context[:params][:project_id] == 'test'

      @text = Time.now.strftime("%Y-%d-%m %H:%M:%S %Z")
      @subject = context[:params][:issue][:subject]
      @description = context[:params][:issue][:description]

      @body = @text + "\n" + @subject + "\n" + @description

      ActionMailer::Base.mail(from: "[email protected]", to: "[email protected]", subject: "test redmine", body: @body).deliver

    end

  end
  
end

I see almost all data except id issue. How can I get the issue id?
Next, by id issue, you need to somehow get the id of the initiator. If there is an understanding of how to do this - I would be grateful for a hint.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Gladyshev, 2017-04-19
@maxxannik

Just like you take params, via context the initiator is the author?
context[:issue].author_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question