public static function getContacts(array $owner, array $rel, string $module, int $page = null, string $requester = null, bool $nocache = false): array
{
if (empty($page)) {
- $cachekey = self::CACHEKEY_CONTACTS . $module . ':'. $owner['uid'];
+ $cachekey = self::CACHEKEY_CONTACTS . $module . ':' . $owner['uid'];
$result = DI::cache()->get($cachekey);
if (!$nocache && !is_null($result)) {
return $result;
$owner_cid = Contact::getIdForURL($owner['url'], 0, false);
- $condition = ["`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
- $owner_cid, Post\Collection::FEATURED];
+ $condition = [
+ "`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
+ $owner_cid, Post\Collection::FEATURED
+ ];
$condition = DBA::mergeConditions($condition, [
'uid' => $owner['uid'],
$data['name'] = $full ? $owner['name'] : $owner['nick'];
if ($full && !empty($owner['country-name'] . $owner['region'] . $owner['locality'])) {
- $data['vcard:hasAddress'] = ['@type' => 'vcard:Home', 'vcard:country-name' => $owner['country-name'],
- 'vcard:region' => $owner['region'], 'vcard:locality' => $owner['locality']];
+ $data['vcard:hasAddress'] = [
+ '@type' => 'vcard:Home', 'vcard:country-name' => $owner['country-name'],
+ 'vcard:region' => $owner['region'], 'vcard:locality' => $owner['locality']
+ ];
}
if ($full && !empty($owner['about'])) {
$data['url'] = $owner['url'];
$data['manuallyApprovesFollowers'] = in_array($owner['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP]);
$data['discoverable'] = (bool)$owner['net-publish'] && $full;
- $data['publicKey'] = ['id' => $owner['url'] . '#main-key',
+ $data['publicKey'] = [
+ 'id' => $owner['url'] . '#main-key',
'owner' => $owner['url'],
- 'publicKeyPem' => $owner['pubkey']];
+ 'publicKeyPem' => $owner['pubkey']
+ ];
$data['endpoints'] = ['sharedInbox' => DI::baseUrl() . '/inbox'];
if ($full && $uid != 0) {
$data['icon'] = ['type' => 'Image', 'url' => User::getAvatarUrl($owner)];
if (($key = array_search($item['author-link'], $data['bcc'])) !== false) {
unset($data['bcc'][$key]);
- }
+ }
foreach ($data['to'] as $to) {
if (($key = array_search($to, $data['cc'])) !== false) {
$mail['sensitive'] = false;
$mail['author-link'] = $mail['owner-link'] = $mail['from-url'];
$mail['owner-id'] = $mail['author-id'];
- $mail['allow_cid'] = '<'.$mail['contact-id'].'>';
+ $mail['allow_cid'] = '<' . $mail['contact-id'] . '>';
$mail['allow_gid'] = '';
$mail['deny_cid'] = '';
$mail['deny_gid'] = '';
$mail['parent-uri'] = $reply['uri'];
$mail['parent-uri-id'] = $reply['uri-id'];
$mail['parent-author-id'] = Contact::getIdForURL($reply['from-url'], 0, false);
- $mail['gravity'] = ($mail['reply'] ? Item::GRAVITY_COMMENT: Item::GRAVITY_PARENT);
+ $mail['gravity'] = ($mail['reply'] ? Item::GRAVITY_COMMENT : Item::GRAVITY_PARENT);
$mail['event-type'] = '';
$mail['language'] = '';
$mail['parent'] = 0;
}
$urls[] = $attachment['url'];
- $attach = ['type' => 'Document',
+ $attach = [
+ 'type' => 'Document',
'mediaType' => $attachment['mimetype'],
'url' => $attachment['url'],
- 'name' => $attachment['description']];
+ 'name' => $attachment['description']
+ ];
if (!empty($attachment['height'])) {
$attach['height'] = $attachment['height'];
$title = $item['title'];
$summary = $item['content-warning'] ?: BBCode::toPlaintext(BBCode::getAbstract($item['body'], Protocol::ACTIVITYPUB));
- $source = $item['body'];
if ($item['event-type'] == 'event') {
$type = 'Event';
if (!$summary) {
$summary = $title;
} else {
- $item['raw-body'] = '[b]' . $title . "[/b]\n\n" . $item['raw-body'];
- $item['body'] = '[b]' . $title . "[/b]\n\n" . $item['body'];
- $source = '[h4]' . $title . "[/h4]\n" . $source;
+ $item['raw-body'] = '[h4][b]' . $title . "[/b][/h4]\n\n" . $item['raw-body'];
+ $item['body'] = '[h4][b]' . $title . "[/b][/h4]\n\n" . $item['body'];
}
$title = '';
break;
$type = 'Note';
$item['raw-body'] = '[b]' . $title . "[/b]\n\n" . $item['raw-body'];
$item['body'] = '[b]' . $title . "[/b]\n\n" . $item['body'];
- $source = '[h4]' . $title . "[/h4]\n" . $source;
$title = '';
break;
}
}
if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
- $source = DI::contentItem()->addSharedPost($item, $source);
+ $source = DI::contentItem()->addSharedPost($item, $item['body']);
+ } else {
+ $source = $item['body'];
}
$data['source'] = ['content' => $source, 'mediaType' => "text/bbcode"];
return false;
}
- $hash = hash('ripemd128', $contact['uid'].'-'.$contact['id'].'-'.$contact['created']);
- $uuid = substr($hash, 0, 8). '-' . substr($hash, 8, 4) . '-' . substr($hash, 12, 4) . '-' . substr($hash, 16, 4) . '-' . substr($hash, 20, 12);
+ $hash = hash('ripemd128', $contact['uid'] . '-' . $contact['id'] . '-' . $contact['created']);
+ $uuid = substr($hash, 0, 8) . '-' . substr($hash, 8, 4) . '-' . substr($hash, 12, 4) . '-' . substr($hash, 16, 4) . '-' . substr($hash, 20, 12);
return DI::baseUrl() . '/activity/' . $uuid;
}
return false;
}
- $data = ['@context' => ActivityPub::CONTEXT,
+ $data = [
+ '@context' => ActivityPub::CONTEXT,
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
'type' => 'Delete',
'actor' => $owner['url'],
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
'instrument' => self::getService(),
'to' => [ActivityPub::PUBLIC_COLLECTION],
- 'cc' => []];
+ 'cc' => []
+ ];
$signed = LDSignature::sign($data, $owner);
{
$profile = APContact::getByURL($owner['url']);
- $data = ['@context' => ActivityPub::CONTEXT,
+ $data = [
+ '@context' => ActivityPub::CONTEXT,
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
'type' => 'Update',
'actor' => $owner['url'],
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
'instrument' => self::getService(),
'to' => [$profile['followers']],
- 'cc' => []];
+ 'cc' => []
+ ];
$signed = LDSignature::sign($data, $owner);
$uid = $admin['uid'];
}
- $condition = ['verb' => Activity::FOLLOW, 'uid' => 0, 'parent-uri' => $object,
- 'author-id' => Contact::getPublicIdByUserId($uid)];
+ $condition = [
+ 'verb' => Activity::FOLLOW, 'uid' => 0, 'parent-uri' => $object,
+ 'author-id' => Contact::getPublicIdByUserId($uid)
+ ];
if (Post::exists($condition)) {
Logger::info('Follow for ' . $object . ' for user ' . $uid . ' does already exist.');
return false;
foreach (Tag::getByURIId($uriid, [Tag::IMPLICIT_MENTION]) as $tag) {
$profile = Contact::getByURL($tag['url'], false, ['addr', 'contact-type', 'nick']);
- if (!empty($profile['addr'])
+ if (
+ !empty($profile['addr'])
&& $profile['contact-type'] != Contact::TYPE_COMMUNITY
&& !strstr($body, $profile['addr'])
&& !strstr($body, $tag['url'])