private static function processContent(array $activity, array $item)
{
if (!empty($activity['mediatype']) && ($activity['mediatype'] == 'text/markdown')) {
- $item['title'] = strip_tags($activity['name']);
+ $item['title'] = strip_tags($activity['name'] ?? '');
$content = Markdown::toBBCode($activity['content']);
} elseif (!empty($activity['mediatype']) && ($activity['mediatype'] == 'text/bbcode')) {
$item['title'] = $activity['name'];
foreach ($receivers[$element] as $receiver) {
if ($receiver == ActivityPub::PUBLIC_COLLECTION) {
$name = Receiver::PUBLIC_COLLECTION;
+ } elseif ($path = parse_url($receiver, PHP_URL_PATH)) {
+ $name = trim($path, '/');
} else {
- $name = trim(parse_url($receiver, PHP_URL_PATH), '/');
+ Logger::warning('Unable to coerce name from receiver', ['receiver' => $receiver]);
+ $name = '';
}
$target = Tag::getTargetType($receiver);
{
if (empty($activity['object_id']) || empty($activity['actor'])) {
Logger::info('Empty object id or actor.');
+ Queue::remove($activity);
return;
}
if ($activity['object_id'] != $activity['actor']) {
Logger::info('Object id does not match actor.');
+ Queue::remove($activity);
return;
}
Queue::remove($activity);
}
+ /**
+ * Add moved contacts as followers for all subscribers of the old contact
+ *
+ * @param array $activity
+ * @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
+ public static function movePerson(array $activity)
+ {
+ if (empty($activity['target_id']) || empty($activity['object_id'])) {
+ Queue::remove($activity);
+ return;
+ }
+
+ if ($activity['object_id'] != $activity['actor']) {
+ Logger::notice('Object is not the actor', ['activity' => $activity]);
+ Queue::remove($activity);
+ return;
+ }
+
+ $from = Contact::getByURL($activity['object_id'], false, ['uri-id']);
+ if (empty($from['uri-id'])) {
+ Logger::info('Object not found', ['activity' => $activity]);
+ Queue::remove($activity);
+ return;
+ }
+
+ $contacts = DBA::select('contact', ['uid', 'url'], ["`uri-id` = ? AND `uid` != ? AND `rel` IN (?, ?)", $from['uri-id'], 0, Contact::FRIEND, Contact::SHARING]);
+ while ($from_contact = DBA::fetch($contacts)) {
+ $result = Contact::createFromProbeForUser($from_contact['uid'], $activity['target_id']);
+ Logger::debug('Follower added', ['from' => $from_contact, 'result' => $result]);
+ }
+ DBA::close($contacts);
+ Queue::remove($activity);
+ }
+
/**
* Blocks the user by the contact
*
Queue::remove($activity);
}
+ /**
+ * Report a user
+ *
+ * @param array $activity
+ * @return void
+ * @throws \Exception
+ */
+ public static function ReportAccount(array $activity)
+ {
+ $account_id = Contact::getIdForURL($activity['object_id']);
+ if (empty($account_id)) {
+ Logger::info('Unknown account', ['activity' => $activity]);
+ Queue::remove($activity);
+ return;
+ }
+
+ $status_ids = $activity['object_ids'];
+ array_shift($status_ids);
+
+ $uri_ids = [];
+ foreach ($status_ids as $status_id) {
+ $post = Post::selectFirst(['uri-id'], ['uri' => $status_id]);
+ if (!empty($post['uri-id'])) {
+ $uri_ids[] = $post['uri-id'];
+ }
+ }
+
+ $report = DI::reportFactory()->createFromReportsRequest(0, $account_id, $activity['content'], false, $uri_ids);
+ DI::report()->save($report);
+
+ Logger::info('Stored report', ['account_id' => $account_id, 'comment' => $activity['content'], 'status_ids' => $status_ids]);
+ }
+
/**
* Accept a follow request
*
*/
public static function acceptFollowUser(array $activity)
{
- $uid = User::getIdForURL($activity['object_actor']);
+ if (!empty($activity['object_actor'])) {
+ $uid = User::getIdForURL($activity['object_actor']);
+ $check_id = false;
+ } elseif (!empty($activity['receiver']) && (count($activity['receiver']) == 1)) {
+ $uid = array_shift($activity['receiver']);
+ $check_id = true;
+ }
+
if (empty($uid)) {
+ Logger::notice('User could not be detected', ['activity' => $activity]);
+ Queue::remove($activity);
return;
}
$cid = Contact::getIdForURL($activity['actor'], $uid);
if (empty($cid)) {
- Logger::info('No contact found', ['actor' => $activity['actor']]);
+ Logger::notice('No contact found', ['actor' => $activity['actor']]);
+ Queue::remove($activity);
return;
}
+ $id = Transmitter::activityIDFromContact($cid);
+ if ($id == $activity['object_id']) {
+ Logger::info('Successful id check', ['uid' => $uid, 'cid' => $cid]);
+ } else {
+ Logger::info('Unsuccessful id check', ['uid' => $uid, 'cid' => $cid, 'id' => $id, 'object_id' => $activity['object_id']]);
+ if ($check_id) {
+ Queue::remove($activity);
+ return;
+ }
+ }
+
self::switchContact($cid);
$fields = ['pending' => false];