- /**
- * Return share data from an item array (if the item is shared item)
- * We are providing the complete Item array, because at some time in the future
- * we hopefully will define these values not in the body anymore but in some item fields.
- * This function is meant to replace all similar functions in the system.
- *
- * @param array $item
- *
- * @return array with share information
- */
- public static function getShareArray(array $item): array
- {
- $attributes = BBCode::fetchShareAttributes($item['body'] ?? '');
- if (!empty($attributes)) {
- return $attributes;
- }
-
- if (!empty($item['quote-uri-id'])) {
- $shared = Post::selectFirst(['author-name', 'author-link', 'author-avatar', 'plink', 'created', 'guid', 'uri', 'body'], ['uri-id' => $item['quote-uri-id']]);
- if (!empty($shared)) {
- return [
- 'author' => $shared['author-name'],
- 'profile' => $shared['author-link'],
- 'avatar' => $shared['author-avatar'],
- 'link' => $shared['plink'],
- 'posted' => $shared['created'],
- 'guid' => $shared['guid'],
- 'message_id' => $shared['uri'],
- 'comment' => $item['body'],
- 'shared' => $shared['body'],
- ];
- }
- }
-
- return [];
- }
-