Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

add documentation

ulfertsfe049f45fd2b
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
index 8ad016da36a..76320a4b69f 100644
--- a/app/mailers/application_mailer.rb
+++ b/app/mailers/application_mailer.rb
@@ -80,10 +80,23 @@ class ApplicationMailer < ActionMailer::Base
super(headers, &block)
end
+ # Sets a Message-ID header.
+ #
+ # While the value is set in here, email gateways such as postmark, unless instructed explicitly will assign
+ # their own message id overwriting the value calculated in here.
+ #
+ # Because of this, the message id and the value affected by it (In-Reply-To) is not relied upon when an email response
+ # is handled by OpenProject.
def message_id(object, user)
headers['Message-ID'] = "<#{message_id_value(object, user)}>"
end
+ # Sets a References header.
+ #
+ # The value is used within the MailHandler to find the appropriate objects for update
+ # when a mail has been received but should also allow mail clients to mails
+ # by the referenced entities. Because of this it might make sense to provide more than one object
+ # of reference. E.g. for a message, the message parent can also be provided.
def references(*objects)
refs = objects.map do |object|
if object.is_a?(Journal)
@@ -148,9 +161,6 @@ class ApplicationMailer < ActionMailer::Base
# Note that this values, as opposed to the one from #message_id_value is not unique.
# It in fact is aimed not not so that similar messages (i.e. those belonging to the same
# work package and journal) end up being grouped together.
- #
- # The value is used within the MailHandler to find the appropriate objects for update
- # when a mail has been received.
def references_value(object)
hash = 'op'\
'.'\
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index 25aad008bca..8e618bab3c9 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -136,6 +136,22 @@ class MailHandler < ActionMailer::Base
private
+ # Dispatches the mail to the most appropriate method:
+ # * If there is no References header the email is interpreted as a new work package
+ # * If there is a References header the email is interpreted to update an existing entity (e.g. a work package
+ # or a message)
+ #
+ # OpenProject includes the necessary references in the References header of outgoing mail (see ApplicationMailer).
+ # This stretches the standard in that the values do not reference existing mails but it has the advantage of being able
+ # identify the object the response is destined for without human interference. Email clients will not remove
+ # entries from the References header but only add to it.
+ #
+ # OpenProject also sets the Message-ID header but gateways such as postmark, unless explicitly instructed otherwise,
+ # will use their own Message-ID and overwrite the provided one. As an email client includes the value thereof
+ # in the In-Reply-To and in the References header the Message-ID could also have been used.
+ #
+ # Relying on the subject of the mail, which had been implemented before, is brittle as it relies on the user not altering
+ # the subject. Additionally, the subject structure might change, e.g. via localization changes.
def dispatch
if (m, object_id = dispatch_target_from_header)
m.call(object_id)