sforkowany z mirror/friendica
commit
32b8c6f65e
|
@ -198,6 +198,43 @@ class Processor
|
||||||
Item::delete(['uri' => $activity['object_id'], 'owner-id' => $owner]);
|
Item::delete(['uri' => $activity['object_id'], 'owner-id' => $owner]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the item array for an activity
|
||||||
|
*
|
||||||
|
* @param array $activity Activity array
|
||||||
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
|
* @throws \ImagickException
|
||||||
|
*/
|
||||||
|
public static function addTag($activity)
|
||||||
|
{
|
||||||
|
if (empty($activity['object_content']) || empty($activity['object_id'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($activity['receiver'] as $receiver) {
|
||||||
|
$item = Item::selectFirst(['id', 'tag', 'origin', 'author-link'], ['uri' => $activity['target_id'], 'uid' => $receiver]);
|
||||||
|
if (!DBA::isResult($item)) {
|
||||||
|
// We don't fetch missing content for this purpose
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($item['author-link'] != $activity['actor']) && !$item['origin']) {
|
||||||
|
Logger::info('Not origin, not from the author, skipping update', ['id' => $item['id'], 'author' => $item['author-link'], 'actor' => $activity['actor']]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// To-Do:
|
||||||
|
// - Check if "blocktag" is set
|
||||||
|
// - Check if actor is a contact
|
||||||
|
|
||||||
|
if (!stristr($item['tag'], trim($activity['object_content']))) {
|
||||||
|
$tag = $item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $activity['object_id'] . ']'. $activity['object_content'] . '[/url]';
|
||||||
|
Item::update(['tag' => $tag], ['id' => $item['id']]);
|
||||||
|
Logger::info('Tagged item', ['id' => $item['id'], 'tag' => $activity['object_content'], 'uri' => $activity['target_id'], 'actor' => $activity['actor']]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the item array for an activity
|
* Prepare the item array for an activity
|
||||||
*
|
*
|
||||||
|
|
|
@ -226,6 +226,13 @@ class Receiver
|
||||||
$object_data['author'] = JsonLD::fetchElement($activity, 'as:actor', '@id');
|
$object_data['author'] = JsonLD::fetchElement($activity, 'as:actor', '@id');
|
||||||
$object_data['object_id'] = $object_id;
|
$object_data['object_id'] = $object_id;
|
||||||
$object_data['object_type'] = ''; // Since we don't fetch the object, we don't know the type
|
$object_data['object_type'] = ''; // Since we don't fetch the object, we don't know the type
|
||||||
|
} elseif (in_array($type, ['as:Add'])) {
|
||||||
|
$object_data = [];
|
||||||
|
$object_data['id'] = JsonLD::fetchElement($activity, '@id');
|
||||||
|
$object_data['target_id'] = JsonLD::fetchElement($activity, 'as:target', '@id');
|
||||||
|
$object_data['object_id'] = JsonLD::fetchElement($activity, 'as:object', '@id');
|
||||||
|
$object_data['object_type'] = JsonLD::fetchElement($activity['as:object'], '@type');
|
||||||
|
$object_data['object_content'] = JsonLD::fetchElement($activity['as:object'], 'as:content', '@type');
|
||||||
} else {
|
} else {
|
||||||
$object_data = [];
|
$object_data = [];
|
||||||
$object_data['id'] = JsonLD::fetchElement($activity, '@id');
|
$object_data['id'] = JsonLD::fetchElement($activity, '@id');
|
||||||
|
@ -366,6 +373,12 @@ class Receiver
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'as:Add':
|
||||||
|
if ($object_data['object_type'] == 'as:tag') {
|
||||||
|
ActivityPub\Processor::addTag($object_data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'as:Announce':
|
case 'as:Announce':
|
||||||
if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
||||||
$profile = APContact::getByURL($object_data['actor']);
|
$profile = APContact::getByURL($object_data['actor']);
|
||||||
|
|
Ładowanie…
Reference in New Issue