mirror of
https://github.com/friendica/friendica
synced 2025-04-26 21:10:16 +00:00
Code cleanup for mod/item.php
This commit is contained in:
parent
931ccde90d
commit
0d56f156f7
3 changed files with 374 additions and 586 deletions
|
@ -819,43 +819,8 @@ class Item
|
|||
|
||||
private static function prepareOriginPost(array $item): array
|
||||
{
|
||||
$item['wall'] = 1;
|
||||
$item['origin'] = 1;
|
||||
$item['network'] = Protocol::DFRN;
|
||||
$item['protocol'] = Conversation::PARCEL_DIRECT;
|
||||
$item['direction'] = Conversation::PUSH;
|
||||
|
||||
$owner = User::getOwnerDataById($item['uid']);
|
||||
|
||||
if (empty($item['contact-id'])) {
|
||||
$item['contact-id'] = $owner['id'];
|
||||
}
|
||||
|
||||
if (empty($item['author-link']) && empty($item['author-id'])) {
|
||||
$item['author-link'] = $owner['url'];
|
||||
$item['author-name'] = $owner['name'];
|
||||
$item['author-avatar'] = $owner['thumb'];
|
||||
}
|
||||
|
||||
if (empty($item['owner-link']) && empty($item['owner-id'])) {
|
||||
$item['owner-link'] = $item['author-link'];
|
||||
$item['owner-name'] = $item['author-name'];
|
||||
$item['owner-avatar'] = $item['author-avatar'];
|
||||
}
|
||||
|
||||
// Setting the object type if not defined before
|
||||
if (empty($item['object-type'])) {
|
||||
$item['object-type'] = Activity\ObjectType::NOTE; // Default value
|
||||
$objectdata = BBCode::getAttachedData($item['body']);
|
||||
|
||||
if ($objectdata['type'] == 'link') {
|
||||
$item['object-type'] = Activity\ObjectType::BOOKMARK;
|
||||
} elseif ($objectdata['type'] == 'video') {
|
||||
$item['object-type'] = Activity\ObjectType::VIDEO;
|
||||
} elseif ($objectdata['type'] == 'photo') {
|
||||
$item['object-type'] = Activity\ObjectType::IMAGE;
|
||||
}
|
||||
}
|
||||
$item = DI::contentItem()->initializePost($item);
|
||||
$item = DI::contentItem()->finalizePost($item);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue