File: CommandByMail.pm

package info (click to toggle)
librt-extension-commandbymail-perl 3.00-1.1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye
  • size: 316 kB
  • sloc: perl: 3,818; makefile: 3
file content (69 lines) | stat: -rw-r--r-- 1,776 bytes parent folder | download | duplicates (3)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package RT::Interface::Email::Action::CommandByMail;

use warnings;
use strict;

use Role::Basic 'with';
with 'RT::Interface::Email::Role';

=head1 NAME

RT::Interface::Email::Action::CommandByMail - Change metadata of ticket via email

=head1 DESCRIPTION

This action provides compatibility with the new mail plugin system introduced
in RT 4.4. It provides an alternate to the default comment and correspond
handlers provided by RT.

=cut

# To maintain compatibility with previous versions of CommandByMail,
# handle the standard comment and correspond actions. Follow the
# pattern from RT's default action handling for providing both.

sub HandleComment {
    CBMHandleEither( @_, Action => "Comment" );
}

sub HandleCorrespond {
    CBMHandleEither( @_, Action => "Correspond" );
}

=head2 CBMHandleEither

This method is the CommandByMail version of RT's _HandleEither.

=cut

sub CBMHandleEither {
    my %args = (
        Action      => undef,
        Message     => undef,
        Subject     => undef,
        Ticket      => undef,
        TicketId    => undef,
        Queue       => undef,
        @_,
    );

    my $return_ref = RT::Extension::CommandByMail::ProcessCommands(%args);

    if ( exists $return_ref->{'DeferToRT'} and $return_ref->{'DeferToRT'} ){
        # Let RT process like normal email.
        # Action and other params should already be set appropriately.
        return RT::Interface::Email::Action::Defaults::_HandleEither( %args );
    }

    if ( exists $return_ref->{'MailError'} and $return_ref->{'MailError'} ){
        MailError(
            Subject     => $return_ref->{'ErrorSubject'},
            Explanation => $return_ref->{'Explanation'},
            FAILURE     => $return_ref->{'Failure'},
        );
    }

    return;
}

1;