$owner_record = DBA::selectFirst('contact', [], ['uid' => api_user(), 'self' => true]);
$arr = [];
- $arr['guid'] = System::createGUID(32);
+ $arr['guid'] = System::UUID();
$arr['uid'] = intval(api_user());
$arr['uri'] = $uri;
$arr['parent-uri'] = $uri;
$emailcc = notags(trim(defaults($_REQUEST, 'emailcc' , '')));
$body = escape_tags(trim(defaults($_REQUEST, 'body' , '')));
$network = notags(trim(defaults($_REQUEST, 'network' , Protocol::DFRN)));
- $guid = System::createGUID(32);
+ $guid = System::UUID();
$postopts = defaults($_REQUEST, 'postopts', '');
$uri = Item::newURI($page_owner_uid);
$arr = [];
- $arr['guid'] = System::createGUID(32);
+ $arr['guid'] = System::UUID();
$arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri;
$arr['parent-uri'] = $uri;
$uri = Item::newURI($page_owner_uid);
$arr = [];
- $arr['guid'] = System::createGUID(32);
+ $arr['guid'] = System::UUID();
$arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri;
$arr['parent-uri'] = $uri;
$arr['coord'] = $lat . ' ' . $lon;
}
- $arr['guid'] = System::createGUID(32);
+ $arr['guid'] = System::UUID();
$arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri;
$arr['parent-uri'] = $uri;
$arr = [];
- $arr['guid'] = System::createGUID(32);
+ $arr['guid'] = System::UUID();
$arr['uid'] = $uid;
$arr['uri'] = $uri;
$arr['parent-uri'] = (!empty($parent_uri) ? $parent_uri : $uri);
$arr = [];
- $arr['guid'] = System::createGUID(32);
+ $arr['guid'] = System::UUID();
$arr['uri'] = $uri;
$arr['uid'] = $owner_uid;
$arr['contact-id'] = $contact['id'];
$arr = [];
- $arr['guid'] = System::createGUID(32);
+ $arr['guid'] = System::UUID();
$arr['uri'] = $uri;
$arr['uid'] = $owner_uid;
$arr['contact-id'] = $contact['id'];
killme();
}
+ /**
+ * Generates a random string in the UUID format
+ *
+ * @param bool|string $prefix A given prefix (default is empty)
+ * @return string a generated UUID
+ */
+ public static function UUID($prefix = '')
+ {
+ $guid = System::createGUID(32, $prefix);
+ return substr($guid, 0, 8). '-' . substr($guid, 8, 4) . '-' . substr($guid, 12, 4) . '-' . substr($guid, 16, 4) . '-' . substr($guid, 20, 12);
+ }
+
/**
* Generates a GUID with the given parameters
*
Addon::callHooks('event_updated', $event['id']);
} else {
- $event['guid'] = defaults($arr, 'guid', System::createGUID(32));
+ $event['guid'] = defaults($arr, 'guid', System::UUID());
// New event. Store it.
DBA::insert('event', $event);
} elseif (!empty($item['uri'])) {
$guid = self::guidFromUri($item['uri'], $prefix_host);
} else {
- $guid = System::createGUID(32, hash('crc32', $prefix_host));
+ $guid = System::UUID(hash('crc32', $prefix_host));
}
return $guid;
public static function newURI($uid, $guid = "")
{
if ($guid == "") {
- $guid = System::createGUID(32);
+ $guid = System::UUID();
}
return self::getApp()->get_baseurl() . '/object/' . $guid;
}
if ($contact['network'] != Protocol::FEED) {
- $datarray["guid"] = System::createGUID(32);
+ $datarray["guid"] = System::UUID();
unset($datarray["plink"]);
$datarray["uri"] = self::newURI($contact['uid'], $datarray["guid"]);
$datarray["parent-uri"] = $datarray["uri"];
$objtype = $item['resource-id'] ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE ;
$new_item = [
- 'guid' => System::createGUID(32),
+ 'guid' => System::UUID(),
'uri' => self::newURI($item['uid']),
'uid' => $item['uid'],
'contact-id' => $item_contact_id,
return -2;
}
- $guid = System::createGUID(32);
+ $guid = System::UUID();
$uri = 'urn:X-dfrn:' . System::baseUrl() . ':' . local_user() . ':' . $guid;
$convid = 0;
$recip_handle = (($contact['addr']) ? $contact['addr'] : $contact['nick'] . '@' . $recip_host);
$sender_handle = $a->user['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);
- $conv_guid = System::createGUID(32);
+ $conv_guid = System::UUID();
$convuri = $recip_handle . ':' . $conv_guid;
$handles = $recip_handle . ';' . $sender_handle;
$subject = L10n::t('[no subject]');
}
- $guid = System::createGUID(32);
+ $guid = System::UUID();
$uri = 'urn:X-dfrn:' . System::baseUrl() . ':' . local_user() . ':' . $guid;
$me = Probe::uri($replyto);
return -2;
}
- $conv_guid = System::createGUID(32);
+ $conv_guid = System::UUID();
$recip_handle = $recipient['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);
$spubkey = $sres['pubkey'];
$insert_result = DBA::insert('user', [
- 'guid' => System::createGUID(32),
+ 'guid' => System::UUID(),
'username' => $username,
'password' => $new_password_encoded,
'email' => $email,
const PUBLIC = 'https://www.w3.org/ns/activitystreams#Public';
const CONTEXT = ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1',
['ostatus' => 'http://ostatus.org#', 'uuid' => 'http://schema.org/identifier',
- 'sensitive' => 'as:sensitive', 'Hashtag' => 'as:Hashtag',
- 'atomUri' => 'ostatus:atomUri', 'conversation' => 'ostatus:conversation',
- 'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri']];
+ 'vcard' => 'http://www.w3.org/2006/vcard/ns#',
+ 'diaspora' => 'https://diasporafoundation.org#',
+ 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
+ 'sensitive' => 'as:sensitive', 'Hashtag' => 'as:Hashtag']];
public static function isRequest()
{
return [];
}
- $data = ['@context' => ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1',
- ['vcard' => 'http://www.w3.org/2006/vcard/ns#', 'uuid' => 'http://schema.org/identifier',
- 'sensitive' => 'as:sensitive', 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers']]];
-
+ $data = ['@context' => self::CONTEXT];
$data['id'] = $contact['url'];
- $data['uuid'] = $user['guid'];
+ $data['diaspora:guid'] = $user['guid'];
$data['type'] = $accounttype[$user['account-type']];
$data['following'] = System::baseUrl() . '/following/' . $user['nickname'];
$data['followers'] = System::baseUrl() . '/followers/' . $user['nickname'];
return $tags;
}
- private static function fetchConversationURLForItem($item)
- {
- $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']]);
$data['inReplyTo'] = null;
}
- $data['uuid'] = $item['guid'];
+ $data['diaspora:guid'] = $item['guid'];
$data['published'] = DateTimeFormat::utc($item["created"]."+00:00", DateTimeFormat::ATOM);
if ($item["created"] != $item["edited"]) {
$data['attributedTo'] = $item['author-link'];
$data['actor'] = $item['author-link'];
$data['sensitive'] = false; // - Query NSFW
- $data['conversation'] = self::fetchConversationURLForItem($item);
$data['context'] = self::fetchContextURLForItem($item);
if (!empty($item['title'])) {
$profile = ['network' => Protocol::ACTIVITYPUB];
$profile['nick'] = $apcontact['nick'];
$profile['name'] = $apcontact['name'];
- $profile['guid'] = $apcontact['uuid'];
+ $profile['guid'] = $apcontact['diaspora:guid'];
$profile['url'] = $apcontact['url'];
$profile['addr'] = $apcontact['addr'];
$profile['alias'] = $apcontact['alias'];
// Data in Notes:
- // To-Do?
- // emoji, atomUri, inReplyToAtomUri
-
// Unhandled
// contentMap, announcement_count, announcements, context_id, likes, like_count
// inReplyToStatusId, shares, quoteUrl, statusnetConversationId
$item['uri'] = $activity['id'];
$item['created'] = $activity['published'];
$item['edited'] = $activity['updated'];
- $item['guid'] = $activity['uuid'];
+ $item['guid'] = $activity['diaspora:guid'];
$item['title'] = HTML::toBBCode($activity['name']);
$item['content-warning'] = HTML::toBBCode($activity['summary']);
$item['body'] = self::convertMentions(HTML::toBBCode($activity['content']));
$author = self::myHandle($owner);
$message = ["author" => $author,
- "guid" => System::createGUID(32),
+ "guid" => System::UUID(),
"parent_type" => "Post",
"parent_guid" => $item["guid"]];