*/
public static function updateItem($activity)
{
- $item = Item::selectFirst(['uri', 'uri-id', 'thr-parent', 'gravity'], ['uri' => $activity['id']]);
+ $item = Post::selectFirst(['uri', 'uri-id', 'thr-parent', 'gravity'], ['uri' => $activity['id']]);
if (!DBA::isResult($item)) {
Logger::warning('No existing item, item will be created', ['uri' => $activity['id']]);
$item = self::createItem($activity);
$item['object-type'] = Activity\ObjectType::COMMENT;
}
- if (empty($activity['directmessage']) && ($activity['id'] != $activity['reply-to-id']) && !Item::exists(['uri' => $activity['reply-to-id']])) {
+ if (empty($activity['directmessage']) && ($activity['id'] != $activity['reply-to-id']) && !Post::exists(['uri' => $activity['reply-to-id']])) {
Logger::notice('Parent not found. Try to refetch it.', ['parent' => $activity['reply-to-id']]);
self::fetchMissingActivity($activity['reply-to-id'], $activity);
}
$item['diaspora_signed_text'] = $activity['diaspora:comment'] ?? '';
/// @todo What to do with $activity['context']?
- if (empty($activity['directmessage']) && ($item['gravity'] != GRAVITY_PARENT) && !Item::exists(['uri' => $item['thr-parent']])) {
+ if (empty($activity['directmessage']) && ($item['gravity'] != GRAVITY_PARENT) && !Post::exists(['uri' => $item['thr-parent']])) {
Logger::info('Parent not found, message will be discarded.', ['thr-parent' => $item['thr-parent']]);
return [];
}
}
foreach ($activity['receiver'] as $receiver) {
- $item = Item::selectFirst(['id', 'uri-id', 'tag', 'origin', 'author-link'], ['uri' => $activity['target_id'], 'uid' => $receiver]);
+ $item = Post::selectFirst(['id', 'uri-id', 'tag', 'origin', 'author-link'], ['uri' => $activity['target_id'], 'uid' => $receiver]);
if (!DBA::isResult($item)) {
// We don't fetch missing content for this purpose
continue;
} else {
if (empty($activity['directmessage']) && ($item['thr-parent'] != $item['uri']) && ($item['gravity'] == GRAVITY_COMMENT)) {
$item_private = !in_array(0, $activity['item_receiver']);
- $parent = Item::selectFirst(['id', 'uri-id', 'private', 'author-link', 'alias'], ['uri' => $item['thr-parent']]);
+ $parent = Post::selectFirst(['id', 'uri-id', 'private', 'author-link', 'alias'], ['uri' => $item['thr-parent']]);
if (!DBA::isResult($parent)) {
Logger::warning('Unknown parent item.', ['uri' => $item['thr-parent']]);
return false;
}
$replyto = JsonLD::fetchElement($activity['as:object'], 'as:inReplyTo', '@id');
- if (Item::exists(['uri' => $replyto])) {
+ if (Post::exists(['uri' => $replyto])) {
Logger::info('Post is a reply to an existing post - accepted', ['id' => $id, 'replyto' => $replyto]);
return true;
}
use Friendica\Model\Contact;
use Friendica\Model\APContact;
use Friendica\Model\Item;
+use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub;
}
}
- if (Item::exists(['uri' => $object_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]])) {
+ if (Post::exists(['uri' => $object_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]])) {
// We just assume "note" since it doesn't make a difference for the further processing
return 'as:Note';
}
}
if (!empty($reply)) {
- $parents = Item::select(['uid'], ['uri' => $reply]);
- while ($parent = Item::fetch($parents)) {
+ $parents = Post::select(['uid'], ['uri' => $reply]);
+ while ($parent = Post::fetch($parents)) {
$receivers[$parent['uid']] = ['uid' => $parent['uid'], 'type' => self::TARGET_ANSWER];
}
+ DBA::close($parents);
}
if (!empty($actor)) {
} else {
Logger::log('Empty content for ' . $object_id . ', check if content is available locally.', Logger::DEBUG);
- $item = Item::selectFirst([], ['uri' => $object_id]);
+ $item = Post::selectFirst([], ['uri' => $object_id]);
if (!DBA::isResult($item)) {
Logger::log('Object with url ' . $object_id . ' was not found locally.', Logger::DEBUG);
return false;
*/
public static function addRelayServerInboxesForItem(int $item_id, array $inboxes = [])
{
- $item = Item::selectFirst(['uid'], ['id' => $item_id]);
+ $item = Post::selectFirst(['uid'], ['id' => $item_id]);
if (empty($item)) {
return $inboxes;
}
$condition['parent-network'] = Protocol::NATIVE_SUPPORT;
- $items = Item::select(['id'], $condition, ['limit' => [($page - 1) * 20, 20], 'order' => ['created' => true]]);
- while ($item = Item::fetch($items)) {
+ $items = Post::select(['id'], $condition, ['limit' => [($page - 1) * 20, 20], 'order' => ['created' => true]]);
+ while ($item = Post::fetch($items)) {
$activity = self::createActivityFromItem($item['id'], true);
$activity['type'] = $activity['type'] == 'Update' ? 'Create' : $activity['type'];
$list[] = $activity['object'];
}
}
+ DBA::close($items);
if (!empty($list)) {
$data['next'] = DI::baseUrl() . '/outbox/' . $owner['nickname'] . '?page=' . ($page + 1);
return false;
}
- return Item::exists(['id' => $item_id, 'network' => Protocol::ACTIVITYPUB]);
+ return Post::exists(['id' => $item_id, 'network' => Protocol::ACTIVITYPUB]);
}
/**
}
if (!empty($item['parent'])) {
- $parents = Item::select(['id', 'author-link', 'owner-link', 'gravity', 'uri'], ['parent' => $item['parent']]);
- while ($parent = Item::fetch($parents)) {
+ $parents = Post::select(['id', 'author-link', 'owner-link', 'gravity', 'uri'], ['parent' => $item['parent']]);
+ while ($parent = Post::fetch($parents)) {
if ($parent['gravity'] == GRAVITY_PARENT) {
$profile = APContact::getByURL($parent['owner-link'], false);
if (!empty($profile)) {
public static function createActivityFromItem(int $item_id, bool $object_mode = false)
{
Logger::info('Fetching activity', ['item' => $item_id]);
- $item = Item::selectFirst([], ['id' => $item_id, 'parent-network' => Protocol::NATIVE_SUPPORT]);
+ $item = Post::selectFirst([], ['id' => $item_id, 'parent-network' => Protocol::NATIVE_SUPPORT]);
if (!DBA::isResult($item)) {
return false;
}
if (!empty($author['nurl'])) {
$self = Contact::selectFirst(['uid'], ['nurl' => $author['nurl'], 'self' => true]);
if (!empty($self['uid'])) {
- $forum_item = Item::selectFirst([], ['uri-id' => $item['uri-id'], 'uid' => $self['uid']]);
+ $forum_item = Post::selectFirst([], ['uri-id' => $item['uri-id'], 'uid' => $self['uid']]);
if (DBA::isResult($item)) {
$item = $forum_item;
}
return [];
}
- $reshared_item = Item::selectFirst([], ['guid' => $reshared['guid']]);
+ $reshared_item = Post::selectFirst([], ['guid' => $reshared['guid']]);
if (!DBA::isResult($reshared_item)) {
return [];
}
$condition = ['verb' => Activity::FOLLOW, 'uid' => 0, 'parent-uri' => $object,
'author-id' => Contact::getPublicIdByUserId($uid)];
- if (Item::exists($condition)) {
+ if (Post::exists($condition)) {
Logger::log('Follow for ' . $object . ' for user ' . $uid . ' does already exist.', Logger::DEBUG);
return false;
}
}
if (!empty($ids)) {
- $ret = Item::select(Item::DELIVER_FIELDLIST, ['id' => $ids]);
- $items = Item::inArray($ret);
+ $items = Post::selectToArray(Item::DELIVER_FIELDLIST, ['id' => $ids]);
} else {
$items = [];
}
$condition = ['id' => $item_id];
}
- $ret = Item::select(Item::DELIVER_FIELDLIST, $condition);
- $items = Item::inArray($ret);
+ $items = Post::selectToArray(Item::DELIVER_FIELDLIST, $condition);
if (!DBA::isResult($items)) {
return '';
}
$entry->appendChild($dfrnowner);
if ($item['gravity'] != GRAVITY_PARENT) {
- $parent = Item::selectFirst(['guid', 'plink'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
+ $parent = Post::selectFirst(['guid', 'plink'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
if (DBA::isResult($parent)) {
$attributes = ["ref" => $item['thr-parent'], "type" => "text/html",
"href" => $parent['plink'],
$is_a_remote_action = false;
- $parent = Item::selectFirst(['thr-parent'], ['uri' => $item["thr-parent"]]);
+ $parent = Post::selectFirst(['thr-parent'], ['uri' => $item["thr-parent"]]);
if (DBA::isResult($parent)) {
$r = q(
"SELECT `item`.`forum_mode`, `item`.`wall` FROM `item`
if ($Blink && Strings::compareLink($Blink, DI::baseUrl() . "/profile/" . $importer["nickname"])) {
$author = DBA::selectFirst('contact', ['id', 'name', 'thumb', 'url'], ['id' => $item['author-id']]);
- $parent = Item::selectFirst(['id'], ['uri' => $item['thr-parent'], 'uid' => $importer["importer_uid"]]);
+ $parent = Post::selectFirst(['id'], ['uri' => $item['thr-parent'], 'uid' => $importer["importer_uid"]]);
$item['parent'] = $parent['id'];
// send a notification
// split into two queries for performance issues
$condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"], 'gravity' => GRAVITY_ACTIVITY,
'verb' => $item['verb'], 'parent-uri' => $item['thr-parent']];
- if (Item::exists($condition)) {
+ if (Post::exists($condition)) {
return false;
}
$condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"], 'gravity' => GRAVITY_ACTIVITY,
'verb' => $item['verb'], 'thr-parent' => $item['thr-parent']];
- if (Item::exists($condition)) {
+ if (Post::exists($condition)) {
return false;
}
$xt = XML::parseString($item["target"]);
if ($xt->type == Activity\ObjectType::NOTE) {
- $item_tag = Item::selectFirst(['id', 'uri-id', 'tag'], ['uri' => $xt->id, 'uid' => $importer["importer_uid"]]);
+ $item_tag = Post::selectFirst(['id', 'uri-id', 'tag'], ['uri' => $xt->id, 'uid' => $importer["importer_uid"]]);
if (!DBA::isResult($item_tag)) {
Logger::log("Query failed to execute, no result returned in " . __FUNCTION__);
$item["edited"] = XML::getFirstNodeValue($xpath, "atom:updated/text()", $entry);
- $current = Item::selectFirst(['id', 'uid', 'edited', 'body'],
+ $current = Post::selectFirst(['id', 'uid', 'edited', 'body'],
['uri' => $item["uri"], 'uid' => $importer["importer_uid"]]
);
// Is there an existing item?
}
$condition = ['uri' => $uri, 'uid' => $importer["importer_uid"]];
- $item = Item::selectFirst(['id', 'parent', 'contact-id', 'file', 'deleted', 'gravity'], $condition);
+ $item = Post::selectFirst(['id', 'parent', 'contact-id', 'file', 'deleted', 'gravity'], $condition);
if (!DBA::isResult($item)) {
Logger::log("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " wasn't found.", Logger::DEBUG);
return;
// Comments can be deleted by the thread owner or comment owner
if (($item['gravity'] != GRAVITY_PARENT) && ($item['contact-id'] != $importer["id"])) {
$condition = ['id' => $item['parent'], 'contact-id' => $importer["id"]];
- if (!Item::exists($condition)) {
+ if (!Post::exists($condition)) {
Logger::log("Item with uri " . $uri . " wasn't found or mustn't be deleted by contact " . $importer["id"] . " - ignoring deletion.", Logger::DEBUG);
return;
}
return $contacts;
}
- $items = Item::select(['author-id', 'author-link', 'parent-author-link', 'parent-guid', 'guid'],
+ $items = Post::select(['author-id', 'author-link', 'parent-author-link', 'parent-guid', 'guid'],
['parent' => $item['parent'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
- while ($item = DBA::fetch($items)) {
+ while ($item = Post::fetch($items)) {
$contact = DBA::selectFirst('contact', ['id', 'url', 'name', 'protocol', 'batch', 'network'],
['id' => $item['author-id']]);
if (!DBA::isResult($contact) || empty($contact['batch']) ||
*/
private static function messageExists($uid, $guid)
{
- $item = Item::selectFirst(['id'], ['uid' => $uid, 'guid' => $guid]);
+ $item = Post::selectFirst(['id'], ['uid' => $uid, 'guid' => $guid]);
if (DBA::isResult($item)) {
Logger::log("message ".$guid." already exists for user ".$uid);
return $item["id"];
$guid = urldecode($matches[2]);
- $item = Item::selectFirst(['id'], ['guid' => $guid, 'uid' => $uid]);
+ $item = Post::selectFirst(['id'], ['guid' => $guid, 'uid' => $uid]);
if (DBA::isResult($item)) {
Logger::info('Found', ['id' => $item['id']]);
return $item['id'];
$ret = self::storeByGuid($guid, $matches[1], $uid);
Logger::info('Result', ['ret' => $ret]);
- $item = Item::selectFirst(['id'], ['guid' => $guid, 'uid' => $uid]);
+ $item = Post::selectFirst(['id'], ['guid' => $guid, 'uid' => $uid]);
if (DBA::isResult($item)) {
Logger::info('Found', ['id' => $item['id']]);
return $item['id'];
'author-name', 'author-link', 'author-avatar', 'gravity',
'owner-name', 'owner-link', 'owner-avatar'];
$condition = ['uid' => $uid, 'guid' => $guid];
- $item = Item::selectFirst($fields, $condition);
+ $item = Post::selectFirst($fields, $condition);
if (!DBA::isResult($item)) {
$person = FContact::getByURL($author);
if ($result) {
Logger::log("Fetched missing item ".$guid." - result: ".$result, Logger::DEBUG);
- $item = Item::selectFirst($fields, $condition);
+ $item = Post::selectFirst($fields, $condition);
}
}
*/
private static function getUriFromGuid($author, $guid, $onlyfound = false)
{
- $item = Item::selectFirst(['uri'], ['guid' => $guid]);
+ $item = Post::selectFirst(['uri'], ['guid' => $guid]);
if (DBA::isResult($item)) {
return $item["uri"];
} elseif (!$onlyfound) {
return "";
}
- /**
- * Fetch the guid from our database with a given uri
- *
- * @param string $uri Message uri
- * @param string $uid Author handle
- *
- * @return string The post guid
- * @throws \Exception
- */
- private static function getGuidFromUri($uri, $uid)
- {
- $item = Item::selectFirst(['guid'], ['uri' => $uri, 'uid' => $uid]);
- if (DBA::isResult($item)) {
- return $item["guid"];
- } else {
- return false;
- }
- }
-
/**
* Store the mentions in the tag table
*
// like on comments have the comment as parent. So we need to fetch the toplevel parent
if ($toplevel_parent_item['gravity'] != GRAVITY_PARENT) {
- $toplevel = Item::selectFirst(['origin'], ['id' => $toplevel_parent_item['parent']]);
+ $toplevel = Post::selectFirst(['origin'], ['id' => $toplevel_parent_item['parent']]);
$origin = $toplevel["origin"];
} else {
$origin = $toplevel_parent_item["origin"];
Logger::info('Participation stored', ['id' => $message_id, 'guid' => $guid, 'parent_guid' => $parent_guid, 'author' => $author]);
// Send all existing comments and likes to the requesting server
- $comments = Item::select(['id', 'uri-id', 'parent-author-network', 'author-network', 'verb'],
+ $comments = Post::select(['id', 'uri-id', 'parent-author-network', 'author-network', 'verb'],
['parent' => $toplevel_parent_item['id'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
- while ($comment = Item::fetch($comments)) {
+ while ($comment = Post::fetch($comments)) {
if (in_array($comment['verb'], [Activity::FOLLOW, Activity::TAG])) {
Logger::info('participation messages are not relayed', ['item' => $comment['id']]);
continue;
$fields = ['body', 'title', 'app', 'created', 'object-type', 'uri', 'guid',
'author-name', 'author-link', 'author-avatar', 'plink', 'uri-id'];
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => [Item::PUBLIC, Item::UNLISTED]];
- $item = Item::selectFirst($fields, $condition);
+ $item = Post::selectFirst($fields, $condition);
if (DBA::isResult($item)) {
Logger::log("reshared message ".$guid." already exists on system.");
$fields = ['body', 'title', 'app', 'created', 'object-type', 'uri', 'guid',
'author-name', 'author-link', 'author-avatar', 'plink', 'uri-id'];
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => [Item::PUBLIC, Item::UNLISTED]];
- $item = Item::selectFirst($fields, $condition);
+ $item = Post::selectFirst($fields, $condition);
if (DBA::isResult($item)) {
// If it is a reshared post from another network then reformat to avoid display problems with two share elements
*/
private static function addReshareActivity($item, $parent_message_id, $guid, $author)
{
- $parent = Item::selectFirst(['uri', 'guid'], ['id' => $parent_message_id]);
+ $parent = Post::selectFirst(['uri', 'guid'], ['id' => $parent_message_id]);
$datarray = [];
$condition = ['guid' => $target_guid, 'deleted' => false, 'uid' => $importer['uid']];
}
- $r = Item::select($fields, $condition);
+ $r = Post::select($fields, $condition);
if (!DBA::isResult($r)) {
Logger::log("Target guid ".$target_guid." was not found on this system for user ".$importer['uid'].".");
return false;
}
- while ($item = Item::fetch($r)) {
+ while ($item = Post::fetch($r)) {
if (strstr($item['file'], '[')) {
Logger::log("Target guid " . $target_guid . " for user " . $item['uid'] . " is filed. So it won't be deleted.", Logger::DEBUG);
continue;
}
// Fetch the parent item
- $parent = Item::selectFirst(['author-link'], ['id' => $item['parent']]);
+ $parent = Post::selectFirst(['author-link'], ['id' => $item['parent']]);
// Only delete it if the parent author really fits
if (!Strings::compareLink($parent["author-link"], $contact["url"]) && !Strings::compareLink($item["author-link"], $contact["url"])) {
Logger::log("Deleted target ".$target_guid." (".$item["id"].") from user ".$item["uid"]." parent: ".$item['parent'], Logger::DEBUG);
}
+ DBA::close($r);
return true;
}
if (!empty($reshared['guid']) && $complete) {
$condition = ['guid' => $reshared['guid'], 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
- $item = Item::selectFirst(['contact-id'], $condition);
+ $item = Post::selectFirst(['contact-id'], $condition);
if (DBA::isResult($item)) {
$ret = [];
$ret["root_handle"] = self::handleFromContact($item["contact-id"]);
*/
private static function constructLike(array $item, array $owner)
{
- $parent = Item::selectFirst(['guid', 'uri', 'thr-parent'], ['uri' => $item["thr-parent"]]);
+ $parent = Post::selectFirst(['guid', 'uri', 'thr-parent'], ['uri' => $item["thr-parent"]]);
if (!DBA::isResult($parent)) {
return false;
}
*/
private static function constructAttend(array $item, array $owner)
{
- $parent = Item::selectFirst(['guid'], ['uri' => $item['thr-parent']]);
+ $parent = Post::selectFirst(['guid'], ['uri' => $item['thr-parent']]);
if (!DBA::isResult($parent)) {
return false;
}
return $result;
}
- $toplevel_item = Item::selectFirst(['guid', 'author-id', 'author-link'], ['id' => $item['parent'], 'parent' => $item['parent']]);
+ $toplevel_item = Post::selectFirst(['guid', 'author-id', 'author-link'], ['id' => $item['parent'], 'parent' => $item['parent']]);
if (!DBA::isResult($toplevel_item)) {
Logger::error('Missing parent conversation item', ['parent' => $item['parent']]);
return false;
$thread_parent_item = $toplevel_item;
if ($item['thr-parent'] != $item['parent-uri']) {
- $thread_parent_item = Item::selectFirst(['guid', 'author-id', 'author-link'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
+ $thread_parent_item = Post::selectFirst(['guid', 'author-id', 'author-link'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
}
$body = $item["body"];
return false;
}
- $parent = Item::selectFirst(['parent-uri'], ['uri' => $item['thr-parent']]);
+ $parent = Post::selectFirst(['parent-uri'], ['uri' => $item['thr-parent']]);
if (!DBA::isResult($parent)) {
return;
}
if (!$dryRun) {
$condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
$importer["uid"], $item["uri"], Protocol::FEED, Protocol::DFRN];
- $previous = Item::selectFirst(['id', 'created'], $condition);
+ $previous = Post::selectFirst(['id', 'created'], $condition);
if (DBA::isResult($previous)) {
// Use the creation date when the post had been stored. It can happen this date changes in the feed.
$creation_dates[] = $previous['created'];
}
$condition = ['uid' => $item['uid'], 'uri' => $item['uri']];
- if (!Item::exists($condition) && !Post\Delayed::exists($item["uri"], $item['uid'])) {
+ if (!Post::exists($condition) && !Post\Delayed::exists($item["uri"], $item['uid'])) {
if (!$notify) {
Post\Delayed::publish($item, $notify, $taglist, $attachments);
} else {
$condition = ['uid' => $owner["uid"], 'guid' => $repeated_guid, 'private' => [Item::PUBLIC, Item::UNLISTED],
'network' => Protocol::FEDERATED];
- $repeated_item = Item::selectFirst([], $condition);
+ $repeated_item = Post::selectFirst([], $condition);
if (!DBA::isResult($repeated_item)) {
return false;
}
$mentioned = [];
if ($item['gravity'] != GRAVITY_PARENT) {
- $parent = Item::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
+ $parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
- $thrparent = Item::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $item['thr-parent']]);
+ $thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $item['thr-parent']]);
if (DBA::isResult($thrparent)) {
$mentioned[$thrparent["author-link"]] = $thrparent["author-link"];
}
// Deletions come with the same uri, so we check for duplicates after processing deletions
- if (Item::exists(['uid' => $importer["uid"], 'uri' => $item["uri"]])) {
+ if (Post::exists(['uid' => $importer["uid"], 'uri' => $item["uri"]])) {
Logger::log('Post with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', Logger::DEBUG);
continue;
} else {
}
}
foreach (self::$itemlist as $item) {
- $found = Item::exists(['uid' => $importer["uid"], 'uri' => $item["uri"]]);
+ $found = Post::exists(['uid' => $importer["uid"], 'uri' => $item["uri"]]);
if ($found) {
Logger::log("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists.", Logger::DEBUG);
} elseif ($item['contact-id'] < 0) {
private static function deleteNotice(array $item)
{
$condition = ['uid' => $item['uid'], 'author-id' => $item['author-id'], 'uri' => $item['uri']];
- if (!Item::exists($condition)) {
+ if (!Post::exists($condition)) {
Logger::log('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it.");
return;
}
}
if (isset($item["thr-parent"])) {
- if (!Item::exists(['uid' => $importer["uid"], 'uri' => $item['thr-parent']])) {
+ if (!Post::exists(['uid' => $importer["uid"], 'uri' => $item['thr-parent']])) {
if ($related != '') {
self::fetchRelated($related, $item["thr-parent"], $importer);
}
$condition = ['uid' => $owner["uid"], 'guid' => $repeated_guid, 'private' => [Item::PUBLIC, Item::UNLISTED],
'network' => [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]];
- $repeated_item = Item::selectFirst([], $condition);
+ $repeated_item = Post::selectFirst([], $condition);
if (!DBA::isResult($repeated_item)) {
return false;
}
$verb = ActivityNamespace::ACTIVITY_SCHEMA . "favorite";
self::entryContent($doc, $entry, $item, $owner, "Favorite", $verb, false);
- $parent = Item::selectFirst([], ['uri' => $item["thr-parent"], 'uid' => $item["uid"]]);
+ $parent = Post::selectFirst([], ['uri' => $item["thr-parent"], 'uid' => $item["uid"]]);
if (DBA::isResult($parent)) {
$as_object = $doc->createElement("activity:object");
$mentioned = [];
if ($item['gravity'] != GRAVITY_PARENT) {
- $parent = Item::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
+ $parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
- $thrparent = Item::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $item['thr-parent']]);
+ $thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $item['thr-parent']]);
if (DBA::isResult($thrparent)) {
$mentioned[$thrparent["author-link"]] = $thrparent["author-link"];
use Friendica\Model\Contact;
use Friendica\Model\GServer;
use Friendica\Model\Item;
+use Friendica\Model\Post;
use Friendica\Model\Search;
use Friendica\Model\Tag;
use Friendica\Util\DateTimeFormat;
if (DI::config()->get("system", "relay_directly", false)) {
// We distribute our stuff based on the parent to ensure that the thread will be complete
- $parent = Item::selectFirst(['uri-id'], ['id' => $item_id]);
+ $parent = Post::selectFirst(['uri-id'], ['id' => $item_id]);
if (!DBA::isResult($parent)) {
return;
}
if (ActivityPub\Transmitter::archivedInbox($inbox)) {
Logger::info('Inbox is archived', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $item_id, 'uid' => $uid]);
if (in_array($cmd, [Delivery::POST])) {
- $item = Item::selectFirst(['uri-id'], ['id' => $item_id]);
+ $item = Post::selectFirst(['uri-id'], ['id' => $item_id]);
Post\DeliveryData::incrementQueueFailed($item['uri-id'] ?? 0);
}
return;
}
// This should never fail and is temporariy (until the move to the "post" structure)
- $item = Item::selectFirst(['uri-id'], ['id' => $item_id]);
+ $item = Post::selectFirst(['uri-id'], ['id' => $item_id]);
$uriid = $item['uri-id'] ?? 0;
$gsid = null;
$uid = $target_id;
$target_item = [];
} else {
- $item = Model\Item::selectFirst(['parent'], ['id' => $target_id]);
+ $item = Model\Post::selectFirst(['parent'], ['id' => $target_id]);
if (!DBA::isResult($item) || empty($item['parent'])) {
return;
}
$condition = ['id' => [$target_id, $parent_id], 'visible' => true, 'moderated' => false];
$params = ['order' => ['id']];
- $itemdata = Model\Item::select([], $condition, $params);
+ $itemdata = Model\Post::select([], $condition, $params);
- while ($item = Model\Item::fetch($itemdata)) {
+ while ($item = Model\Post::fetch($itemdata)) {
if ($item['verb'] == Activity::ANNOUNCE) {
continue;
}
}
$condition = ['uri' => $target_item['thr-parent'], 'uid' => $target_item['uid']];
- $thr_parent = Model\Item::selectFirst(['network', 'object'], $condition);
+ $thr_parent = Model\Post::selectFirst(['network', 'object'], $condition);
if (!DBA::isResult($thr_parent)) {
// Shouldn't happen. But when this does, we just take the parent as thread parent.
// That's totally okay for what we use this variable here.
if (empty($target_item['title'])) {
$condition = ['uri' => $target_item['parent-uri'], 'uid' => $owner['uid']];
- $title = Model\Item::selectFirst(['title'], $condition);
+ $title = Model\Post::selectFirst(['title'], $condition);
if (DBA::isResult($title) && ($title['title'] != '')) {
$subject = $title['title'];
} else {
$condition = ['parent-uri' => $target_item['parent-uri'], 'uid' => $owner['uid']];
- $title = Model\Item::selectFirst(['title'], $condition);
+ $title = Model\Post::selectFirst(['title'], $condition);
if (DBA::isResult($title) && ($title['title'] != '')) {
$subject = $title['title'];
} else {
// find ancestors
$condition = ['id' => $target_id, 'visible' => true, 'moderated' => false];
- $target_item = Item::selectFirst([], $condition);
+ $target_item = Post::selectFirst([], $condition);
if (!DBA::isResult($target_item) || !intval($target_item['parent'])) {
Logger::info('No target item', ['cmd' => $cmd, 'target' => $target_id]);
$condition = ['parent' => $target_item['parent'], 'visible' => true, 'moderated' => false];
$params = ['order' => ['id']];
- $items_stmt = Item::select([], $condition, $params);
+ $items_stmt = Post::select([], $condition, $params);
if (!DBA::isResult($items_stmt)) {
Logger::info('No item found', ['cmd' => $cmd, 'target' => $target_id]);
return;
}
- $items = Item::inArray($items_stmt);
+ $items = Post::inArray($items_stmt);
// avoid race condition with deleting entries
if ($items[0]['deleted']) {
$fields = ['network', 'author-id', 'author-link', 'author-network', 'owner-id'];
$condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]];
- $thr_parent = Item::selectFirst($fields, $condition);
+ $thr_parent = Post::selectFirst($fields, $condition);
if (empty($thr_parent)) {
$thr_parent = $parent;
}
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
+use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub;
// Have we seen it before?
$fields = ['deleted', 'id'];
$condition = ['uid' => $importer_uid, 'uri' => $datarray['uri']];
- $item = Item::selectFirst($fields, $condition);
+ $item = Post::selectFirst($fields, $condition);
if (DBA::isResult($item)) {
Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],Logger::DEBUG);
}
}
$condition = ['uri' => $refs_arr, 'uid' => $importer_uid];
- $parent = Item::selectFirst(['uri'], $condition);
+ $parent = Post::selectFirst(['uri'], $condition);
if (DBA::isResult($parent)) {
$datarray['thr-parent'] = $parent['uri'];
}
if (empty($datarray['thr-parent']) && $reply) {
$condition = ['title' => $datarray['title'], 'uid' => $importer_uid, 'network' => Protocol::MAIL];
$params = ['order' => ['created' => true]];
- $parent = Item::selectFirst(['uri'], $condition, $params);
+ $parent = Post::selectFirst(['uri'], $condition, $params);
if (DBA::isResult($parent)) {
$datarray['thr-parent'] = $parent['uri'];
}
use Friendica\Core\Logger;
use Friendica\Database\DBA;
-use Friendica\Model\Item;
use Friendica\Model\Photo;
+use Friendica\Model\Post;
/**
* Removes orphaned data from deleted contacts
$condition = ['uid' => $contact['uid'], 'contact-id' => $id];
}
do {
- $items = Item::select(['id', 'guid'], $condition, ['limit' => 100]);
- while ($item = Item::fetch($items)) {
+ $items = Post::select(['id', 'guid'], $condition, ['limit' => 100]);
+ while ($item = Post::fetch($items)) {
Logger::info('Delete removed contact item', ['id' => $item['id'], 'guid' => $item['guid']]);
DBA::delete('item', ['id' => $item['id']]);
}
DBA::close($items);
- } while (Item::exists($condition));
+ } while (Post::exists($condition));
Photo::delete(['contact-id' => $id]);
$ret = DBA::delete('contact', ['id' => $id]);
use Friendica\Database\DBA;
use Friendica\Model\Item;
+use Friendica\Model\Post;
/**
* Removes orphaned data from deleted users
// Now we delete all user items
$condition = ['uid' => $uid, 'deleted' => false];
do {
- $items = Item::select(['id'], $condition, ['limit' => 100]);
- while ($item = Item::fetch($items)) {
+ $items = Post::select(['id'], $condition, ['limit' => 100]);
+ while ($item = Post::fetch($items)) {
Item::markForDeletionById($item['id'], PRIORITY_NEGLIGIBLE);
}
DBA::close($items);
- } while (Item::exists($condition));
+ } while (Post::exists($condition));
}
}