summaryrefslogtreecommitdiffstats
path: root/Extension.pm
blob: 1ebd30bdd85e9c342c224b917ec2ed1d715a1a33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.

package Bugzilla::Extension::Mageia;
use strict;
use base qw(Bugzilla::Extension);

use Bugzilla::User;
use Bugzilla::Extension::Mageia::Util;

use Email::Address;

our $VERSION = '0.02';

sub mailer_before_send {
    my ($self, $args) = @_;
    my $email = $args->{email};

    # Include the changer's name in the "From:" field.
    if (my $changer = $email->header('X-Bugzilla-Who')) {
        $changer = Bugzilla::User->new({ name => $changer });
        my $changer_name = $changer ? $changer->name : undef;
        my $address = Email::Address->new($changer_name, $email->header('From'));
        $email->header_set('From', $address->format);
    }
}

__PACKAGE__->NAME;