Project

General

Profile

Reopen issue by mail - plugin for 4.0.6?

Added by Michael K. over 4 years ago

Hello,
We are using Redmine 4.0.6 (installed few days ago on Kubuntu)

I've created special email address for issue reporting, everything works fine.

The problem is, when I close issue and someone replies to email notification about issue closing, the issue stays closed.

I know there is option of allow_override=status (in cronjob) and ppl can write Status: New at the beginning of the mail to reopen the issue, but a lot of non tech-savvy users don't remember to do that

There's plugin here:
https://github.com/openSUSE-Team/redmine-reopen-issues-by-mail

But it's not working with Redmine 4.0.6 and new Rails

I made some modification to it (ie. Change alias_method_chain to alias_method) also 2 other lines (ie. One with IssueStatus.default.id - I change it to 1 (number one))

So the output of the changes was:
1. No more errors in production.log
2. Update/Comment has information that "Michael changed status from Closed to New" but whole issue status is still Closed (status at the top of the page and on issues list)

Can someone please help me to make this plugin work in 4.0.6?


Replies (2)

RE: Reopen issue by mail - plugin for 4.0.6? - Added by Michael K. over 4 years ago

For anyone interested I fixed the plugin, here's proper code:

module ReopenIssuesByMail
  module MailHandlerPatch
    def self.included(base)
      base.send(:include, InstanceMethods)
      base.class_eval do
        # alias_method_chain :receive_issue_reply, :reopen_issues_by_mail
        alias_method :receive_issue_reply_without_reopen_issues_by_mail, :receive_issue_reply
        alias_method :receive_issue_reply, :receive_issue_reply_with_reopen_issues_by_mail
      end
    end

    module InstanceMethods
      # Adds a note to an existing issue
      def receive_issue_reply_with_reopen_issues_by_mail(issue_id, from_journal=nil)
        journal = receive_issue_reply_without_reopen_issues_by_mail(issue_id, from_journal)
        issue = Issue.find_by_id(issue_id)
        return unless issue
        if issue.closed?
          # status_id = IssueStatus.default.id
          status_id = 1 #check and put here ID of the status you want to set (you can check it easly in Administration panel in redmine, by hovering over status name in settings - look for ID in link to the status)
          JournalDetail.create(:journal => journal, :property => "attr",
                               :prop_key => "status_id", :value => status_id,
                               :old_value => issue.status_id)
          # Issue.update_all({:status_id => status_id}, {:id => issue.id})
          Issue.where(:id => issue_id).update_all(:status_id => status_id) # for issue_id change status_id
          logger.info "MailHandler: reopening issue ##{issue.id}" if logger
        end
        journal.reload
      end
    end
  end
end

RE: Reopen issue by mail - plugin for 4.0.6? - Added by Georg P over 1 year ago

Hi,

I found your post upon searching the internet for some errors the plugin produced under Redmine 5 and submitted these changes as https://github.com/openSUSE-Team/redmine-reopen-issues-by-mail/pull/3.

    (1-2/2)