Skip to content

Commit

Permalink
Get gitlab api for original commenter if resolver isnot synced (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankdekker authored Jan 3, 2024
1 parent 2ff9d4d commit 4954170
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/MessageHandler/Gitlab/CommentResolvedMessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ public function __invoke(CommentResolved|CommentUnresolved $event): void
return;
}

$comment = Assert::notNull($this->commentRepository->find($event->getCommentId()));
$user = Assert::notNull($this->userRepository->find($event->getUserId()));
$api = $this->apiProvider->create($comment->getReview()->getRepository(), $user);
$comment = Assert::notNull($this->commentRepository->find($event->getCommentId()));
$repository = $comment->getReview()->getRepository();
$user = Assert::notNull($this->userRepository->find($event->getUserId()));
$api = $this->apiProvider->create($repository, $user) ?? $this->apiProvider->create($repository, $comment->getUser());
if ($api === null) {
$this->logger?->info('No api configuration found for comment {id}', ['id' => $event->getCommentId()]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ public function testInvokeNoApi(): void
$review->setRepository($repository);

$comment = new Comment();
$comment->setUser($user);
$comment->setReview($review);

$this->commentRepository->expects(self::once())->method('find')->with(222)->willReturn($comment);
$this->userRepository->expects(self::once())->method('find')->with(333)->willReturn($user);
$this->apiProvider->expects(self::once())->method('create')->with($repository, $user)->willReturn(null);
$this->apiProvider->expects(self::exactly(2))->method('create')->with($repository, $user)->willReturn(null);

($this->handler)(new CommentResolved(111, 222, 333, 'file'));
}
Expand Down

0 comments on commit 4954170

Please sign in to comment.