プロジェクト

全般

プロフィール

Vote #66183

完了

Remove email body via a delimiter

Admin Redmine さんがほぼ2年前に追加. ほぼ2年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Email receiving_29
対象バージョン:
開始日:
2009/12/16
期日:
進捗率:

0%

予定工数:
category_id:
29
version_id:
6
issue_org_id:
4409
author_id:
5
assigned_to_id:
5
comments:
17
status_id:
5
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

My clients and I use the email receiving features of Redmine all the time but it's a pain if someone forgets to remove the replies or has a long signature line. This patch adds a setting to allow Administrators to configure delimiters for the incoming email body. When the email is read, the body content that is after these delimiters are removed.

For example, with the delimiter of "cut" the following email would only have "Here is the email body for issue 4." as the issue/journal body.

Here is the email body for issue 4.

CUT

Sent from my iPhone

Multiple delimiters can be added easily by separating them with a line in the settings.

I can commit this patch for 0.9 if there are no problems. I just wanted to get some feedback first.


journals

Its amazing how this little feature makes such a difference when trying to read an issue history. The ability to manage the filter via the admin is nice as many system parse emails different (like mac mail killing ---). +1.
--------------------------------------------------------------------------------
A definite +1 from me also, my devs had requested this exact same feature ;)
--------------------------------------------------------------------------------
This looks interesting for my purposes as well. I would like to test it but how should this patch be applied?
--------------------------------------------------------------------------------
A few comments:
* this should be applied to forum replies as well
* the setting name is a bit vague, I think that @mail_handler_body_delimiters@ would be better

<pre>
regex = Regexp.new(token + '.*', Regexp::IGNORECASE | Regexp::MULTILINE)
</pre>

* entering an invalid regexp in this setting will raise an error, this should be rescued
* this will remove content after a line that *starts* with the delimiter. IMHO, it's not a desirable behaviour. Since we accept a regexp, why not let the user append .* if he really wants this?
* we should add an additional setting to turn on/off regexp matching (something like @mail_handler_body_delimiters_regexp@ set to off by default).
--------------------------------------------------------------------------------
Jean-Philippe Lang wrote:
> A few comments:
> * this should be applied to forum replies as well

Agreed.

> * the setting name is a bit vague, I think that @mail_handler_body_delimiters@ would be better

Thanks, I had trouble coming up with a good description for it so @mail_handler_body_delimiters@ would be good.

> * entering an invalid regexp in this setting will raise an error, this should be rescued

Good catch, I can write a test for that case.

> * this will remove content after a line that *starts* with the delimiter. IMHO, it's not a desirable behaviour. Since we accept a regexp, why not let the user append .* if he really wants this?

I think this is the standard behavior. Most other systems with a similar feature have a section saying "all content after HERE will be removed". I can remove the .* and add a note on the user interface to let the admin know they will need to add .* if they want to remove all content after the regex.

> * we should add an additional setting to turn on/off regexp matching (something like @mail_handler_body_delimiters_regexp@ set to off by default).

So would this setting enable/disable the body removal? So if it's disabled, the body is added as is. If it's enabled, the body is stripped according to the regular expressions in @mail_handler_body_delimiters@.
--------------------------------------------------------------------------------
Eric Davis wrote:
> Jean-Philippe Lang wrote:
> > * this will remove content after a line that *starts* with the delimiter. IMHO, it's not a desirable behaviour. Since we accept a regexp, why not let the user append .* if he really wants this?
>
> I think this is the standard behavior. Most other systems with a similar feature have a section saying "all content after HERE will be removed". I can remove the .* and add a note on the user interface to let the admin know they will need to add .* if they want to remove all content after the regex.

According to the "signature block":http://en.wikipedia.org/wiki/Signature_block article on Wikipedia, a signature begins with "@-- \n@", so I think the appended @.*@ should not be the default.
--------------------------------------------------------------------------------
> I think this is the standard behavior. Most other systems with a similar feature have a section saying "all content after HERE will be removed". I can remove the .* and add a note on the user interface to let the admin know they will need to add .* if they want to remove all content after the regex.

I didn't try your patch but it looks like if you set the delimiter to '--' for example, it will strip any text after '--' anywhere if the email body.

The following email:

<pre>
This is my body ------ and this should not be stripped.

--
JP
</pre>

would become:
<pre>
This is my body
</pre>

