*/
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],
}
}
- $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 = 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];
}
$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'])