Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

[NEW] direct reply by subject

Open ruKurz opened this issue 6 years ago • 2 comments

This PR is motivated by adding an alternate method in order to direct reply to offline messages via email using the email subject instead of the email to.

Current situation The Rocket.Chat message (ID) to reply to is currently referenced using email subaddressing (RFC 5233). Unfortunately there are a lot of email service providers out there not supporting subaddressing (e.g. Microsoft O365). Therefore it might be a good idea to use the subject email header in order to pass the message id.

Changes This PR makes it configureable to choose whether to use subaddressing or the email subject within your email reply in order to reference the Rocket.Chat message: direct-reply-method

How it works If the Subject option is selected the subject of a reply email will be appended by reply:<17-char-messageID> (see app/lib/server/functions/notifications/email.js for details):

if (settings.get('Direct_Reply_Method') && settings.get('Direct_Reply_Method') === 'subject') {
	emailSubject = `${ emailSubject } reply:${ message._id }`;
}

The email interceptor now tries to find a RC messageId either in the e-mail subject or the e-mail to (see /app/lib/server/lib/processDirectEmail.js for details):

const ind = email.headers.subject.indexOf('reply:');
if (ind > 0) {
	// message id to reply to is encoded by email 'subject'
	email.headers.mid = email.headers.subject.substring(ind + 6, ind + 23);
} else if (email.headers.to.indexOf('+') >= 0) {
	// message id to reply to is encoded by email 'to'
	// Valid 'To' format
	email.headers.mid = email.headers.to.split('@')[0].split('+')[1];
}

ruKurz avatar May 30 '19 18:05 ruKurz

@Hudell would be great to see this reviewed! Thanks in advance.

ruKurz avatar May 30 '19 18:05 ruKurz

Could we get this feature in the master branch, please? Exchange servers do not have the possibility to do subadressing with a delimiter. They would need that option to subadress by subject ID infusion.

rasos avatar Nov 25 '20 14:11 rasos