And I think the regexp is definitly not needed. The setting should be regexp escaped.
--------------------------------------------------------------------------------
Felix Schäfer wrote:
> According to the "signature block":http://en.wikipedia.org/wiki/Signature_block article on Wikipedia, a signature begins with "@--
@", so I think the appended @.*@ should not be the default.

Without @.*@ it will convert the following email like so, which isn't useful at all:

<pre>
This is my body content

--
JPL
Maintainer of Redmine.org
Ruby on Rails developer
user@example.com
</pre>

to:

<pre>
This is my body content

JPL
Maintainer of Redmine.org
Ruby on Rails developer
user@example.com
</pre>

Jean-Philippe Lang wrote:
> I didn't try your patch but it looks like if you set the delimiter to '--' for example, it will strip any text after '--' anywhere if the email body.

Correct, the administrator would have to be careful with what delimiters are used. I have two sites in production using @---@ already and has only stripped to much content once out of a few thousand emails.

> And I think the regexp is definitly not needed. The setting should be regexp escaped.

I'm not following, how would you match the content then?
--------------------------------------------------------------------------------
Eric Davis wrote:
> Felix Schäfer wrote:
> > According to the "signature block":http://en.wikipedia.org/wiki/Signature_block article on Wikipedia, a signature begins with "@--
> @", so I think the appended @.*@ should not be the default.
>
> Without @.*@ it will convert the following email like so, which isn't useful at all:

Yeah, sorry, I was more thinking in terms of lines… What I meant was that it should only cut content starting with a line containing _only_ given string or regex.
--------------------------------------------------------------------------------
How about the token having to be on a line by istelf. I don't know in Ruby but in Perl it becomes:

<pre>
$token="--";
$_ = "This is my body\n--\nthis si crap";

s/^$token\n.*//m;

print;
</pre>

I'd not make the regexp ignoring case. I.e. @"END\n"@ must be matched, but not @"End\n"@,
.* will remove the rest anyway.
--------------------------------------------------------------------------------
Little change because '.' doesn't match newlines by default in Perl, and bodies like the following one would not be processed correctly

<pre>
$token="--";
$_ = "This is my body\n--\nthis si crap\nthis line too";

s/^$token.*//ms;

#this would work too:
#s/^$token(.|\s)*//m;

print;
</pre>

Sorry for talking Perl in a Ruby project, but there should be an equivalence...
Eric
--------------------------------------------------------------------------------
Sorry to pollute this issue :-/ I omitted to put @'\n'@ back into my last regexps.
It should indeed be @s/^$token\n.*//ms;@ or @s/^$token\n(.|\s)*//m;@
well you get the idea...
--------------------------------------------------------------------------------
Feature added in r3226.
Delimiters are strings (not regexp) and must match the entire line.
--------------------------------------------------------------------------------
Works a charm, thanks a lot :-)
--------------------------------------------------------------------------------
Guys, I'm sure I'm being thick here, but could you please give me an example on how to use this great feature?
I've tried updating an issue from Gmail. The reply is something like:

On Thu, Sep 2, 2010 at 12:22 PM, <redmine@romulus.thepieguide.com> wrote:

Issue #3195 has been updated by Dinis Quelhas.

trying to truncate with gmail
Feature #3195: T1 Test Issue

.....

If I go to Settings->Incoming Emails->Truncate emails after one of these lines and add "On Thu, Sep 2, 2010 at 12:22 PM, <redmine@romulus.thepieguide.com> wrote:" it works just fine but if I add something like "Issue #3195 has been updated by Dinis Quelhas" it doesn't work.

I would like to have something a bit more generic for all of them like:

"Feature #*:" to apply to all incoming emails. Is this possible?

Thanks in advance for your help :-)
--------------------------------------------------------------------------------
most of mail clients would append somethink like "john wrote" or "on xx/xx/xx ..." etc... is there any way to add some kind of reg expression ? in case of that regular expression is not valid, just ignore the expression !

in my case I would cut the body as soon as I find "redmine@myserver.com"... but it is never a whole line !
--------------------------------------------------------------------------------
Regexp based delimiters should be added.
Please revert the change soon.
--------------------------------------------------------------------------------


related_issues

duplicates,Closed,3199,Ability to remove mail signature when updating an issue from mail

Admin Redmine さんがほぼ2年前に更新

  • カテゴリEmail receiving_29 にセット
  • 対象バージョン0.9.0_6 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0