5
5
namespace App \Factory \ActivityPub ;
6
6
7
7
use App \Entity \Magazine ;
8
+ use App \Markdown \MarkdownConverter ;
9
+ use App \Markdown \RenderTarget ;
8
10
use App \Service \ActivityPub \ContextsProvider ;
9
11
use App \Service \ImageManager ;
10
12
use Symfony \Component \Routing \Generator \UrlGeneratorInterface ;
@@ -13,13 +15,25 @@ class GroupFactory
13
15
{
14
16
public function __construct (
15
17
private readonly UrlGeneratorInterface $ urlGenerator ,
18
+ private readonly MarkdownConverter $ markdownConverter ,
16
19
private readonly ContextsProvider $ contextProvider ,
17
20
private readonly ImageManager $ imageManager
18
21
) {
19
22
}
20
23
21
24
public function create (Magazine $ magazine ): array
22
25
{
26
+ $ markdownSummary = $ magazine ->description ;
27
+
28
+ if (!empty ($ magazine ->rules )) {
29
+ $ markdownSummary .= "\r\n\r\n### Rules \r\n\r\n" .$ magazine ->rules ;
30
+ }
31
+
32
+ $ summary = $ this ->markdownConverter ->convertToHtml (
33
+ $ markdownSummary ,
34
+ [MarkdownConverter::RENDER_TARGET => RenderTarget::ActivityPub],
35
+ );
36
+
23
37
$ group = [
24
38
'type ' => 'Group ' ,
25
39
'@context ' => $ this ->contextProvider ->referencedContexts (),
@@ -47,7 +61,11 @@ public function create(Magazine $magazine): array
47
61
'id ' => $ this ->getActivityPubId ($ magazine ).'#main-key ' ,
48
62
'publicKeyPem ' => $ magazine ->publicKey ,
49
63
],
50
- 'summary ' => $ magazine ->description ,
64
+ 'summary ' => $ summary ,
65
+ 'source ' => $ markdownSummary ? [
66
+ 'content ' => $ markdownSummary ,
67
+ 'mediaType ' => 'text/markdown ' ,
68
+ ] : null ,
51
69
'sensitive ' => $ magazine ->isAdult ,
52
70
'attributedTo ' => $ this ->urlGenerator ->generate (
53
71
'ap_magazine_moderators ' ,
0 commit comments