Project

General

Profile

Actions

Feature #23011

closed

Purpose of MESSAGE_ID_RE in mail_handler.rb

Added by Alexander Herr almost 8 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:

Description

In `dispatch` of `app/models/mail_handler.rb` a global named `MESSAGE_ID_RE` is used, which is defined as the regular expression:

MESSAGE_ID_RE = %r{^<?redmine\.([a-z0-9_]+)\-(\d+)\.\d+(\.[a-f0-9]+)?@}

The conditional in `dispatch` does the following:

if headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
      klass, object_id = $1, $2.to_i
      method_name = "receive_#{klass}_reply" 
      if self.class.private_instance_methods.collect(&:to_s).include?(method_name)
        send method_name, object_id
      else
        # ignoring it
      end
end

The purpose of this global (and its conditional in `dispatch`) isn't quite clear to me, as it is also lacking comments. I suspect that it looks for redmine's own e-mail-address and then calls a supplied method?

Why should redmine talk to itself through e-mails in such a way? What if I change redmine's e-mail-address to something not containing redmine? What will break (if anything)?

We recently changed the naming of our redmine instance (both the domain-name and the e-mail-address now do not contain redmine) to something more obvious for non-tech folk. We would hate to have broken something by that change.

Actions #1

Updated by Jean-Philippe Lang almost 8 years ago

  • Status changed from New to Closed
Redmine doesn't talk to itself by email. This regexp is used to parse the In-Reply-To and References headers when a user replies to a Redmine notification in order to know to which object (issue or message) the user is replying:
  1. Redmine sends a notification (eg. issue X is created)
  2. A user replies to this notification
  3. Redmine detects that this is a reply to issue X and appends the message as a note to issue X

It doesn't match the host part of the message id, so changing your hostname should not have any effects on this.

Actions #2

Updated by Toshi MARUYAMA almost 8 years ago

  • Description updated (diff)
Actions #3

Updated by Alexander Herr almost 8 years ago

And what if not only the domain does not contain redmine but the e-mail-name as well? I.e. instead of its . Does that break the above?

Actions #4

Updated by Jean-Philippe Lang almost 8 years ago

Alexander Herr wrote:

And what if not only the domain does not contain redmine but the e-mail-name as well? I.e. instead of its . Does that break the above?

No

Actions #5

Updated by Jean-Philippe Lang almost 8 years ago

This regexp is not for parsing email addresses but message ids which are always generated by Redmine in this way: <redmine-xxx@xxx>, whatever your host name or email address is (see Mailer#message_id_for and Mailer#token_for).

Actions

Also available in: Atom PDF