mirror of
https://github.com/friendica/friendica
synced 2025-04-22 01:50:11 +00:00
[ActivityPub] Add support for more attachments structures
- Add support for type: Page into [attachment], type: Link using href attribute - Ensure Receiver::process* parameter is an array - Remove superfluous eptiness check in JsonLD::fetchElementArray
This commit is contained in:
parent
59bd6fd908
commit
01e9beffc2
3 changed files with 90 additions and 59 deletions
|
@ -94,39 +94,43 @@ class Processor
|
|||
}
|
||||
|
||||
foreach ($activity['attachments'] as $attach) {
|
||||
$filetype = strtolower(substr($attach['mediaType'], 0, strpos($attach['mediaType'], '/')));
|
||||
if ($filetype == 'image') {
|
||||
if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
|
||||
continue;
|
||||
}
|
||||
switch ($attach['type']) {
|
||||
case 'link':
|
||||
$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'], '/')));
|
||||
if ($filetype == 'image') {
|
||||
if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($attach['name'])) {
|
||||
$item['body'] .= "\n[img]" . $attach['url'] . '[/img]';
|
||||
} else {
|
||||
$item['body'] .= "\n[img=" . $attach['url'] . ']' . $attach['name'] . '[/img]';
|
||||
}
|
||||
} elseif ($filetype == 'audio') {
|
||||
if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
|
||||
continue;
|
||||
}
|
||||
if (empty($attach['name'])) {
|
||||
$item['body'] .= "\n[img]" . $attach['url'] . '[/img]';
|
||||
} else {
|
||||
$item['body'] .= "\n[img=" . $attach['url'] . ']' . $attach['name'] . '[/img]';
|
||||
}
|
||||
} elseif ($filetype == 'audio') {
|
||||
if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item['body'] .= "\n[audio]" . $attach['url'] . '[/audio]';
|
||||
} elseif ($filetype == 'video') {
|
||||
if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
|
||||
continue;
|
||||
}
|
||||
$item['body'] .= "\n[audio]" . $attach['url'] . '[/audio]';
|
||||
} elseif ($filetype == 'video') {
|
||||
if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item['body'] .= "\n[video]" . $attach['url'] . '[/video]';
|
||||
} else {
|
||||
if (!empty($item["attach"])) {
|
||||
$item["attach"] .= ',';
|
||||
} else {
|
||||
$item["attach"] = '';
|
||||
}
|
||||
if (!isset($attach['length'])) {
|
||||
$attach['length'] = "0";
|
||||
}
|
||||
$item["attach"] .= '[attach]href="'.$attach['url'].'" length="'.$attach['length'].'" type="'.$attach['mediaType'].'" title="'.($attach['name'] ?? '') .'"[/attach]';
|
||||
$item['body'] .= "\n[video]" . $attach['url'] . '[/video]';
|
||||
} else {
|
||||
if (!empty($item["attach"])) {
|
||||
$item["attach"] .= ',';
|
||||
} else {
|
||||
$item["attach"] = '';
|
||||
}
|
||||
|
||||
$item["attach"] .= '[attach]href="' . $attach['url'] . '" length="' . ($attach['length'] ?? '0') . '" type="' . $attach['mediaType'] . '" title="' . ($attach['name'] ?? '') . '"[/attach]';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue