mirror of
https://github.com/friendica/friendica
synced 2024-12-22 23:20:16 +00:00
Add check for existing attachment in ActivityPub\Processor::constructAttachList
This commit is contained in:
parent
01e9beffc2
commit
4d3dd28c44
1 changed files with 9 additions and 1 deletions
|
@ -96,7 +96,15 @@ class Processor
|
|||
foreach ($activity['attachments'] as $attach) {
|
||||
switch ($attach['type']) {
|
||||
case 'link':
|
||||
$item['body'] .= "\n[attachment type='link' url='" . $attach['url'] . "' title='" . ($attach['title'] ?? '') . "' image='" . ($attach['image'] ?? '') . "']" . ($attach['desc'] ?? '') . '[/attachment]';
|
||||
// Only one [attachment] tag is allowed
|
||||
$existingAttachmentPos = strpos($item['body'], '[attachment');
|
||||
if ($existingAttachmentPos !== false) {
|
||||
$linkTitle = $attach['title'] ?: $attach['url'];
|
||||
// Additional link attachments are prepended before the existing [attachment] tag
|
||||
$item['body'] = substr_replace($item['body'], "\n[bookmark=" . $attach['url'] . ']' . $linkTitle . "[/bookmark]\n", $existingAttachmentPos, 0);
|
||||
} else {
|
||||
$item['body'] .= "\n[attachment type='link' url='" . $attach['url'] . "' title='" . ($attach['title'] ?? '') . "' image='" . ($attach['image'] ?? '') . "']" . ($attach['desc'] ?? '') . '[/attachment]';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$filetype = strtolower(substr($attach['mediaType'], 0, strpos($attach['mediaType'], '/')));
|
||||
|
|
Loading…
Reference in a new issue