Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExtractSubjectTag Action: prepend, not append, remote system's subject tag #324

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from

Conversation

Al2Klimov
Copy link

Too long (200+) ticket subjects (produced by this action) are shortened automatically.
This could cut off the remote system's subject tag if at the end.

…t tag

Too long (200+) ticket subjects (produced by this action) are shortened automatically.
This could cut off the remote system's subject tag if at the end.
@Al2Klimov
Copy link
Author

How to reproduce

  1. Setup two RTs, say, Tom and Jerry
  2. In Tom create a ticket with a loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong subject, add Jerry as requestor and reply something
  3. In Jerry reply to the ticket
  4. In Tom reply to the ticket -> opens separate ticket at Jerry

@Al2Klimov
Copy link
Author

Why exactly this happens

To understand the following we need to remember that there are ticket subjects and eMail subjects.

  1. In Tom the newly created ticket has the ID 1 and the ticket subject looooooo... (cut off).
  2. On "reply" (it's not actually a reply, but the very first message of the whole conversation) Tom sends an eMail to Jerry with the eMail subject [%s #%d] %s, i.e. [tom #1] looooooo... (cut off).
  3. That eMail creates a new ticket in Jerry with ID 1 and the eMail subject from above as ticket subject.
  4. On (actual) reply Jerry sends an eMail to Tom with the eMail subject [%s #%d] %s, i.e. [jerry #1] [tom #1] looooooo... (cut off).
  5. Tom recognises [tom #1] in the eMail subject and associates the eMail with the existing ticket.
  6. Tom also recognises the foreign tag [jerry #1] and the code I changed in this PR tries(!) to change the ticket subject to loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong [jerry #1] (so that on next reply from Tom gets into the right ticket at Jerry). It tries! But, as master Yoda said: Do or do not. There's no try. Effectively Tom doesn’t change the ticket subject as above as [jerry #1] gets cut off silently due to the database column length.
  7. As the ticket subject stays as-is the next reply from Tom misses [jerry #1].
  8. Therefore Jerry can’t associate it with the already existing ticket and creates a new one.

@Al2Klimov
Copy link
Author

How to workaround

At least in the Tom RT, preferably in both ones:

  1. Navigate to Admin/Scrips/Select
  2. Open On transaction, add any tags in the transaction's subject to the ticket's subject
  3. Set Action to User Defined
  4. Set Custom action preparation code to 1;
  5. Copy the code given below to Custom action commit code
  6. Apply this PR as patch
  7. Save Changes

my $Transaction = $self->TransactionObj;
my $FirstAttachment = $Transaction->Attachments->First;
return 1 unless $FirstAttachment;
my $TransactionSubject = $FirstAttachment->Subject;
return 1 unless $TransactionSubject;
my $Ticket = $self->TicketObj;
my $TicketSubject = $self->TicketObj->Subject;
my $origTicketSubject = $TicketSubject;
my $match = RT->Config->Get('ExtractSubjectTagMatch');
my $nomatch = RT->Config->Get('ExtractSubjectTagNoMatch');
TAGLIST: while ( $TransactionSubject =~ /($match)/g ) {
my $tag = $1;
next if $tag =~ /$nomatch/;
foreach my $subject_tag ( RT->System->SubjectTag ) {
if ($tag =~ m{\[(?:https?://)?\Q$subject_tag\E\s+#(\d+)\s*\]}) {
next TAGLIST;
}
}
$TicketSubject .= " $tag" unless ( $TicketSubject =~ /\Q$tag\E/ );
}
$self->TicketObj->SetSubject($TicketSubject)
if ( $TicketSubject ne $origTicketSubject );
return (1);

CC @lippserd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant