$params['group_by'] = ['uri-id'];
} else {
$condition = ["`id` > ?
- " . ($exclude_replies ? " AND `id` = `parent` " : ' ') . "
+ " . ($exclude_replies ? " AND `gravity` = " . GRAVITY_PARENT : ' ') . "
AND (`uid` = 0 OR (`uid` = ? AND NOT `global`))
AND `body` LIKE CONCAT('%',?,'%')",
$since_id, api_user(), $_REQUEST['q']];
$retweeted_item = [];
$quoted_item = [];
- if ($item["id"] == $item["parent"]) {
+ if ($item['gravity'] == GRAVITY_PARENT) {
$body = $item['body'];
$retweeted_item = api_share_as_retweet($item);
if ($body != $item['body']) {
$item['pagedrop'] = $page_dropping;
- if ($item['id'] == $item['parent']) {
+ if ($item['gravity'] == GRAVITY_PARENT) {
$item_object = new Post($item);
$conv->addParent($item_object);
}
return;
}
- if (!empty($item['verb']) && DI::activity()->match($item['verb'], $verb) && ($item['id'] != $item['parent'])) {
+ if (!empty($item['verb']) && DI::activity()->match($item['verb'], $verb) && ($item['gravity'] != GRAVITY_PARENT)) {
$author = ['uid' => 0, 'id' => $item['author-id'],
'network' => $item['author-network'], 'url' => $item['author-link']];
$url = Contact::magicLinkByContact($author);
{
$children = [];
foreach ($item_list as $i => $item) {
- if ($item['id'] != $item['parent']) {
+ if ($item['gravity'] != GRAVITY_PARENT) {
if ($recursive) {
// Fallback to parent-uri if thr-parent is not set
$thr_parent = $item['thr-parent'];
// Extract the top level items
foreach ($item_array as $item) {
- if ($item['id'] == $item['parent']) {
+ if ($item['gravity'] == GRAVITY_PARENT) {
$parents[] = $item;
}
}
$item = null;
$item_user = local_user();
- $fields = ['id', 'parent', 'author-id', 'body', 'uid', 'guid'];
+ $fields = ['id', 'parent', 'author-id', 'body', 'uid', 'guid', 'gravity'];
// If there is only one parameter, then check if this parameter could be a guid
if ($a->argc == 2) {
}
if (!empty($_SERVER['HTTP_ACCEPT']) && strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
- Logger::log('Directly serving XML for id '.$item["id"], Logger::DEBUG);
- displayShowFeed($item["id"], false);
+ Logger::log('Directly serving XML for id '.$item['id'], Logger::DEBUG);
+ displayShowFeed($item['id'], false);
}
- if ($item["id"] != $item["parent"]) {
- $parent = Item::selectFirstForUser($item_user, $fields, ['id' => $item["parent"]]);
+ if ($item['gravity'] != GRAVITY_PARENT) {
+ $parent = Item::selectFirstForUser($item_user, $fields, ['id' => $item['parent']]);
$item = $parent ?: $item;
}
$condition = ['guid' => $a->argv[1], 'uid' => local_user()];
$item = Item::selectFirstForUser(local_user(), $fields, $condition);
if (DBA::isResult($item)) {
- $item_id = $item["id"];
- $item_parent = $item["parent"];
+ $item_id = $item['id'];
+ $item_parent = $item['parent'];
$item_parent_uri = $item['parent-uri'];
}
}
if (($item_parent == 0) && remote_user()) {
$item = Item::selectFirst($fields, ['guid' => $a->argv[1], 'private' => Item::PRIVATE, 'origin' => true]);
if (DBA::isResult($item) && Contact::isFollower(remote_user(), $item['uid'])) {
- $item_id = $item["id"];
- $item_parent = $item["parent"];
+ $item_id = $item['id'];
+ $item_parent = $item['parent'];
$item_parent_uri = $item['parent-uri'];
}
}
$condition = ['private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => $a->argv[1], 'uid' => 0];
$item = Item::selectFirstForUser(local_user(), $fields, $condition);
if (DBA::isResult($item)) {
- $item_id = $item["id"];
- $item_parent = $item["parent"];
+ $item_id = $item['id'];
+ $item_parent = $item['parent'];
$item_parent_uri = $item['parent-uri'];
}
}
// The URI and the contact is taken from the direct parent which needn't to be the top parent
$thr_parent_uri = $toplevel_item['uri'];
- if ($toplevel_item['id'] != $toplevel_item['parent']) {
+ if ($toplevel_item['gravity'] != GRAVITY_PARENT) {
$toplevel_item = Item::selectFirst([], ['id' => $toplevel_item['parent']]);
}
}
}
if ($order === 'post') {
// Only show toplevel posts when updating posts in this order mode
- $sql_extra4 .= " AND `item`.`id` = `item`.`parent`";
+ $sql_extra4 .= " AND `item`.`gravity` = " . GRAVITY_PARENT;
}
}
if (($activity->match($item['verb'], Activity::LIKE) ||
$activity->match($item['verb'], Activity::DISLIKE)) &&
- ($item['id'] != $item['parent'])) {
+ ($item['gravity'] != GRAVITY_PARENT)) {
continue;
}
if ($notification["visible"]
&& !$notification["deleted"]
- && empty($result[$notification["parent"]])
+ && empty($result[$notification['parent']])
) {
// Should we condense the notifications or show them all?
if (DI::pConfig()->get(local_user(), 'system', 'detailed_notif')) {
$result[$notification["id"]] = $notification;
} else {
- $result[$notification["parent"]] = $notification;
+ $result[$notification['parent']] = $notification;
}
}
}
$item['author-avatar'] = $item['contact-avatar'];
}
- $item['label'] = (($item['id'] == $item['parent']) ? 'post' : 'comment');
+ $item['label'] = (($item['gravity'] == GRAVITY_PARENT) ? 'post' : 'comment');
$item['link'] = $this->baseUrl->get(true) . '/display/' . $item['parent-guid'];
$item['image'] = Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO);
$item['url'] = $item['author-link'];
- $item['text'] = (($item['id'] == $item['parent'])
+ $item['text'] = (($item['gravity'] == GRAVITY_PARENT)
? $this->l10n->t("%s created a new post", $item['author-name'])
: $this->l10n->t("%s commented on %s's post", $item['author-name'], $item['parent-author-name']));
$item['when'] = DateTimeFormat::local($item['created'], 'r');
$fields = ['id', 'uri', 'uri-id', 'uid', 'parent', 'parent-uri', 'origin',
'deleted', 'file', 'resource-id', 'event-id', 'attach',
'verb', 'object-type', 'object', 'target', 'contact-id',
- 'icid', 'psid'];
+ 'icid', 'psid', 'gravity'];
$item = self::selectFirst($fields, ['id' => $item_id]);
if (!DBA::isResult($item)) {
Logger::info('Item not found.', ['id' => $item_id]);
//}
// If it's the parent of a comment thread, kill all the kids
- if ($item['id'] == $item['parent']) {
+ if ($item['gravity'] == GRAVITY_PARENT) {
self::markForDeletion(['parent' => $item['parent'], 'deleted' => false], $priority);
}
}
}
- $item["parent"] = $parent['id'];
+ $item['parent'] = $parent['id'];
$item["deleted"] = $parent['deleted'];
$item["allow_cid"] = $parent['allow_cid'];
$item['allow_gid'] = $parent['allow_gid'];
// If its a post that originated here then tag the thread as "mention"
if ($item['origin'] && $item['uid']) {
- DBA::update('thread', ['mention' => true], ['iid' => $item["parent"]]);
- Logger::info('tagged thread as mention', ['parent' => $item["parent"], 'uid' => $item['uid']]);
+ DBA::update('thread', ['mention' => true], ['iid' => $item['parent']]);
+ Logger::info('tagged thread as mention', ['parent' => $item['parent'], 'uid' => $item['uid']]);
}
// Update the contact relations
}
// Is it a toplevel post?
- if ($item['id'] == $item['parent']) {
+ if ($item['gravity'] == GRAVITY_PARENT) {
self::addShadow($itemid);
return;
}
if (!$mention) {
if (($community_page || $prvgroup) &&
- !$item['wall'] && !$item['origin'] && ($item['id'] == $item['parent'])) {
+ !$item['wall'] && !$item['origin'] && ($item['gravity'] == GRAVITY_PARENT)) {
Logger::info('Delete private group/communiy top-level item without mention', ['id' => $item_id, 'guid'=> $item['guid']]);
DBA::delete('item', ['id' => $item_id]);
return true;
return;
}
- $condition = ["`uid` = ? AND NOT `deleted` AND `id` = `parent` AND `gravity` = ?",
+ $condition = ["`uid` = ? AND NOT `deleted` AND `gravity` = ?",
$uid, GRAVITY_PARENT];
/*
return DI::l10n()->t('event');
} elseif (!empty($item['resource-id'])) {
return DI::l10n()->t('photo');
- } elseif (!empty($item['verb']) && $item['verb'] !== Activity::POST) {
+ } elseif ($item['gravity'] == GRAVITY_ACTIVITY) {
return DI::l10n()->t('activity');
- } elseif ($item['id'] != $item['parent']) {
+ } elseif ($item['gravity'] == GRAVITY_COMMENT) {
return DI::l10n()->t('comment');
}
$pinned = DI::l10n()->t('pinned item');
}
- if ($origin && ($item['id'] != $item['parent']) && ($item['network'] == Protocol::ACTIVITYPUB)) {
+ if ($origin && ($item['gravity'] != GRAVITY_PARENT) && ($item['network'] == Protocol::ACTIVITYPUB)) {
// ActivityPub doesn't allow removal of remote comments
$delete = DI::l10n()->t('Delete locally');
} else {
if ($item['object-type'] != "") {
XML::addElement($doc, $entry, "activity:object-type", $item['object-type']);
- } elseif ($item['id'] == $item['parent']) {
+ } elseif ($item['gravity'] == GRAVITY_PARENT) {
XML::addElement($doc, $entry, "activity:object-type", Activity\ObjectType::NOTE);
} else {
XML::addElement($doc, $entry, "activity:object-type", Activity\ObjectType::COMMENT);
$author = DBA::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]);
$parent = Item::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => $importer["importer_uid"]]);
- $item["parent"] = $parent['id'];
+ $item['parent'] = $parent['id'];
// send a notification
notification(
"verb" => $item["verb"],
"otype" => "person",
"activity" => $verb,
- "parent" => $item["parent"]]
+ "parent" => $item['parent']]
);
}
}
}
$condition = ['uri' => $uri, 'uid' => $importer["importer_uid"]];
- $item = Item::selectFirst(['id', 'parent', 'contact-id', 'file', 'deleted'], $condition);
+ $item = Item::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;
}
// When it is a starting post it has to belong to the person that wants to delete it
- if (($item['id'] == $item['parent']) && ($item['contact-id'] != $importer["id"])) {
+ if (($item['gravity'] == GRAVITY_PARENT) && ($item['contact-id'] != $importer["id"])) {
Logger::log("Item with uri " . $uri . " don't belong to contact " . $importer["id"] . " - ignoring deletion.", Logger::DEBUG);
return;
}
// Comments can be deleted by the thread owner or comment owner
- if (($item['id'] != $item['parent']) && ($item['contact-id'] != $importer["id"])) {
+ if (($item['gravity'] != GRAVITY_PARENT) && ($item['contact-id'] != $importer["id"])) {
$condition = ['id' => $item['parent'], 'contact-id' => $importer["id"]];
if (!Item::exists($condition)) {
Logger::log("Item with uri " . $uri . " wasn't found or mustn't be deleted by contact " . $importer["id"] . " - ignoring deletion.", Logger::DEBUG);
private static function parentItem($uid, $guid, $author, array $contact)
{
$fields = ['id', 'parent', 'body', 'wall', 'uri', 'guid', 'private', 'origin',
- 'author-name', 'author-link', 'author-avatar',
+ 'author-name', 'author-link', 'author-avatar', 'gravity',
'owner-name', 'owner-link', 'owner-avatar'];
$condition = ['uid' => $uid, 'guid' => $guid];
$item = Item::selectFirst($fields, $condition);
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = DateTimeFormat::utcNow();
// like on comments have the comment as parent. So we need to fetch the toplevel parent
- if ($parent_item["id"] != $parent_item["parent"]) {
- $toplevel = Item::selectFirst(['origin'], ['id' => $parent_item["parent"]]);
+ if ($parent_item['gravity'] != GRAVITY_PARENT) {
+ $toplevel = Item::selectFirst(['origin'], ['id' => $parent_item['parent']]);
$origin = $toplevel["origin"];
} else {
$origin = $parent_item["origin"];
}
// Fetch the parent item
- $parent = Item::selectFirst(['author-link'], ['id' => $item["parent"]]);
+ $parent = Item::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"])) {
Item::markForDeletion(['id' => $item['id']]);
- Logger::log("Deleted target ".$target_guid." (".$item["id"].") from user ".$item["uid"]." parent: ".$item["parent"], Logger::DEBUG);
+ Logger::log("Deleted target ".$target_guid." (".$item["id"].") from user ".$item["uid"]." parent: ".$item['parent'], Logger::DEBUG);
}
return true;
return $result;
}
- $toplevel_item = Item::selectFirst(['guid', 'author-id', 'author-link'], ['id' => $item["parent"], 'parent' => $item["parent"]]);
+ $toplevel_item = Item::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"]]);
+ Logger::error('Missing parent conversation item', ['parent' => $item['parent']]);
return false;
}
$msg_type = "retraction";
- if ($item['id'] == $item['parent']) {
+ if ($item['gravity'] == GRAVITY_PARENT) {
$target_type = "Post";
} elseif (in_array($item["verb"], [Activity::LIKE, Activity::DISLIKE])) {
$target_type = "Like";
*/
private static function reshareEntry(DOMDocument $doc, array $item, array $owner, $repeated_guid, $toplevel)
{
- if (($item["id"] != $item["parent"]) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
+ if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
}
*/
private static function likeEntry(DOMDocument $doc, array $item, array $owner, $toplevel)
{
- if (($item["id"] != $item["parent"]) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
+ if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
}
*/
private static function followEntry(DOMDocument $doc, array $item, array $owner, $toplevel)
{
- $item["id"] = $item["parent"] = 0;
+ $item["id"] = $item['parent'] = 0;
$item["created"] = $item["edited"] = date("c");
$item["private"] = Item::PRIVATE;
*/
private static function noteEntry(DOMDocument $doc, array $item, array $owner, $toplevel, $feed_mode)
{
- if (($item["id"] != $item["parent"]) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
+ if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
}
$mentioned = [];
if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
- $parent = Item::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item["parent"]]);
+ $parent = Item::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
$thrparent = Item::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $parent_item]);
XML::addElement($doc, $entry, "link", "", $attributes);
}
- if (!$feed_mode && (intval($item["parent"]) > 0)) {
+ if (!$feed_mode && (intval($item['parent']) > 0)) {
$conversation_href = $conversation_uri = str_replace('/objects/', '/context/', $item['parent-uri']);
if (isset($parent_item)) {
$attributes = [
"href" => $conversation_href,
- "local_id" => $item["parent"],
+ "local_id" => $item['parent'],
"ref" => $conversation_uri];
XML::addElement($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes);