Fixing processing forum posts

This commit is contained in:
Michael 2020-08-09 22:46:18 +00:00
parent bf7128b4b2
commit 62ce87dfe6
3 changed files with 38 additions and 17 deletions

View File

@ -1800,6 +1800,7 @@ class Item
// 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']);
@ -1990,6 +1991,31 @@ class Item
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
*

View File

@ -387,16 +387,11 @@ class Receiver
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');
@ -410,7 +405,6 @@ class Receiver
ActivityPub\Processor::createActivity($announce_object_data, Activity::ANNOUNCE);
}
}
break;
case 'as:Like':

View File

@ -2162,6 +2162,7 @@ class DFRN
|| ($item["verb"] == Activity::ATTEND)
|| ($item["verb"] == Activity::ATTENDNO)
|| ($item["verb"] == Activity::ATTENDMAYBE)
|| ($item["verb"] == Activity::ANNOUNCE)
) {
$is_like = true;
$item["gravity"] = GRAVITY_ACTIVITY;