*/
public static function addRelayServerInboxes(array $inboxes = [])
{
- $contacts = DBA::select('apcontact', ['inbox'],
- ["`type` = ? AND `url` IN (SELECT `url` FROM `contact` WHERE `uid` = ? AND `rel` = ?)",
- 'Application', 0, Contact::FRIEND]);
- while ($contact = DBA::fetch($contacts)) {
+ foreach (Relay::getList(['inbox']) as $contact) {
$inboxes[$contact['inbox']] = $contact['inbox'];
}
- DBA::close($contacts);
return $inboxes;
}
return $inboxes;
}
- $relays = Relay::getList($item_id, [], [Protocol::ACTIVITYPUB]);
+ $relays = Relay::getDirectRelayList($item_id);
if (empty($relays)) {
return $inboxes;
}
return $success;
}
-
+
/**
* Collects a list of contacts of the given owner
*
return [];
}
- $fields = ['locality', 'region', 'country-name'];
+ $fields = ['locality', 'region', 'country-name', 'net-publish'];
$profile = DBA::selectFirst('profile', $fields, ['uid' => $uid]);
if (!DBA::isResult($profile)) {
return [];
}
- $fields = ['name', 'url', 'location', 'about', 'avatar', 'photo'];
+ $fields = ['id', 'name', 'url', 'location', 'about', 'avatar', 'photo', 'updated'];
$contact = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
if (!DBA::isResult($contact)) {
return [];
$contact = User::getSystemAccount();
$user = ['guid' => '', 'nickname' => $contact['nick'], 'pubkey' => $contact['pubkey'],
'account-type' => $contact['contact-type'], 'page-flags' => User::PAGE_FLAGS_NORMAL];
- $profile = ['locality' => '', 'region' => '', 'country-name' => ''];
+ $profile = ['locality' => '', 'region' => '', 'country-name' => '', 'net-publish' => false];
}
$data = ['@context' => ActivityPub::CONTEXT];
}
$data['type'] = ActivityPub::ACCOUNT_TYPES[$user['account-type']];
-
+
if ($uid != 0) {
$data['following'] = DI::baseUrl() . '/following/' . $user['nickname'];
$data['followers'] = DI::baseUrl() . '/followers/' . $user['nickname'];
$data['url'] = $contact['url'];
$data['manuallyApprovesFollowers'] = in_array($user['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP]);
+ $data['discoverable'] = $profile['net-publish'];
$data['publicKey'] = ['id' => $contact['url'] . '#main-key',
'owner' => $contact['url'],
'publicKeyPem' => $user['pubkey']];
$data['endpoints'] = ['sharedInbox' => DI::baseUrl() . '/inbox'];
- $data['icon'] = ['type' => 'Image',
- 'url' => $contact['photo']];
+ $data['icon'] = ['type' => 'Image', 'url' => Contact::getAvatarUrlForId($contact['id'], '', $contact['updated'])];
+
+ $resourceid = Photo::ridFromURI($contact['photo']);
+ if (!empty($resourceid)) {
+ $photo = Photo::selectFirst(['type'], ["resource-id" => $resourceid]);
+ if (!empty($photo['type'])) {
+ $data['icon']['mediaType'] = $photo['type'];
+ }
+ }
+
+ if (!empty($contact['header'])) {
+ $data['image'] = ['type' => 'Image', 'url' => Contact::getHeaderUrlForId($contact['id'], '', $contact['updated'])];
+
+ $resourceid = Photo::ridFromURI($contact['header']);
+ if (!empty($resourceid)) {
+ $photo = Photo::selectFirst(['type'], ["resource-id" => $resourceid]);
+ if (!empty($photo['type'])) {
+ $data['image']['mediaType'] = $photo['type'];
+ }
+ }
+ }
$data['generator'] = self::getService();
$actor_profile = APContact::getByURL($item['author-link']);
}
+ $exclusive = false;
+
$terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
if ($item['private'] != Item::PRIVATE) {
foreach ($terms as $term) {
$profile = APContact::getByURL($term['url'], false);
if (!empty($profile)) {
+ if ($term['type'] == Tag::EXCLUSIVE_MENTION) {
+ $exclusive = true;
+ if (!empty($profile['followers']) && ($profile['type'] == 'Group')) {
+ $data['cc'][] = $profile['followers'];
+ }
+ }
$data['to'][] = $profile['url'];
}
}
// But comments to forums aren't directed to the followers collection
// This rule is only valid when the actor isn't the forum.
// The forum needs to transmit their content to their followers.
- if (($profile['type'] == 'Group') && ($profile['url'] != $actor_profile['url'])) {
+ if (($profile['type'] == 'Group') && ($profile['url'] != ($actor_profile['url'] ?? ''))) {
$data['to'][] = $profile['url'];
} else {
$data['cc'][] = $profile['url'];
$data['cc'][] = $actor_profile['followers'];
}
}
- } else {
- // Public thread parent post always are directed to the followers
+ } elseif (!$exclusive) {
+ // Public thread parent post always are directed to the followers.
+ // This mustn't be done by posts that are directed to forum servers via the exclusive mention.
+ // But possibly in that case we could add the "followers" collection of the forum to the message.
if (($item['private'] != Item::PRIVATE) && !$forum_mode) {
$data['cc'][] = $actor_profile['followers'];
}
/**
* Check if a given contact should be delivered via AP
*
- * @param array $contact
- * @param array $networks
- * @return bool
- * @throws Exception
+ * @param array $contact
+ * @param array $networks
+ * @return bool
+ * @throws Exception
*/
private static function isAPContact(array $contact, array $networks)
{
if (!empty($self['uid'])) {
$forum_item = Post::selectFirst(Item::DELIVER_FIELDLIST, ['uri-id' => $item['uri-id'], 'uid' => $self['uid']]);
if (DBA::isResult($forum_item)) {
- $item = $forum_item;
+ $item = $forum_item;
}
}
}
}
$urls[] = $attachment['url'];
- $attachments[] = ['type' => 'Document',
+ $attach = ['type' => 'Document',
'mediaType' => $attachment['mimetype'],
'url' => $attachment['url'],
'name' => $attachment['description']];
+
+ if (!empty($attachment['height'])) {
+ $attach['height'] = $attachment['height'];
+ }
+
+ if (!empty($attachment['width'])) {
+ $attach['width'] = $attachment['width'];
+ }
+
+ if (!empty($attachment['preview'])) {
+ $attach['image'] = $attachment['preview'];
+ }
+
+ $attachments[] = $attach;
}
}
}
$urls[] = $attachment['url'];
- $attachments[] = ['type' => 'Document',
+ $attach = ['type' => 'Document',
'mediaType' => $attachment['mimetype'],
'url' => $attachment['url'],
'name' => $attachment['description']];
+
+ if (!empty($attachment['height'])) {
+ $attach['height'] = $attachment['height'];
+ }
+
+ if (!empty($attachment['width'])) {
+ $attach['width'] = $attachment['width'];
+ }
+
+ if (!empty($attachment['preview'])) {
+ $attach['image'] = $attachment['preview'];
+ }
+
+ $attachments[] = $attach;
}
// Currently deactivated, since it creates side effects on Mastodon and Pleroma.
// It will be activated, once this cleared.
* This part is currently deactivated. The automated summary seems to be more
* confusing than helping. But possibly we will find a better way.
* So the code is left here for now as a reminder
- *
+ *
* } elseif (($type == 'Article') && empty($data['summary'])) {
* $regexp = "/[@!]\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
* $summary = preg_replace_callback($regexp, ['self', 'mentionAddrCallback'], $body);