Skip to content

Commit 4b00bf2

Browse files
authored
improve logs and fix some warnings (#1936)
1 parent 0120164 commit 4b00bf2

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

src/Controller/Security/VerifyEmailController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ public function __invoke(Request $request, UserRepository $repository, UserManag
2121
return $this->redirectToRoute('app_register');
2222
}
2323

24-
$user = $repository->find($id);
24+
try {
25+
$user = $repository->find($id);
26+
} catch (\Exception) {
27+
return $this->redirectToRoute('app_register');
28+
}
2529

2630
if (null === $user) {
2731
return $this->redirectToRoute('app_register');

src/MessageHandler/ActivityPub/Inbox/CreateHandler.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ public function doWork(MessageInterface $message): void
9595
$this->cache->invalidateTags([$tag]);
9696
$this->logger->debug('cleared cached items with tag {t}', ['t' => $tag]);
9797
}
98+
} else {
99+
$this->logger->warning('received Create activity for unknown type {t} of object {o}; ignoring', [
100+
't' => $object['type'],
101+
'o' => $object['id'] ?? '<no id>',
102+
]);
98103
}
99104
} catch (UserBannedException) {
100105
$this->logger->info('[CreateHandler::doWork] Did not create the post, because the user is banned');

src/MessageHandler/DeleteUserHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public function doWork(MessageInterface $message): void
5454
if (!$user) {
5555
throw new UnrecoverableMessageHandlingException('User not found');
5656
} elseif ($user->isDeleted && null === $user->markedForDeletionAt) {
57-
throw new UnrecoverableMessageHandlingException('User already deleted');
57+
// user already deleted
58+
return;
5859
}
5960

6061
$isLocal = null === $user->apId;

src/Service/ActivityPub/ApHttpClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private function getActivityObjectImpl(string $url): ?string
123123
$content = $response->getContent(false);
124124
$this->logger->debug('[ApHttpClient::getActivityObjectImpl] URL: {url} - content: {content}', ['url' => $url, 'content' => $content]);
125125
} catch (\Exception $e) {
126-
$this->logRequestException($response, $url, 'ApHttpClient:getActivityObject', $e);
126+
$this->logRequestException($response ?? null, $url, 'ApHttpClient:getActivityObject', $e);
127127
}
128128

129129
return $content;
@@ -447,7 +447,7 @@ public function post(string $url, User|Magazine $actor, ?array $body = null, boo
447447
throw new InvalidApPostException('Post failed', $url, $statusCode, $body);
448448
}
449449
} catch (\Exception $e) {
450-
$this->logRequestException($response, $url, 'ApHttpClient:post', $e, $jsonBody);
450+
$this->logRequestException($response ?? null, $url, 'ApHttpClient:post', $e, $jsonBody);
451451
}
452452

453453
// build cache

src/Service/MentionManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function handleChain(ActivityPubActivityInterface $activity): array
6262
function ($val) {
6363
preg_match(RegPatterns::LOCAL_USER, $val, $l);
6464

65-
return preg_match(RegPatterns::AP_USER, $val) || $val === $l[0] ?? '';
65+
return preg_match(RegPatterns::AP_USER, $val) || $val === ($l[0] ?? '');
6666
}
6767
);
6868

0 commit comments

Comments
 (0)