summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Condition/StatusChangeQuietResolve.pm
blob: 8426141826bf63009ad1bc1073d96785f386f3df (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package RT::Condition::StatusChangeQuietResolve;
use base 'RT::Condition';
use strict;
use warnings;

=head2 DESCRIPTION

This condition allows for muting of resolution notifications when
combined with the ticket status 'resolved_quiet'

If status has been updated as 'resolved_quiet', this condition
will block notification, and update ticket status to 'resolved'

If status has been updated as 'resolved', this condition
will block notification only if the previous ticket status
had been 'resolved_quiet'

=cut

sub IsApplicable {
  my $self = shift;
  my $txn = $self->TransactionObj;
  my ($type, $field) = ($txn->Type, $txn->Field);

  return 0
    unless $type eq 'Status'
    || ($type eq 'Set' && $field eq 'Status');

  return 0
    unless $txn->NewValue eq 'resolved'
    || $txn->NewValue eq 'resolved_quiet';

  my $ticket = $self->TicketObj;

  if ($txn->NewValue eq 'resolved_quiet') {
    $ticket->SetStatus('resolved');
    return 0;
  }
  elsif ($txn->NewValue eq 'resolved' && $txn->OldValue eq 'resolved_quiet') {
    return 0;
  }

  return 1;
}

RT::Base->_ImportOverlays();

1;