*/
public static function getOutbox($owner, $page = null)
{
- $public_contact = Contact::getIdForURL($owner['url'], 0, true);
+ $public_contact = Contact::getIdForURL($owner['url'], 0, false);
$condition = ['uid' => 0, 'contact-id' => $public_contact, 'author-id' => $public_contact,
'private' => [Item::PUBLIC, Item::UNLISTED], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
continue;
}
- if ($receiver == $item_profile['followers']) {
+ if ($item_profile && $receiver == $item_profile['followers']) {
$inboxes = array_merge($inboxes, self::fetchTargetInboxesforUser($uid, $personal));
} else {
if (Contact::isLocal($receiver)) {
$data = [];
}
- $data['id'] = $mail['uri'] . '#Create';
+ $data['id'] = $mail['uri'] . '/Create';
$data['type'] = 'Create';
$data['actor'] = $mail['author-link'];
$data['published'] = DateTimeFormat::utc($mail['created'] . '+00:00', DateTimeFormat::ATOM);
}
}
- $data = ActivityPub\Transmitter::createActivityFromItem($item_id);
+ $data = self::createActivityFromItem($item_id);
DI::cache()->set($cachekey, $data, Duration::QUARTER_HOUR);
return $data;
$type = 'Announce';
// Disguise forum posts as reshares. Will later be converted to a real announce
- $item['body'] = share_header($item['author-name'], $item['author-link'], $item['author-avatar'],
- $item['guid'], $item['created'], $item['plink']) . $item['body'] . '[/share]';
+ $item['body'] = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'],
+ $item['plink'], $item['created'], $item['guid']) . $item['body'] . '[/share]';
}
}
$conversation = DBA::selectFirst('conversation', ['source'], $condition);
if (DBA::isResult($conversation)) {
$data = json_decode($conversation['source'], true);
- if (!empty($data)) {
- return $data;
+ if (!empty($data['type'])) {
+ if (in_array($data['type'], ['Create', 'Update'])) {
+ if ($object_mode) {
+ unset($data['@context']);
+ unset($data['signature']);
+ }
+ return $data;
+ } elseif (in_array('as:' . $data['type'], Receiver::CONTENT_TYPES)) {
+ if (!empty($data['@context'])) {
+ $context = $data['@context'];
+ unset($data['@context']);
+ }
+ unset($data['actor']);
+ $object = $data;
+ }
}
}
}
if (!$object_mode) {
- $data = ['@context' => ActivityPub::CONTEXT];
+ $data = ['@context' => $context ?? ActivityPub::CONTEXT];
if ($item['deleted'] && ($item['gravity'] == GRAVITY_ACTIVITY)) {
$type = 'Undo';
$data = [];
}
- $data['id'] = $item['uri'] . '#' . $type;
+ $data['id'] = $item['uri'] . '/' . $type;
$data['type'] = $type;
if (Item::isForumPost($item) && ($type != 'Announce')) {
$data = array_merge($data, self::createPermissionBlockForItem($item, false));
if (in_array($data['type'], ['Create', 'Update', 'Delete'])) {
- $data['object'] = self::createNote($item);
+ $data['object'] = $object ?? self::createNote($item);
} elseif ($data['type'] == 'Add') {
$data = self::createAddTag($item, $data);
} elseif ($data['type'] == 'Announce') {
$url = DI::baseUrl() . '/search?tag=' . urlencode($term['name']);
$tags[] = ['type' => 'Hashtag', 'href' => $url, 'name' => '#' . $term['name']];
} else {
- $contact = Contact::getDetailsByURL($term['url']);
+ $contact = Contact::getByURL($term['url'], false, ['addr']);
if (!empty($contact['addr'])) {
$mention = '@' . $contact['addr'];
} else {
return '';
}
- $data = Contact::getDetailsByURL($match[1]);
+ $data = Contact::getByURL($match[1], false, ['url', 'nick']);
if (empty($data['nick'])) {
return $match[0];
}
{
$event = [];
$event['name'] = $item['event-summary'];
- $event['content'] = BBCode::convert($item['event-desc'], false, 9);
+ $event['content'] = BBCode::convert($item['event-desc'], false, BBCode::ACTIVITYPUB);
$event['startTime'] = DateTimeFormat::utc($item['event-start'] . '+00:00', DateTimeFormat::ATOM);
if (!$item['event-nofinish']) {
$regexp = "/[@!]\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
$body = preg_replace_callback($regexp, ['self', 'mentionCallback'], $body);
- $data['content'] = BBCode::convert($body, false, 9);
+ $data['content'] = BBCode::convert($body, false, BBCode::ACTIVITYPUB);
}
// The regular "content" field does contain a minimized HTML. This is done since systems like
private static function prependMentions($body, int $uriid)
{
- if (DI::config()->get('system', 'disable_implicit_mentions')) {
- return $body;
- }
-
$mentions = [];
foreach (Tag::getByURIId($uriid, [Tag::IMPLICIT_MENTION]) as $tag) {
- $profile = Contact::getDetailsByURL($tag['url']);
+ $profile = Contact::getByURL($tag['url'], false, ['addr', 'contact-type', 'nick']);
if (!empty($profile['addr'])
&& $profile['contact-type'] != Contact::TYPE_COMMUNITY
&& !strstr($body, $profile['addr'])