Model ticket link counterparts explicitly
This commit is contained in:
@@ -23,13 +23,15 @@ class DeleteProjectTicketLink
|
||||
404,
|
||||
);
|
||||
|
||||
$linkedTicket = $ticketLink->source_ticket_id === $ticket->id
|
||||
$isSourceTicket = $ticketLink->source_ticket_id === $ticket->id;
|
||||
$linkedTicket = $isSourceTicket
|
||||
? $ticketLink->targetTicket
|
||||
: $ticketLink->sourceTicket;
|
||||
|
||||
$label = $ticketLink->ticketLinkType->label;
|
||||
$label = $ticketLink->ticketLinkType->labelForSource($isSourceTicket);
|
||||
$counterpartLabel = $ticketLink->ticketLinkType->labelForSource(! $isSourceTicket);
|
||||
|
||||
DB::transaction(function () use ($label, $linkedTicket, $user, $ticket, $ticketLink): void {
|
||||
DB::transaction(function () use ($label, $counterpartLabel, $linkedTicket, $user, $ticket, $ticketLink): void {
|
||||
$ticketLink->delete();
|
||||
|
||||
$this->createTicketWorklogEntry->handle(
|
||||
@@ -47,10 +49,10 @@ class DeleteProjectTicketLink
|
||||
$linkedTicket,
|
||||
$user,
|
||||
TicketWorklogEntryType::LinkRemoved,
|
||||
"Removed {$label} link to {$ticket->ticket_key}.",
|
||||
"Removed {$counterpartLabel} link to {$ticket->ticket_key}.",
|
||||
[
|
||||
'linked_ticket_key' => $ticket->ticket_key,
|
||||
'ticket_link_type' => $label,
|
||||
'ticket_link_type' => $counterpartLabel,
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user