public function initializePost(array $post): array
{
- $post['wall'] = true;
- $post['origin'] = true;
- $post['network'] = Protocol::DFRN;
- $post['protocol'] = Conversation::PARCEL_DIRECT;
- $post['direction'] = Conversation::PUSH;
- $post['guid'] = System::createUUID();
- $post['uri'] = ItemModel::newURI($post['guid']);
- $post['verb'] = Activity::POST;
- $post['received'] = DateTimeFormat::utcNow();
+ $post['network'] = Protocol::DFRN;
+ $post['protocol'] = Conversation::PARCEL_DIRECT;
+ $post['direction'] = Conversation::PUSH;
+ $post['received'] = DateTimeFormat::utcNow();
+ $post['origin'] = true;
+ $post['wall'] = $post['wall'] ?? true;
+ $post['guid'] = $post['guid'] ?? System::createUUID();
+ $post['uri'] = $post['uri'] ?? ItemModel::newURI($post['guid']);
+ $post['verb'] = $post['verb'] ?? Activity::POST;
$owner = User::getOwnerDataById($post['uid']);
if (empty($post['contact-id'])) {
$item['hashtags'] = $tags['hashtags'];
$item['mentions'] = $tags['mentions'];
- $item['body'] = preg_replace("#\s*\[attachment .*?].*?\[/attachment]\s*#ism", "\n", $item['body']);
-
if (!$is_preview) {
+ $item['body'] = preg_replace("#\s*\[attachment .*?].*?\[/attachment]\s*#ism", "\n", $item['body']);
$item['body'] = Post\Media::removeFromEndOfBody($item['body'] ?? '');
}
$body = $item['body'];
+ if ($is_preview) {
+ $item['body'] = preg_replace("#\s*\[attachment .*?].*?\[/attachment]\s*#ism", "\n", $item['body']);
+ }
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network', 'has-media', 'quote-uri-id', 'post-type'];