+ /**
+ * Process the content
+ *
+ * @param array $activity Activity array
+ * @param array $item
+ * @return array|bool Returns the item array or false if there was an unexpected occurrence
+ * @throws \Exception
+ */
+ private static function processContent($activity, $item)
+ {
+ $item['title'] = HTML::toBBCode($activity['name']);
+
+ if (!empty($activity['source'])) {
+ $item['body'] = $activity['source'];
+ } else {
+ $content = HTML::toBBCode($activity['content']);
+
+ if (!empty($activity['emojis'])) {
+ $content = self::replaceEmojis($content, $activity['emojis']);
+ }
+
+ $content = self::convertMentions($content);
+
+ if (empty($activity['directmessage']) && ($item['thr-parent'] != $item['uri']) && ($item['gravity'] == GRAVITY_COMMENT)) {
+ $item_private = !in_array(0, $activity['item_receiver']);
+ $parent = Item::selectFirst(['id', 'private', 'author-link', 'alias'], ['uri' => $item['thr-parent']]);
+ if (!DBA::isResult($parent)) {
+ Logger::warning('Unknown parent item.', ['uri' => $item['thr-parent']]);
+ return false;
+ }
+ if ($item_private && !$parent['private']) {
+ Logger::warning('Item is private but the parent is not. Dropping.', ['item-uri' => $item['uri'], 'thr-parent' => $item['thr-parent']]);
+ return false;
+ }
+
+ $potential_implicit_mentions = self::getImplicitMentionList($parent);
+ $content = self::removeImplicitMentionsFromBody($content, $potential_implicit_mentions);
+ $activity['tags'] = self::convertImplicitMentionsInTags($activity['tags'], $potential_implicit_mentions);
+ }
+ $item['content-warning'] = HTML::toBBCode($activity['summary']);
+ $item['body'] = $content;
+
+ if (($activity['object_type'] == 'as:Video') && !empty($activity['alternate-url'])) {
+ $item['body'] .= "\n[video]" . $activity['alternate-url'] . '[/video]';
+ }
+ }
+
+ $item['tag'] = self::constructTagString($activity['tags'], $activity['sensitive']);
+
+ $item['location'] = $activity['location'];
+
+ if (!empty($item['latitude']) && !empty($item['longitude'])) {
+ $item['coord'] = $item['latitude'] . ' ' . $item['longitude'];
+ }
+
+ $item['app'] = $activity['generator'];
+
+ return $item;
+ }
+