Post class introduced in "mod" and "include"
This commit is contained in:
@@ -41,6 +41,7 @@ use Friendica\Model\Item;
|
||||
use Friendica\Model\Mail;
|
||||
use Friendica\Model\Notify;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Model\UserItem;
|
||||
use Friendica\Model\Verb;
|
||||
@@ -1365,7 +1366,7 @@ function api_get_last_status($ownerId, $uid)
|
||||
*/
|
||||
function api_get_item(array $condition)
|
||||
{
|
||||
$item = Item::selectFirst(Item::DISPLAY_FIELDLIST, $condition, ['order' => ['id' => true]]);
|
||||
$item = Post::selectFirst(Item::DISPLAY_FIELDLIST, $condition, ['order' => ['id' => true]]);
|
||||
|
||||
return $item;
|
||||
}
|
||||
@@ -1673,7 +1674,7 @@ function api_statuses_home_timeline($type)
|
||||
}
|
||||
|
||||
if (!empty($idarray)) {
|
||||
$unseen = Item::exists(['unseen' => true, 'id' => $idarray]);
|
||||
$unseen = Post::exists(['unseen' => true, 'id' => $idarray]);
|
||||
if ($unseen) {
|
||||
Item::update(['unseen' => false], ['unseen' => true, 'id' => $idarray]);
|
||||
}
|
||||
@@ -1880,12 +1881,12 @@ function api_statuses_show($type)
|
||||
$conversation = !empty($_REQUEST['conversation']);
|
||||
|
||||
// try to fetch the item for the local user - or the public item, if there is no local one
|
||||
$uri_item = Item::selectFirst(['uri'], ['id' => $id]);
|
||||
$uri_item = Post::selectFirst(['uri'], ['id' => $id]);
|
||||
if (!DBA::isResult($uri_item)) {
|
||||
throw new BadRequestException("There is no status with this id.");
|
||||
}
|
||||
|
||||
$item = Item::selectFirst(['id'], ['uri' => $uri_item['uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
||||
$item = Post::selectFirst(['id'], ['uri' => $uri_item['uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
throw new BadRequestException("There is no status with this id.");
|
||||
}
|
||||
@@ -1963,12 +1964,12 @@ function api_conversation_show($type)
|
||||
Logger::info(API_LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]);
|
||||
|
||||
// try to fetch the item for the local user - or the public item, if there is no local one
|
||||
$item = Item::selectFirst(['parent-uri'], ['id' => $id]);
|
||||
$item = Post::selectFirst(['parent-uri'], ['id' => $id]);
|
||||
if (!DBA::isResult($item)) {
|
||||
throw new BadRequestException("There is no status with this id.");
|
||||
}
|
||||
|
||||
$parent = Item::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
||||
$parent = Post::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
||||
if (!DBA::isResult($parent)) {
|
||||
throw new BadRequestException("There is no status with this id.");
|
||||
}
|
||||
@@ -2040,7 +2041,7 @@ function api_statuses_repeat($type)
|
||||
Logger::log('API: api_statuses_repeat: '.$id);
|
||||
|
||||
$fields = ['uri-id', 'network', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink'];
|
||||
$item = Item::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]);
|
||||
$item = Post::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]);
|
||||
|
||||
if (DBA::isResult($item) && $item['body'] != "") {
|
||||
if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::TWITTER])) {
|
||||
@@ -4879,7 +4880,7 @@ function prepare_photo_data($type, $scale, $photo_id)
|
||||
|
||||
// retrieve item element for getting activities (like, dislike etc.) related to photo
|
||||
$condition = ['uid' => api_user(), 'resource-id' => $photo_id, 'type' => 'photo'];
|
||||
$item = Item::selectFirst(['id', 'uid', 'uri', 'parent', 'allow_cid', 'deny_cid', 'allow_gid', 'deny_gid'], $condition);
|
||||
$item = Post::selectFirst(['id', 'uid', 'uri', 'parent', 'allow_cid', 'deny_cid', 'allow_gid', 'deny_gid'], $condition);
|
||||
if (!DBA::isResult($item)) {
|
||||
throw new NotFoundException('Photo-related item not found.');
|
||||
}
|
||||
@@ -5075,7 +5076,7 @@ function api_share_as_retweet(&$item)
|
||||
}
|
||||
|
||||
if (!empty($condition)) {
|
||||
$original_item = Item::selectFirst([], $condition);
|
||||
$original_item = Post::selectFirst([], $condition);
|
||||
if (DBA::isResult($original_item)) {
|
||||
$reshared_item = array_merge($reshared_item, $original_item);
|
||||
}
|
||||
@@ -5102,7 +5103,7 @@ function api_in_reply_to($item)
|
||||
$in_reply_to['screen_name'] = null;
|
||||
|
||||
if (($item['thr-parent'] != $item['uri']) && ($item['gravity'] != GRAVITY_PARENT)) {
|
||||
$parent = Item::selectFirst(['id'], ['uid' => $item['uid'], 'uri' => $item['thr-parent']]);
|
||||
$parent = Post::selectFirst(['id'], ['uid' => $item['uid'], 'uri' => $item['thr-parent']]);
|
||||
if (DBA::isResult($parent)) {
|
||||
$in_reply_to['status_id'] = intval($parent['id']);
|
||||
} else {
|
||||
@@ -5112,7 +5113,7 @@ function api_in_reply_to($item)
|
||||
$in_reply_to['status_id_str'] = (string) intval($in_reply_to['status_id']);
|
||||
|
||||
$fields = ['author-nick', 'author-name', 'author-id', 'author-link'];
|
||||
$parent = Item::selectFirst($fields, ['id' => $in_reply_to['status_id']]);
|
||||
$parent = Post::selectFirst($fields, ['id' => $in_reply_to['status_id']]);
|
||||
|
||||
if (DBA::isResult($parent)) {
|
||||
$in_reply_to['screen_name'] = (($parent['author-nick']) ? $parent['author-nick'] : $parent['author-name']);
|
||||
|
||||
@@ -33,10 +33,11 @@ use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\Verb;
|
||||
use Friendica\Object\Post;
|
||||
use Friendica\Object\Post as ObjectPost;
|
||||
use Friendica\Object\Thread;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Util\Crypto;
|
||||
@@ -201,7 +202,7 @@ function localize_item(&$item)
|
||||
if ($activity->match($item['verb'], Activity::TAG)) {
|
||||
$fields = ['author-id', 'author-link', 'author-name', 'author-network',
|
||||
'verb', 'object-type', 'resource-id', 'body', 'plink'];
|
||||
$obj = Item::selectFirst($fields, ['uri' => $item['parent-uri']]);
|
||||
$obj = Post::selectFirst($fields, ['uri' => $item['parent-uri']]);
|
||||
if (!DBA::isResult($obj)) {
|
||||
return;
|
||||
}
|
||||
@@ -677,7 +678,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
|
||||
$item['pagedrop'] = $page_dropping;
|
||||
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
$item_object = new Post($item);
|
||||
$item_object = new ObjectPost($item);
|
||||
$conv->addParent($item_object);
|
||||
}
|
||||
}
|
||||
@@ -871,7 +872,7 @@ function conversation_fetch_items(array $parent, array $items, array $condition,
|
||||
$condition[0] .= " AND NOT `author`.`hidden`";
|
||||
}
|
||||
|
||||
$thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity', 'post-type']), $condition, $params);
|
||||
$thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['pinned', 'contact-uid', 'gravity', 'post-type']), $condition, $params);
|
||||
|
||||
$comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false, $activity);
|
||||
|
||||
@@ -1041,7 +1042,7 @@ function builtin_activity_puller(array $activity, array &$conv_responses)
|
||||
}
|
||||
|
||||
// Skip when the causer of the parent is the same than the author of the announce
|
||||
if (($verb == Activity::ANNOUNCE) && Item::exists(['uri' => $activity['thr-parent'],
|
||||
if (($verb == Activity::ANNOUNCE) && Post::exists(['uri' => $activity['thr-parent'],
|
||||
'uid' => $activity['uid'], 'causer-id' => $activity['author-id'], 'gravity' => GRAVITY_PARENT])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\ItemContent;
|
||||
use Friendica\Model\Notify;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Model\UserItem;
|
||||
use Friendica\Protocol\Activity;
|
||||
@@ -518,7 +519,7 @@ function notification($params)
|
||||
Logger::log('sending notification email');
|
||||
|
||||
if (isset($params['parent']) && (intval($params['parent']) != 0)) {
|
||||
$parent = Item::selectFirst(['guid'], ['id' => $params['parent']]);
|
||||
$parent = Post::selectFirst(['guid'], ['id' => $params['parent']]);
|
||||
$message_id = "<" . $parent['guid'] . "@" . gethostname() . ">";
|
||||
|
||||
// Is this the first email notification for this parent item and user?
|
||||
@@ -650,7 +651,7 @@ function check_item_notification($itemid, $uid, $notification_type) {
|
||||
|
||||
// Special treatment for posts that had been shared via "announce"
|
||||
if ($item['gravity'] == GRAVITY_ACTIVITY) {
|
||||
$parent_item = Item::selectFirst($fields, ['uri-id' => $item['thr-parent-id'], 'uid' => [$uid, 0]]);
|
||||
$parent_item = Post::selectFirst($fields, ['uri-id' => $item['thr-parent-id'], 'uid' => [$uid, 0]]);
|
||||
if (DBA::isResult($parent_item)) {
|
||||
// Don't notify on own entries
|
||||
if (User::getIdForURL($parent_item['author-link']) == $uid) {
|
||||
|
||||
Reference in New Issue
Block a user