return $data;
}
+ /**
+ * Return the service array containing information the used software and it's url
+ *
+ * @return array with service data
+ */
+ private static function getService()
+ {
+ return ['type' => 'Service',
+ 'name' => FRIENDICA_PLATFORM . " '" . FRIENDICA_CODENAME . "' " . FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
+ 'url' => BaseObject::getApp()->getBaseURL()];
+ }
+
/**
* Return the ActivityPub profile of the given user
*
$data['icon'] = ['type' => 'Image',
'url' => $contact['avatar']];
+ $data['generator'] = self::getService();
+
// tags: https://kitty.town/@inmysocks/100656097926961126.json
return $data;
}
+ /**
+ * @param string $username
+ * @return array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
+ public static function getDeletedUser($username)
+ {
+ return [
+ '@context' => ActivityPub::CONTEXT,
+ 'id' => System::baseUrl() . '/profile/' . $username,
+ 'type' => 'Tombstone',
+ 'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
+ 'updated' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
+ 'deleted' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
+ ];
+ }
+
/**
* Returns an array with permissions of a given item array
*
return $receivers;
}
+ /**
+ * Check if an inbox is archived
+ *
+ * @param string $url Inbox url
+ *
+ * @return boolean "true" if inbox is archived
+ */
+ private static function archivedInbox($url)
+ {
+ return DBA::exists('inbox-status', ['url' => $url, 'archive' => true]);
+ }
+
/**
* Fetches a list of inboxes of followers of a given user
*
} else {
$target = $profile['sharedinbox'];
}
- $inboxes[$target] = $target;
+ if (!self::archivedInbox($target)) {
+ $inboxes[$target] = $target;
+ }
}
}
DBA::close($contacts);
} else {
$target = $profile['sharedinbox'];
}
- $inboxes[$target] = $target;
+ if (!self::archivedInbox($target)) {
+ $inboxes[$target] = $target;
+ }
}
}
}
$condition = ['item-uri' => $item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB];
$conversation = DBA::selectFirst('conversation', ['source'], $condition);
if (DBA::isResult($conversation)) {
- $data = json_decode($conversation['source']);
+ $data = json_decode($conversation['source'], true);
if (!empty($data)) {
return $data;
}
$data['published'] = DateTimeFormat::utc($item['created'] . '+00:00', DateTimeFormat::ATOM);
- $data['instrument'] = ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()];
+ $data['instrument'] = self::getService();
$data = array_merge($data, self::createPermissionBlockForItem($item, false));
return $data;
}
- $data['summary'] = BBCode::convert(BBCode::getAbstract($item['body'], Protocol::ACTIVITYPUB), false, 7);
+ $data['summary'] = BBCode::toPlaintext(BBCode::getAbstract($item['body'], Protocol::ACTIVITYPUB));
if ($item['uri'] != $item['thr-parent']) {
$data['inReplyTo'] = $item['thr-parent'];
if ($type == 'Note') {
$body = self::removePictures($body);
} elseif (($type == 'Article') && empty($data['summary'])) {
- $data['summary'] = BBCode::convert(Plaintext::shorten(self::removePictures($body), 1000), false, 7);
+ $data['summary'] = BBCode::toPlaintext(Plaintext::shorten(self::removePictures($body), 1000));
}
if ($type == 'Event') {
'actor' => $owner['url'],
'object' => $suggestion['url'],
'content' => $suggestion['note'],
- 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
+ 'instrument' => self::getService(),
'to' => [ActivityPub::PUBLIC_COLLECTION],
'cc' => []];
'actor' => $owner['url'],
'object' => $owner['url'],
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
- 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
+ 'instrument' => self::getService(),
'to' => [ActivityPub::PUBLIC_COLLECTION],
'cc' => []];
'actor' => $owner['url'],
'object' => $owner['url'],
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
- 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
+ 'instrument' => self::getService(),
'to' => [ActivityPub::PUBLIC_COLLECTION],
'cc' => []];
'actor' => $owner['url'],
'object' => self::getProfile($uid),
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
- 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
+ 'instrument' => self::getService(),
'to' => [$profile['followers']],
'cc' => []];
'type' => $activity,
'actor' => $owner['url'],
'object' => $profile['url'],
- 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
+ 'instrument' => self::getService(),
'to' => [$profile['url']]];
Logger::log('Sending activity ' . $activity . ' to ' . $target . ' for user ' . $uid, Logger::DEBUG);
'type' => 'Follow',
'actor' => $owner['url'],
'object' => $object,
- 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
+ 'instrument' => self::getService(),
'to' => [$profile['url']]];
Logger::log('Sending follow ' . $object . ' to ' . $target . ' for user ' . $uid, Logger::DEBUG);
'object' => ['id' => $id, 'type' => 'Follow',
'actor' => $profile['url'],
'object' => $owner['url']],
- 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
+ 'instrument' => self::getService(),
'to' => [$profile['url']]];
Logger::log('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG);
'object' => ['id' => $id, 'type' => 'Follow',
'actor' => $profile['url'],
'object' => $owner['url']],
- 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
+ 'instrument' => self::getService(),
'to' => [$profile['url']]];
Logger::log('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG);
'object' => ['id' => $object_id, 'type' => 'Follow',
'actor' => $owner['url'],
'object' => $profile['url']],
- 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
+ 'instrument' => self::getService(),
'to' => [$profile['url']]];
Logger::log('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG);