From 7afb631c9c4893a554f1ecd395f1ffbae3413cb8 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Mon, 27 Oct 2014 11:34:55 +0800 Subject: Bug 1075281: bugmail filtering not working the way I expect it to --- extensions/BugmailFilter/Extension.pm | 16 ++++++++++++++++ extensions/BugmailFilter/lib/Filter.pm | 7 ++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/extensions/BugmailFilter/Extension.pm b/extensions/BugmailFilter/Extension.pm index ebfc1f851..4d4a1938f 100644 --- a/extensions/BugmailFilter/Extension.pm +++ b/extensions/BugmailFilter/Extension.pm @@ -235,6 +235,10 @@ sub user_wants_mail { filter_field => $_->{field_name}, # filter's field_name field_name => $_->{field_name}, # raw bugzilla field_name } } + grep { + # flags are added later + $_->{field_name} ne 'flagtypes.name' + } @$diffs ]; @@ -248,6 +252,18 @@ sub user_wants_mail { } } + # insert fake fields for flags + foreach my $diff (@$diffs) { + next unless $diff->{field_name} eq 'flagtypes.name'; + foreach my $change (split(/, /, join(', ', ($diff->{old}, $diff->{new})))) { + next unless $change =~ /^(.+)[\?\-+]/; + push @$fields, { + filter_field => $1, + field_name => 'flagtypes.name', + }; + } + } + # set filter_field on tracking flags to tracking.$type require Bugzilla::Extension::TrackingFlags::Flag; my @tracking_flags = Bugzilla->tracking_flags; diff --git a/extensions/BugmailFilter/lib/Filter.pm b/extensions/BugmailFilter/lib/Filter.pm index 6246f51d9..d59e19fb7 100644 --- a/extensions/BugmailFilter/lib/Filter.pm +++ b/extensions/BugmailFilter/lib/Filter.pm @@ -181,7 +181,12 @@ sub matches { if (my $field_name = $self->{field_name}) { if ($args->{field}->{field_name} && substr($field_name, 0, 1) eq '~') { my $substring = quotemeta(substr($field_name, 1)); - if ($args->{field}->{field_name} !~ /$substring/i) { + if ($args->{field}->{filter_field} !~ /$substring/i) { + return 0; + } + } + elsif ($field_name eq 'flagtypes.name') { + if ($args->{field}->{field_name} ne $field_name) { return 0; } } -- cgit v1.2.3-24-g4f1b