DBA::delete('item-delivery-data', ['iid' => $item['id']]);
- //if (!empty($item['iaid']) && !self::exists(['iaid' => $item['iaid'], 'deleted' => false])) {
- // DBA::delete('item-activity', ['id' => $item['iaid']], ['cascade' => false]);
- //}
+ // We don't delete the item-activity here, since we need some of the data for ActivityPub
+
if (!empty($item['icid']) && !self::exists(['icid' => $item['icid'], 'deleted' => false])) {
DBA::delete('item-content', ['id' => $item['icid']], ['cascade' => false]);
}
if ($notify) {
// We have to avoid duplicates. So we create the GUID in form of a hash of the plink or uri.
// We add the hash of our own host because our host is the original creator of the post.
- $prefix_host = get_app()->get_hostname();
+ $prefix_host = get_app()->getHostName();
} else {
$prefix_host = '';
} elseif (!empty($item['uri'])) {
$guid = self::guidFromUri($item['uri'], $prefix_host);
} else {
- $guid = System::createGUID(32, hash('crc32', $prefix_host));
+ $guid = System::createUUID(hash('crc32', $prefix_host));
}
return $guid;
} else {
// This shouldn't happen.
logger('Could not insert activity for URI ' . $item['uri'] . ' - should not happen');
+ Lock::release('item_insert_activity');
return false;
}
if ($locked) {
public static function newURI($uid, $guid = "")
{
if ($guid == "") {
- $guid = System::createGUID(32);
+ $guid = System::createUUID();
}
- return self::getApp()->get_baseurl() . '/object/' . $guid;
+ return self::getApp()->getBaseURL() . '/objects/' . $guid;
}
/**
}
// Prevent to forward already forwarded posts
- if ($datarray["app"] == $a->get_hostname()) {
+ if ($datarray["app"] == $a->getHostName()) {
logger('Already forwarded (second test)', LOGGER_DEBUG);
return false;
}
}
if ($contact['network'] != Protocol::FEED) {
- $datarray["guid"] = System::createGUID(32);
+ $datarray["guid"] = System::createUUID();
unset($datarray["plink"]);
$datarray["uri"] = self::newURI($contact['uid'], $datarray["guid"]);
$datarray["parent-uri"] = $datarray["uri"];
return true;
}
- $objtype = $item['resource-id'] ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE ;
+ $objtype = $item['resource-id'] ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE;
$new_item = [
- 'guid' => System::createGUID(32),
+ 'guid' => System::createUUID(),
'uri' => self::newURI($item['uid']),
'uid' => $item['uid'],
'contact-id' => $item_contact_id,
'parent' => $item['id'],
'parent-uri' => $item['uri'],
'thr-parent' => $item['uri'],
- 'owner-id' => $item['owner-id'],
+ 'owner-id' => $author_id,
'author-id' => $author_id,
'body' => $activity,
'verb' => $activity,