Transmit shared attachments via ActivityPub

This commit is contained in:
Michael 2021-04-29 20:22:38 +00:00
parent b88c9f9d67
commit 7c80f513d5

View file

@ -1291,22 +1291,35 @@ class Transmitter
$attachments[] = $attachment; $attachments[] = $attachment;
} }
*/ */
foreach (Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT, Post\Media::TORRENT, Post\Media::UNKNOWN]) as $attachment) { $uriids = [$item['uri-id']];
$attachments[] = ['type' => 'Document', $shared = BBCode::fetchShareAttributes($item['body']);
'mediaType' => $attachment['mimetype'], if (!empty($shared['guid'])) {
'url' => $attachment['url'], $shared_item = Post::selectFirst(['uri-id'], ['guid' => $shared['guid']]);
'name' => $attachment['description']]; if (!empty($shared_item['uri-id'])) {
$uriids[] = $shared_item['uri-id'];
}
}
foreach ($uriids as $uriid) {
foreach (Post\Media::getByURIId($uriid, [Post\Media::DOCUMENT, Post\Media::TORRENT, Post\Media::UNKNOWN]) as $attachment) {
$attachments[] = ['type' => 'Document',
'mediaType' => $attachment['mimetype'],
'url' => $attachment['url'],
'name' => $attachment['description']];
}
} }
if ($type != 'Note') { if ($type != 'Note') {
return $attachments; return $attachments;
} }
foreach (Post\Media::getByURIId($item['uri-id'], [Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]) as $attachment) { foreach ($uriids as $uriid) {
$attachments[] = ['type' => 'Document', foreach (Post\Media::getByURIId($uriid, [Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]) as $attachment) {
'mediaType' => $attachment['mimetype'], $attachments[] = ['type' => 'Document',
'url' => $attachment['url'], 'mediaType' => $attachment['mimetype'],
'name' => $attachment['description']]; 'url' => $attachment['url'],
'name' => $attachment['description']];
}
} }
return $attachments; return $attachments;