// It is mainly used in the "post_local" hook.
unset($item['api_source']);
+ self::transformToForumPost($item);
// Check for hashtags in the body and repair or add hashtag links
$item['body'] = self::setHashtags($item['body']);
return $current_post;
}
+ /**
+ * Convert items to forum posts
+ *
+ * @param array $item
+ * @return void
+ */
+ private static function transformToForumPost(array $item)
+ {
+ if ($item["verb"] != Activity::ANNOUNCE) {
+ return;
+ }
+
+ $pcontact = Contact::selectFirst(['nurl'], ['id' => $item['author-id'], 'contact-type' => Contact::TYPE_COMMUNITY]);
+ if (empty($pcontact['nurl'])) {
+ return;
+ }
+
+ $contact = Contact::selectFirst(['id'], ['nurl' => $pcontact['nurl'], 'uid' => $item['uid']]);
+ if (!empty($contact['id'])) {
+ Item::update(['owner-id' => $item['author-id'], 'contact-id' => $contact['id']],
+ ['uri-id' => $item['parent-uri-id'], 'uid' => $item['uid']]);
+ LOgger::info('Convert message into a forum message', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'uid' => $item['uid'], 'owner-id' => $item['author-id'], 'contact-id' => $contact['id']]);
+ }
+ }
+
/**
* Distribute the given item to users who subscribed to their tags
*
case 'as:Announce':
if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
- $profile = APContact::getByURL($object_data['actor']);
- // Reshared posts from persons appear as summary at the bottom
- // If this isn't set, then a single reshare appears on top. This is used for groups.
- $object_data['thread-completion'] = ($profile['type'] != 'Group');
+ $object_data['thread-completion'] = true;
$item = ActivityPub\Processor::createItem($object_data);
ActivityPub\Processor::postItem($object_data, $item);
- // Add the bottom reshare information only for persons
- if ($profile['type'] != 'Group') {
- $announce_object_data = self::processObject($activity);
- $announce_object_data['name'] = $type;
- $announce_object_data['author'] = JsonLD::fetchElement($activity, 'as:actor', '@id');
- $announce_object_data['object_id'] = $object_data['object_id'];
- $announce_object_data['object_type'] = $object_data['object_type'];
- $announce_object_data['push'] = $push;
-
- if (!empty($body)) {
- $announce_object_data['raw'] = $body;
- }
+ $announce_object_data = self::processObject($activity);
+ $announce_object_data['name'] = $type;
+ $announce_object_data['author'] = JsonLD::fetchElement($activity, 'as:actor', '@id');
+ $announce_object_data['object_id'] = $object_data['object_id'];
+ $announce_object_data['object_type'] = $object_data['object_type'];
+ $announce_object_data['push'] = $push;
- ActivityPub\Processor::createActivity($announce_object_data, Activity::ANNOUNCE);
+ if (!empty($body)) {
+ $announce_object_data['raw'] = $body;
}
+
+ ActivityPub\Processor::createActivity($announce_object_data, Activity::ANNOUNCE);
}
break;