X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FItem.php;h=19ab371d7c0f9581f86e0709fa45e12f81c5bdfc;hb=ee32459358c6ca818f368e55e49147e4dcdcc690;hp=68ebc690e8f7646c282f87f5e4a27bb1a84d6e9e;hpb=6a8ebc8639507404be07bb7d6fd5a37189e46563;p=friendica.git diff --git a/src/Model/Item.php b/src/Model/Item.php index 68ebc690e8..19ab371d7c 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1081,9 +1081,8 @@ class Item extends BaseObject 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]); } @@ -1205,7 +1204,7 @@ class Item extends BaseObject } 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; @@ -1936,6 +1935,7 @@ class Item extends BaseObject } 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) { @@ -2071,6 +2071,7 @@ class Item extends BaseObject $users = []; + /// @todo add a field "pcid" in the contact table that referrs to the public contact id. $owner = DBA::selectFirst('contact', ['url', 'nurl', 'alias'], ['id' => $parent['owner-id']]); if (!DBA::isResult($owner)) { return; @@ -2110,43 +2111,7 @@ class Item extends BaseObject } DBA::close($contacts); } -/* - - $condition = ["`nurl` IN (SELECT `nurl` FROM `contact` WHERE `id` = ?) AND `uid` != 0 AND NOT `blocked` AND `rel` IN (?, ?)", - $parent['owner-id'], Contact::SHARING, Contact::FRIEND]; - - $contacts = DBA::select('contact', ['uid'], $condition); - - while ($contact = DBA::fetch($contacts)) { - $users[$contact['uid']] = $contact['uid']; - } - - DBA::close($contacts); - - // And the same with the alias in the user contacts - $condition = ["`alias` IN (SELECT `url` FROM `contact` WHERE `id` = ?) AND `uid` != 0 AND NOT `blocked` AND `rel` IN (?, ?)", - $parent['owner-id'], Contact::SHARING, Contact::FRIEND]; - - $contacts = DBA::select('contact', ['uid'], $condition); - while ($contact = DBA::fetch($contacts)) { - $users[$contact['uid']] = $contact['uid']; - } - - DBA::close($contacts); - - // And vice versa - $condition = ["`url` IN (SELECT `alias` FROM `contact` WHERE `id` = ?) AND `uid` != 0 AND NOT `blocked` AND `rel` IN (?, ?)", - $parent['owner-id'], Contact::SHARING, Contact::FRIEND]; - - $contacts = DBA::select('contact', ['uid'], $condition); - - while ($contact = DBA::fetch($contacts)) { - $users[$contact['uid']] = $contact['uid']; - } - - DBA::close($contacts); -*/ $origin_uid = 0; if ($item['uri'] != $item['parent-uri']) { @@ -2393,10 +2358,10 @@ class Item extends BaseObject 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()->get_baseurl() . '/objects/' . $guid; } /** @@ -2720,7 +2685,7 @@ class Item extends BaseObject } 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"]; @@ -2886,7 +2851,7 @@ class Item extends BaseObject } // returns an array of contact-ids that are allowed to see this object - private static function enumeratePermissions($obj) + public static function enumeratePermissions($obj) { $allow_people = expand_acl($obj['allow_cid']); $allow_groups = Group::expand(expand_acl($obj['allow_gid'])); @@ -3149,7 +3114,7 @@ class Item extends BaseObject $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,