jfqd / redmine_helpdesk

Lightweight helpdesk plugin for redmine.
MIT License
195 stars 101 forks source link

First response E-Mail not working on master (undefined method `value=' for nil:NilClass) #147

Closed MatthiasPetermann closed 2 years ago

MatthiasPetermann commented 4 years ago

Hello Stefan,

Since I discovered the redmine_helpdesk plugin, I have been able to (almost) completely release myself from email for general IT support and am much more organized. Thanks a lot for this!

At the turn of the year I switched my Redmine to version 4.1 (on Ruby 2.6) and also updated the redmine_helpdesk plugin to the latest version from master.

With this combination, sending the "first response" initially no longer worked. In the Redmine log there was the following note:

    MailHandler: issue #2853 created by Anonymous
    MailHandler: an unexpected error occurred when receiving email: undefined method `value=' for nil:NilClass

I was able to use this patch to bring the affected code to an older version that was still working:

   dev$ diff mail_handler_patch.rb.orig mail_handler_patch.rb
    33c33,37
    <           custom_value = custom_field_value(issue,'cc-handling')
    ---
    >           #custom_value = custom_field_value(issue,'cc-handling')
    >           custom_field = CustomField.find_by_name('cc-handling')
    >           custom_value = CustomValue.where(
    >               "customized_id = ? AND custom_field_id = ?", issue.project.id, custom_field.id).first
    > 
    36c40,43
    <             custom_value = custom_field_value(issue,'copy-to')
    ---
    >             #custom_value = custom_field_value(issue,'copy-to')
    > custom_field = CustomField.find_by_name('copy-to')           
    >           custom_value = CustomValue.where(
    >               "customized_id = ? AND custom_field_id = ?", issue.id, custom_field.id).first
    46c53,57
    <           custom_value = custom_field_value(issue,'owner-email')
    ---
    >           #custom_value = custom_field_value(issue,'owner-email')
    > custom_field = CustomField.find_by_name('owner-email')
    >           custom_value = CustomValue.where(
    >             "customized_id = ? AND custom_field_id = ?", issue.id, custom_field.id).
    >             first

However, this is probably a step backwards since you have certainly introduced the custom_field_value method for a good reason. If you have the opportunity to take a look at it, I'm happy to test it.

Best wishes Matthias

gainskills commented 4 years ago

From the error, it seemed it related to Redmine receive emails module. All fields have been mentioned in https://www.redmine.org/projects/redmine/wiki/RedmineReceivingEmails Hope this does some help.

MatthiasPetermann commented 4 years ago

Hello,

unfortunately I did not receive any notification of your reply and would like to apologize for the late reaction. Today I updated my Redmine and took the opportunity to check for new versions of my used plugins. I noticed your answer. Unfortunately I did not quite understand what to do. I call the mail handler as follows:

#!/bin/sh
export GEM_HOME=/usr/local/redmine/.gem
export PATH=$PATH:/usr/local/bin
cd /usr/local/redmine/current/
bundle26 exec rake -f /usr/local/redmine/current/Rakefile redmine:email:receive_imap RAILS_ENV="production" host=192.168.2.14 username=username password=password folder=INBOX move_on_success=INBOX/processed move_on_failure=INBOX/failed project=helpdesk tracker=Aufgabe allow_override=project,tracker,priority unknown_user=accept no_permission_check=1

As a test I have set allow_override to "all". This did not bring any change either. The good news is that my patch from back then still works. Maybe someone can have a look at it again?

Many thanks in advance Matthias

jfqd commented 3 years ago

Think I fixed that issue today with commit e3a1794e087dda200afd5194da142706db293226. Can you confirm?