• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

RikudouSage / lemmyverse.link / 14420750975

12 Apr 2025 03:01PM UTC coverage: 6.667% (-0.8%) from 7.5%
14420750975

push

github

RikudouSage
Add support for resolving any post following Lemmy convention

0 of 26 new or added lines in 3 files covered. (0.0%)

1 existing line in 1 file now uncovered.

12 of 180 relevant lines covered (6.67%)

0.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Service/ActivityPubResolver.php
1
<?php
2

3
namespace App\Service;
4

5
use App\Dto\ActivityPubItem;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
8
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
9
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
10
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
11
use Symfony\Contracts\HttpClient\HttpClientInterface;
12

13
final readonly class ActivityPubResolver
14
{
15
    public function __construct(
16
        private HttpClientInterface $httpClient,
17
    ) {
NEW
18
    }
×
19

20
    public function getItem(string $id): ?ActivityPubItem
21
    {
22
        try {
NEW
23
            $response = $this->httpClient->request(
×
NEW
24
                Request::METHOD_GET,
×
NEW
25
                $id,
×
NEW
26
                [
×
NEW
27
                    'headers' => [
×
NEW
28
                        'Accept' => 'application/activity+json',
×
NEW
29
                    ],
×
NEW
30
                ],
×
NEW
31
            );
×
32

NEW
33
            $content = $response->getContent();
×
NEW
34
            $json = json_decode($content, true, JSON_THROW_ON_ERROR);
×
35

NEW
36
            return new ActivityPubItem(
×
NEW
37
                id: $json['id'],
×
NEW
38
                name: $json['name'],
×
NEW
39
            );
×
NEW
40
        } catch (TransportExceptionInterface | ClientExceptionInterface | ServerExceptionInterface) {
×
NEW
41
            return null;
×
42
        }
43
    }
44
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc