* - Event
*
* General:
+ * - Attachments
+ * - nsfw (sensitive)
* - Queueing unsucessful deliveries
* - Polling the outboxes for missing content?
* - Possibly using the LD-JSON parser
public static function createActivityFromItem($item_id, $object_mode = false)
{
- $item = Item::selectFirst([], ['id' => $item_id]);
+ $item = Item::selectFirst([], ['id' => $item_id, 'parent-network' => Protocol::NATIVE_SUPPORT]);
if (!DBA::isResult($item)) {
return false;
$data['updated'] = DateTimeFormat::utc($item["edited"]."+00:00", DateTimeFormat::ATOM);
}
- $data['context'] = self::createConversationURLFromItem($item);
+ $data['context'] = self::fetchContextURLForItem($item);
$data = array_merge($data, ActivityPub::createPermissionBlockForItem($item));
public static function createObjectFromItemID($item_id)
{
- $item = Item::selectFirst([], ['id' => $item_id]);
+ $item = Item::selectFirst([], ['id' => $item_id, 'parent-network' => Protocol::NATIVE_SUPPORT]);
if (!DBA::isResult($item)) {
return false;
return $tags;
}
- private static function createConversationURLFromItem($item)
+ private static function fetchConversationURLForItem($item)
{
- $conversation = DBA::selectFirst('conversation', ['conversation-uri'], ['item-uri' => $item['parent-uri']]);
+ $conversation = DBA::selectFirst('conversation', ['conversation-href', 'conversation-uri'], ['item-uri' => $item['parent-uri']]);
if (DBA::isResult($conversation) && !empty($conversation['conversation-uri'])) {
$conversation_uri = $conversation['conversation-uri'];
+ } elseif (DBA::isResult($conversation) && !empty($conversation['conversation-href'])) {
+ $conversation_uri = $conversation['conversation-href'];
} else {
$conversation_uri = str_replace('/object/', '/context/', $item['parent-uri']);
}
return $conversation_uri;
}
+ private static function fetchContextURLForItem($item)
+ {
+ $conversation = DBA::selectFirst('conversation', ['conversation-href', 'conversation-uri'], ['item-uri' => $item['parent-uri']]);
+ if (DBA::isResult($conversation) && !empty($conversation['conversation-href'])) {
+ $context_uri = $conversation['conversation-href'];
+ } elseif (DBA::isResult($conversation) && !empty($conversation['conversation-uri'])) {
+ $context_uri = $conversation['conversation-uri'];
+ } else {
+ $context_uri = str_replace('/object/', '/context/', $item['parent-uri']);
+ }
+ return $context_uri;
+ }
+
private static function CreateNote($item)
{
if (!empty($item['title'])) {
$data['attributedTo'] = $item['author-link'];
$data['actor'] = $item['author-link'];
$data['sensitive'] = false; // - Query NSFW
- $data['conversation'] = $data['context'] = self::createConversationURLFromItem($item);
+ $data['conversation'] = self::fetchConversationURLForItem($item);
+ $data['context'] = self::fetchContextURLForItem($item);
if (!empty($item['title'])) {
$data['name'] = BBCode::convert($item['title'], false, 7);
$data['tag'] = self::createTagList($item);
$data = array_merge($data, ActivityPub::createPermissionBlockForItem($item));
- //$data['emoji'] = []; // Ignore by now
return $data;
}
$item['protocol'] = Conversation::PARCEL_ACTIVITYPUB;
$item['source'] = $body;
+ $item['conversation-href'] = $activity['context'];
$item['conversation-uri'] = $activity['conversation'];
foreach ($activity['receiver'] as $receiver) {