Merge pull request #10461 from annando/ap-preview

Transmit preview link
This commit is contained in:
Hypolite Petovan 2021-07-04 09:07:56 -04:00 committed by GitHub
commit 4a1bcb13d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 19 deletions

View File

@ -126,6 +126,7 @@ class Processor
$data['url'] = $attachment['url'];
$data['mimetype'] = $attachment['mediaType'];
$data['height'] = $attachment['height'] ?? null;
$data['width'] = $attachment['width'] ?? null;
$data['size'] = $attachment['size'] ?? null;
$data['preview'] = $attachment['image'] ?? null;
$data['description'] = $attachment['name'] ?? null;

View File

@ -1112,14 +1112,6 @@ class Receiver
'image' => $pageImage,
];
break;
case 'as:Link':
$attachlist[] = [
'type' => str_replace('as:', '', JsonLD::fetchElement($attachment, '@type')),
'mediaType' => JsonLD::fetchElement($attachment, 'as:mediaType', '@value'),
'name' => JsonLD::fetchElement($attachment, 'as:name', '@value'),
'url' => JsonLD::fetchElement($attachment, 'as:href', '@id')
];
break;
case 'as:Image':
$mediaType = JsonLD::fetchElement($attachment, 'as:mediaType', '@value');
$imageFullUrl = JsonLD::fetchElement($attachment, 'as:url', '@id');
@ -1181,7 +1173,10 @@ class Receiver
'type' => str_replace('as:', '', JsonLD::fetchElement($attachment, '@type')),
'mediaType' => JsonLD::fetchElement($attachment, 'as:mediaType', '@value'),
'name' => JsonLD::fetchElement($attachment, 'as:name', '@value'),
'url' => JsonLD::fetchElement($attachment, 'as:url', '@id')
'url' => JsonLD::fetchElement($attachment, 'as:url', '@id'),
'height' => JsonLD::fetchElement($attachment, 'as:height', '@value'),
'width' => JsonLD::fetchElement($attachment, 'as:width', '@value'),
'image' => JsonLD::fetchElement($attachment, 'as:image', '@id')
];
}
}

View File

@ -1298,10 +1298,24 @@ class Transmitter
}
$urls[] = $attachment['url'];
$attachments[] = ['type' => 'Document',
$attach = ['type' => 'Document',
'mediaType' => $attachment['mimetype'],
'url' => $attachment['url'],
'name' => $attachment['description']];
if (!empty($attachment['height'])) {
$attach['height'] = $attachment['height'];
}
if (!empty($attachment['width'])) {
$attach['width'] = $attachment['width'];
}
if (!empty($attachment['preview'])) {
$attach['image'] = $attachment['preview'];
}
$attachments[] = $attach;
}
}
@ -1316,10 +1330,24 @@ class Transmitter
}
$urls[] = $attachment['url'];
$attachments[] = ['type' => 'Document',
$attach = ['type' => 'Document',
'mediaType' => $attachment['mimetype'],
'url' => $attachment['url'],
'name' => $attachment['description']];
if (!empty($attachment['height'])) {
$attach['height'] = $attachment['height'];
}
if (!empty($attachment['width'])) {
$attach['width'] = $attachment['width'];
}
if (!empty($attachment['preview'])) {
$attach['image'] = $attachment['preview'];
}
$attachments[] = $attach;
}
// Currently deactivated, since it creates side effects on Mastodon and Pleroma.
// It will be activated, once this cleared.