From 2fa692bcce820edd25667a51113167c24ceff251 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 16 Jan 2021 04:16:09 +0000 Subject: [PATCH] New post class in the rest of the classes --- src/Factory/Api/Mastodon/Status.php | 5 +++-- src/Module/Admin/Item/Source.php | 2 +- src/Module/Conversation/Community.php | 3 ++- src/Module/Conversation/Network.php | 3 ++- src/Module/Debug/ItemBody.php | 3 ++- src/Module/Diaspora/Fetch.php | 5 +++-- src/Module/Like.php | 5 +++-- src/Module/Objects.php | 3 ++- src/Module/PermissionTooltip.php | 3 ++- src/Module/Profile/Status.php | 3 ++- src/Module/Search/Acl.php | 3 ++- src/Module/Search/Index.php | 3 ++- src/Module/Update/Network.php | 3 ++- src/Module/Update/Profile.php | 4 ++-- src/Object/Post.php | 5 +++-- 15 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/Factory/Api/Mastodon/Status.php b/src/Factory/Api/Mastodon/Status.php index e1c11de6cb..a75ab2ed3c 100644 --- a/src/Factory/Api/Mastodon/Status.php +++ b/src/Factory/Api/Mastodon/Status.php @@ -27,6 +27,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Model\Verb; use Friendica\Network\HTTPException; use Friendica\Protocol\Activity; @@ -60,7 +61,7 @@ class Status extends BaseFactory */ public function createFromUriId(int $uriId, $uid = 0) { - $item = Item::selectFirst([], ['uri-id' => $uriId, 'uid' => $uid]); + $item = Post::selectFirst([], ['uri-id' => $uriId, 'uid' => $uid]); if (!$item) { throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . 'not found' . ($uid ? ' for user ' . $uid : '.')); } @@ -93,7 +94,7 @@ class Status extends BaseFactory if ($item['vid'] == Verb::getID(Activity::ANNOUNCE)) { $reshare = $this->createFromUriId($item['thr-parent-id'], $uid)->toArray(); - $reshared_item = Item::selectFirst(['title', 'body'], ['uri-id' => $item['thr-parent-id'], 'uid' => $uid]); + $reshared_item = Post::selectFirst(['title', 'body'], ['uri-id' => $item['thr-parent-id'], 'uid' => $uid]); $item['title'] = $reshared_item['title'] ?? $item['title']; $item['body'] = $reshared_item['body'] ?? $item['body']; } else { diff --git a/src/Module/Admin/Item/Source.php b/src/Module/Admin/Item/Source.php index 6e917eb16c..83b57abbfe 100644 --- a/src/Module/Admin/Item/Source.php +++ b/src/Module/Admin/Item/Source.php @@ -40,7 +40,7 @@ class Source extends BaseAdmin $item_id = ''; $terms = []; if (!empty($guid)) { - $item = Model\Item::selectFirst(['id', 'uri-id', 'guid', 'uri'], ['guid' => $guid]); + $item = Model\Post::selectFirst(['id', 'uri-id', 'guid', 'uri'], ['guid' => $guid]); if ($item) { $conversation = Model\Conversation::getByItemUri($item['uri']); diff --git a/src/Module/Conversation/Community.php b/src/Module/Conversation/Community.php index a960bf5e0e..cbcb508707 100644 --- a/src/Module/Conversation/Community.php +++ b/src/Module/Conversation/Community.php @@ -35,6 +35,7 @@ use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Model\User; use Friendica\Network\HTTPException; @@ -237,7 +238,7 @@ class Community extends BaseModule } if (!empty($_GET['item'])) { - $item = Item::selectFirst(['parent'], ['id' => $_GET['item']]); + $item = Post::selectFirst(['parent'], ['id' => $_GET['item']]); self::$item_id = $item['parent'] ?? 0; } else { self::$item_id = 0; diff --git a/src/Module/Conversation/Network.php b/src/Module/Conversation/Network.php index ca8e8c89c2..f3a60b48f8 100644 --- a/src/Module/Conversation/Network.php +++ b/src/Module/Conversation/Network.php @@ -17,6 +17,7 @@ use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Model\Profile; use Friendica\Model\User; use Friendica\Module\Contact as ModuleContact; @@ -215,7 +216,7 @@ class Network extends BaseModule return; } - $unseen = Item::exists($condition); + $unseen = Post::exists($condition); if ($unseen) { /// @todo handle huge "unseen" updates in the background to avoid timeout errors diff --git a/src/Module/Debug/ItemBody.php b/src/Module/Debug/ItemBody.php index c6530b927a..dea8bec131 100644 --- a/src/Module/Debug/ItemBody.php +++ b/src/Module/Debug/ItemBody.php @@ -24,6 +24,7 @@ namespace Friendica\Module\Debug; use Friendica\BaseModule; use Friendica\DI; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Network\HTTPException; /** @@ -46,7 +47,7 @@ class ItemBody extends BaseModule throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.')); } - $item = Item::selectFirst(['body'], ['uid' => local_user(), 'id' => $itemId]); + $item = Post::selectFirst(['body'], ['uid' => local_user(), 'id' => $itemId]); if (!empty($item)) { if (DI::mode()->isAjax()) { diff --git a/src/Module/Diaspora/Fetch.php b/src/Module/Diaspora/Fetch.php index 67f6fd0f7e..04f38abbc6 100644 --- a/src/Module/Diaspora/Fetch.php +++ b/src/Module/Diaspora/Fetch.php @@ -26,6 +26,7 @@ use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\DI; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Model\User; use Friendica\Network\HTTPException; use Friendica\Protocol\Diaspora; @@ -55,10 +56,10 @@ class Fetch extends BaseModule 'event-id', 'resource-id', 'author-link', 'author-avatar', 'author-name', 'plink', 'owner-link', 'uri-id' ]; $condition = ['wall' => true, 'private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]]; - $item = Item::selectFirst($fields, $condition); + $item = Post::selectFirst($fields, $condition); if (empty($item)) { $condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]]; - $item = Item::selectFirst(['author-link'], $condition); + $item = Post::selectFirst(['author-link'], $condition); if (!empty($item["author-link"])) { $parts = parse_url($item["author-link"]); if (empty($parts["scheme"]) || empty($parts["host"])) { diff --git a/src/Module/Like.php b/src/Module/Like.php index 4a6831b738..8d699be5e5 100644 --- a/src/Module/Like.php +++ b/src/Module/Like.php @@ -29,6 +29,7 @@ use Friendica\DI; use Friendica\Model\Item; use Friendica\Core\Session; use Friendica\Database\DBA; +use Friendica\Model\Post; use Friendica\Network\HTTPException; use Friendica\Util\Strings; @@ -55,7 +56,7 @@ class Like extends BaseModule $itemId = (($app->argc > 1) ? Strings::escapeTags(trim($app->argv[1])) : 0); if (in_array($verb, ['announce', 'unannounce'])) { - $item = Item::selectFirst(['network'], ['id' => $itemId]); + $item = Post::selectFirst(['network'], ['id' => $itemId]); if ($item['network'] == Protocol::DIASPORA) { self::performDiasporaReshare($itemId); } @@ -86,7 +87,7 @@ class Like extends BaseModule private static function performDiasporaReshare(int $itemId) { $fields = ['uri-id', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink']; - $item = Item::selectFirst($fields, ['id' => $itemId, 'private' => [Item::PUBLIC, Item::UNLISTED]]); + $item = Post::selectFirst($fields, ['id' => $itemId, 'private' => [Item::PUBLIC, Item::UNLISTED]]); if (!DBA::isResult($item) || ($item['body'] == '')) { return; } diff --git a/src/Module/Objects.php b/src/Module/Objects.php index cbe2e53fe0..18830339fb 100644 --- a/src/Module/Objects.php +++ b/src/Module/Objects.php @@ -28,6 +28,7 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Network\HTTPException; use Friendica\Protocol\ActivityPub; use Friendica\Util\HTTPSignature; @@ -68,7 +69,7 @@ class Objects extends BaseModule } } - $item = Item::selectFirst(['id', 'uid', 'origin', 'author-link', 'changed', 'private', 'psid', 'gravity'], + $item = Post::selectFirst(['id', 'uid', 'origin', 'author-link', 'changed', 'private', 'psid', 'gravity'], ['uri-id' => $itemuri['id']], ['order' => ['origin' => true]]); if (!DBA::isResult($item)) { diff --git a/src/Module/PermissionTooltip.php b/src/Module/PermissionTooltip.php index 3e760ef1e0..b9429fce23 100644 --- a/src/Module/PermissionTooltip.php +++ b/src/Module/PermissionTooltip.php @@ -7,6 +7,7 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; use Friendica\Model\Group; +use Friendica\Model\Post; use Friendica\Network\HTTPException; /** @@ -27,7 +28,7 @@ class PermissionTooltip extends \Friendica\BaseModule $condition = ['id' => $referenceId]; if ($type == 'item') { $fields = ['uid', 'psid', 'private']; - $model = Item::selectFirst($fields, $condition); + $model = Post::selectFirst($fields, $condition); } else { $fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']; $model = DBA::selectFirst($type, $fields, $condition); diff --git a/src/Module/Profile/Status.php b/src/Module/Profile/Status.php index cadb9aa4b8..b937a2a4cb 100644 --- a/src/Module/Profile/Status.php +++ b/src/Module/Profile/Status.php @@ -30,6 +30,7 @@ use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Model\Post\Category; use Friendica\Model\Profile as ProfileModel; use Friendica\Model\User; @@ -206,7 +207,7 @@ class Status extends BaseProfile } if ($is_owner) { - $unseen = Item::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]); + $unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]); if ($unseen) { Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]); } diff --git a/src/Module/Search/Acl.php b/src/Module/Search/Acl.php index e8b6f357d9..6fcbfa3fd7 100644 --- a/src/Module/Search/Acl.php +++ b/src/Module/Search/Acl.php @@ -31,6 +31,7 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Network\HTTPException; use Friendica\Util\Strings; @@ -314,7 +315,7 @@ class Acl extends BaseModule if ($conv_id) { // In multi threaded posts the conv_id is not the parent of the whole thread - $parent_item = Item::selectFirst(['parent'], ['id' => $conv_id]); + $parent_item = Post::selectFirst(['parent'], ['id' => $conv_id]); if (DBA::isResult($parent_item)) { $conv_id = $parent_item['parent']; } diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 67534a61ab..f50b68c2aa 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -35,6 +35,7 @@ use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; use Friendica\Model\ItemContent; +use Friendica\Model\Post; use Friendica\Model\Tag; use Friendica\Module\BaseSearch; use Friendica\Network\HTTPException; @@ -288,7 +289,7 @@ class Index extends BaseSearch } if (!empty($item_id)) { - $item = Item::selectFirst(['guid'], ['id' => $item_id]); + $item = Post::selectFirst(['guid'], ['id' => $item_id]); if (DBA::isResult($item)) { DI::baseUrl()->redirect('display/' . $item['guid']); } diff --git a/src/Module/Update/Network.php b/src/Module/Update/Network.php index 81bdf834e4..bcaa11fd49 100644 --- a/src/Module/Update/Network.php +++ b/src/Module/Update/Network.php @@ -5,6 +5,7 @@ namespace Friendica\Module\Update; use Friendica\Core\System; use Friendica\DI; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Module\Conversation\Network as NetworkModule; class Network extends NetworkModule @@ -23,7 +24,7 @@ class Network extends NetworkModule if (!DI::pConfig()->get($profile_uid, 'system', 'no_auto_update') || ($_GET['force'] == 1)) { if (!empty($_GET['item'])) { - $item = Item::selectFirst(['parent'], ['id' => $_GET['item']]); + $item = Post::selectFirst(['parent'], ['id' => $_GET['item']]); $parent = $item['parent'] ?? 0; } else { $parent = 0; diff --git a/src/Module/Update/Profile.php b/src/Module/Update/Profile.php index 38ef3b09e0..56e86feb36 100644 --- a/src/Module/Update/Profile.php +++ b/src/Module/Update/Profile.php @@ -22,12 +22,12 @@ namespace Friendica\Module\Update; use Friendica\BaseModule; -use Friendica\Content\Pager; use Friendica\Core\Session; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Model\Profile as ProfileModel; use Friendica\Network\HTTPException\ForbiddenException; use Friendica\Util\DateTimeFormat; @@ -111,7 +111,7 @@ class Profile extends BaseModule } if ($is_owner) { - $unseen = Item::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]); + $unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]); if ($unseen) { Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]); } diff --git a/src/Object/Post.php b/src/Object/Post.php index 21b2e4ce14..4c838f7714 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -33,6 +33,7 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; +use Friendica\Model\Post as ModelPost; use Friendica\Model\Tag; use Friendica\Model\User; use Friendica\Protocol\Activity; @@ -212,7 +213,7 @@ class Post if (!$origin) { /// @todo This shouldn't be done as query here, but better during the data creation. // it is now done here, since during the RC phase we shouldn't make to intense changes. - $parent = Item::selectFirst(['origin'], ['id' => $item['parent']]); + $parent = ModelPost::selectFirst(['origin'], ['id' => $item['parent']]); if (DBA::isResult($parent)) { $origin = $parent['origin']; } @@ -875,7 +876,7 @@ class Post return ''; } - $item = Item::selectFirst(['author-addr', 'uri-id'], ['id' => $this->getId()]); + $item = ModelPost::selectFirst(['author-addr', 'uri-id'], ['id' => $this->getId()]); if (!DBA::isResult($item) || empty($item['author-addr'])) { // Should not happen return '';