Fixing processing forum posts
This commit is contained in:
parent
bf7128b4b2
commit
62ce87dfe6
3 changed files with 38 additions and 17 deletions
|
@ -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
|
||||
*
|
||||
|
|
|
@ -387,29 +387,23 @@ 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');
|
||||
$announce_object_data['object_id'] = $object_data['object_id'];
|
||||
$announce_object_data['object_type'] = $object_data['object_type'];
|
||||
$announce_object_data['push'] = $push;
|
||||
$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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue