mirror of
https://github.com/friendica/friendica
synced 2024-12-23 16:00:16 +00:00
Merge pull request #9803 from annando/post
New post class in the rest of the classes
This commit is contained in:
commit
c1226bff07
15 changed files with 33 additions and 20 deletions
|
@ -27,6 +27,7 @@ use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\Verb;
|
use Friendica\Model\Verb;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Protocol\Activity;
|
use Friendica\Protocol\Activity;
|
||||||
|
@ -60,7 +61,7 @@ class Status extends BaseFactory
|
||||||
*/
|
*/
|
||||||
public function createFromUriId(int $uriId, $uid = 0)
|
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) {
|
if (!$item) {
|
||||||
throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . 'not found' . ($uid ? ' for user ' . $uid : '.'));
|
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)) {
|
if ($item['vid'] == Verb::getID(Activity::ANNOUNCE)) {
|
||||||
$reshare = $this->createFromUriId($item['thr-parent-id'], $uid)->toArray();
|
$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['title'] = $reshared_item['title'] ?? $item['title'];
|
||||||
$item['body'] = $reshared_item['body'] ?? $item['body'];
|
$item['body'] = $reshared_item['body'] ?? $item['body'];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -40,7 +40,7 @@ class Source extends BaseAdmin
|
||||||
$item_id = '';
|
$item_id = '';
|
||||||
$terms = [];
|
$terms = [];
|
||||||
if (!empty($guid)) {
|
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) {
|
if ($item) {
|
||||||
$conversation = Model\Conversation::getByItemUri($item['uri']);
|
$conversation = Model\Conversation::getByItemUri($item['uri']);
|
||||||
|
|
|
@ -35,6 +35,7 @@ use Friendica\Core\Session;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
|
|
||||||
|
@ -237,7 +238,7 @@ class Community extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_GET['item'])) {
|
if (!empty($_GET['item'])) {
|
||||||
$item = Item::selectFirst(['parent'], ['id' => $_GET['item']]);
|
$item = Post::selectFirst(['parent'], ['id' => $_GET['item']]);
|
||||||
self::$item_id = $item['parent'] ?? 0;
|
self::$item_id = $item['parent'] ?? 0;
|
||||||
} else {
|
} else {
|
||||||
self::$item_id = 0;
|
self::$item_id = 0;
|
||||||
|
|
|
@ -17,6 +17,7 @@ use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Module\Contact as ModuleContact;
|
use Friendica\Module\Contact as ModuleContact;
|
||||||
|
@ -215,7 +216,7 @@ class Network extends BaseModule
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$unseen = Item::exists($condition);
|
$unseen = Post::exists($condition);
|
||||||
|
|
||||||
if ($unseen) {
|
if ($unseen) {
|
||||||
/// @todo handle huge "unseen" updates in the background to avoid timeout errors
|
/// @todo handle huge "unseen" updates in the background to avoid timeout errors
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Module\Debug;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +47,7 @@ class ItemBody extends BaseModule
|
||||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.'));
|
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 (!empty($item)) {
|
||||||
if (DI::mode()->isAjax()) {
|
if (DI::mode()->isAjax()) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Protocol\Diaspora;
|
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'
|
'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]];
|
$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)) {
|
if (empty($item)) {
|
||||||
$condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
|
$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"])) {
|
if (!empty($item["author-link"])) {
|
||||||
$parts = parse_url($item["author-link"]);
|
$parts = parse_url($item["author-link"]);
|
||||||
if (empty($parts["scheme"]) || empty($parts["host"])) {
|
if (empty($parts["scheme"]) || empty($parts["host"])) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Core\Session;
|
use Friendica\Core\Session;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ class Like extends BaseModule
|
||||||
$itemId = (($app->argc > 1) ? Strings::escapeTags(trim($app->argv[1])) : 0);
|
$itemId = (($app->argc > 1) ? Strings::escapeTags(trim($app->argv[1])) : 0);
|
||||||
|
|
||||||
if (in_array($verb, ['announce', 'unannounce'])) {
|
if (in_array($verb, ['announce', 'unannounce'])) {
|
||||||
$item = Item::selectFirst(['network'], ['id' => $itemId]);
|
$item = Post::selectFirst(['network'], ['id' => $itemId]);
|
||||||
if ($item['network'] == Protocol::DIASPORA) {
|
if ($item['network'] == Protocol::DIASPORA) {
|
||||||
self::performDiasporaReshare($itemId);
|
self::performDiasporaReshare($itemId);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +87,7 @@ class Like extends BaseModule
|
||||||
private static function performDiasporaReshare(int $itemId)
|
private static function performDiasporaReshare(int $itemId)
|
||||||
{
|
{
|
||||||
$fields = ['uri-id', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink'];
|
$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'] == '')) {
|
if (!DBA::isResult($item) || ($item['body'] == '')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
use Friendica\Util\HTTPSignature;
|
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]]);
|
['uri-id' => $itemuri['id']], ['order' => ['origin' => true]]);
|
||||||
|
|
||||||
if (!DBA::isResult($item)) {
|
if (!DBA::isResult($item)) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +28,7 @@ class PermissionTooltip extends \Friendica\BaseModule
|
||||||
$condition = ['id' => $referenceId];
|
$condition = ['id' => $referenceId];
|
||||||
if ($type == 'item') {
|
if ($type == 'item') {
|
||||||
$fields = ['uid', 'psid', 'private'];
|
$fields = ['uid', 'psid', 'private'];
|
||||||
$model = Item::selectFirst($fields, $condition);
|
$model = Post::selectFirst($fields, $condition);
|
||||||
} else {
|
} else {
|
||||||
$fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
|
$fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
|
||||||
$model = DBA::selectFirst($type, $fields, $condition);
|
$model = DBA::selectFirst($type, $fields, $condition);
|
||||||
|
|
|
@ -30,6 +30,7 @@ use Friendica\Core\Session;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\Post\Category;
|
use Friendica\Model\Post\Category;
|
||||||
use Friendica\Model\Profile as ProfileModel;
|
use Friendica\Model\Profile as ProfileModel;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -206,7 +207,7 @@ class Status extends BaseProfile
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($is_owner) {
|
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) {
|
if ($unseen) {
|
||||||
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
|
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
|
@ -314,7 +315,7 @@ class Acl extends BaseModule
|
||||||
|
|
||||||
if ($conv_id) {
|
if ($conv_id) {
|
||||||
// In multi threaded posts the conv_id is not the parent of the whole thread
|
// 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)) {
|
if (DBA::isResult($parent_item)) {
|
||||||
$conv_id = $parent_item['parent'];
|
$conv_id = $parent_item['parent'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\ItemContent;
|
use Friendica\Model\ItemContent;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\Tag;
|
use Friendica\Model\Tag;
|
||||||
use Friendica\Module\BaseSearch;
|
use Friendica\Module\BaseSearch;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
|
@ -288,7 +289,7 @@ class Index extends BaseSearch
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($item_id)) {
|
if (!empty($item_id)) {
|
||||||
$item = Item::selectFirst(['guid'], ['id' => $item_id]);
|
$item = Post::selectFirst(['guid'], ['id' => $item_id]);
|
||||||
if (DBA::isResult($item)) {
|
if (DBA::isResult($item)) {
|
||||||
DI::baseUrl()->redirect('display/' . $item['guid']);
|
DI::baseUrl()->redirect('display/' . $item['guid']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace Friendica\Module\Update;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Module\Conversation\Network as NetworkModule;
|
use Friendica\Module\Conversation\Network as NetworkModule;
|
||||||
|
|
||||||
class Network extends 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 (!DI::pConfig()->get($profile_uid, 'system', 'no_auto_update') || ($_GET['force'] == 1)) {
|
||||||
if (!empty($_GET['item'])) {
|
if (!empty($_GET['item'])) {
|
||||||
$item = Item::selectFirst(['parent'], ['id' => $_GET['item']]);
|
$item = Post::selectFirst(['parent'], ['id' => $_GET['item']]);
|
||||||
$parent = $item['parent'] ?? 0;
|
$parent = $item['parent'] ?? 0;
|
||||||
} else {
|
} else {
|
||||||
$parent = 0;
|
$parent = 0;
|
||||||
|
|
|
@ -22,12 +22,12 @@
|
||||||
namespace Friendica\Module\Update;
|
namespace Friendica\Module\Update;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Content\Pager;
|
|
||||||
use Friendica\Core\Session;
|
use Friendica\Core\Session;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\Profile as ProfileModel;
|
use Friendica\Model\Profile as ProfileModel;
|
||||||
use Friendica\Network\HTTPException\ForbiddenException;
|
use Friendica\Network\HTTPException\ForbiddenException;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
@ -111,7 +111,7 @@ class Profile extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($is_owner) {
|
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) {
|
if ($unseen) {
|
||||||
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
|
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Model\Post as PostModel;
|
||||||
use Friendica\Model\Tag;
|
use Friendica\Model\Tag;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Protocol\Activity;
|
use Friendica\Protocol\Activity;
|
||||||
|
@ -212,7 +213,7 @@ class Post
|
||||||
if (!$origin) {
|
if (!$origin) {
|
||||||
/// @todo This shouldn't be done as query here, but better during the data creation.
|
/// @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.
|
// 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 = PostModel::selectFirst(['origin'], ['id' => $item['parent']]);
|
||||||
if (DBA::isResult($parent)) {
|
if (DBA::isResult($parent)) {
|
||||||
$origin = $parent['origin'];
|
$origin = $parent['origin'];
|
||||||
}
|
}
|
||||||
|
@ -875,7 +876,7 @@ class Post
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = Item::selectFirst(['author-addr', 'uri-id'], ['id' => $this->getId()]);
|
$item = PostModel::selectFirst(['author-addr', 'uri-id'], ['id' => $this->getId()]);
|
||||||
if (!DBA::isResult($item) || empty($item['author-addr'])) {
|
if (!DBA::isResult($item) || empty($item['author-addr'])) {
|
||||||
// Should not happen
|
// Should not happen
|
||||||
return '';
|
return '';
|
||||||
|
|
Loading…
Reference in a new issue