$datarray['pubmail'] = $pubmail_enabled;
$datarray['attach'] = $attachments;
- // This is not a bug. The item store function changes 'parent-uri' to 'thr-parent' and fetches 'parent-uri' new. (We should change this)
- $datarray['parent-uri'] = $thr_parent_uri;
+ $datarray['thr-parent'] = $thr_parent_uri;
$datarray['postopts'] = $postopts;
$datarray['origin'] = $origin;
// This field is for storing the raw conversation data
$datarray['protocol'] = Conversation::PARCEL_DFRN;
- $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $datarray['parent-uri']]);
+ $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $datarray['thr-parent']]);
if (DBA::isResult($conversation)) {
if ($conversation['conversation-uri'] != '') {
$datarray['conversation-uri'] = $conversation['conversation-uri'];
$arr['wall'] = $item['wall'];
$arr['gravity'] = GRAVITY_COMMENT;
$arr['parent'] = $item['id'];
- $arr['parent-uri'] = $item['uri'];
+ $arr['thr-parent'] = $item['uri'];
$arr['owner-name'] = $item['author-name'];
$arr['owner-link'] = $item['author-link'];
$arr['owner-avatar'] = $item['author-avatar'];
$mail->appendChild($sender);
XML::addElement($doc, $mail, "dfrn:id", $item['uri']);
- XML::addElement($doc, $mail, "dfrn:in-reply-to", $item['parent-uri']);
+ XML::addElement($doc, $mail, "dfrn:in-reply-to", $item['thr-parent']);
XML::addElement($doc, $mail, "dfrn:sentdate", DateTimeFormat::utc($item['created'] . '+00:00', DateTimeFormat::ATOM));
XML::addElement($doc, $mail, "dfrn:subject", $item['title']);
XML::addElement($doc, $mail, "dfrn:content", $item['body']);
$entry->appendChild($dfrnowner);
if ($item['gravity'] != GRAVITY_PARENT) {
- $parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
- $parent = Item::selectFirst(['guid', 'plink'], ['uri' => $parent_item, 'uid' => $item['uid']]);
+ $parent = Item::selectFirst(['guid', 'plink'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
if (DBA::isResult($parent)) {
- $attributes = ["ref" => $parent_item, "type" => "text/html",
+ $attributes = ["ref" => $item['thr-parent'], "type" => "text/html",
"href" => $parent['plink'],
"dfrn:diaspora_guid" => $parent['guid']];
XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
$conversation_uri = $conversation_href;
if (isset($parent_item)) {
- $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $item['parent-uri']]);
+ $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $item['thr-parent']]);
if (DBA::isResult($conversation)) {
if ($conversation['conversation-uri'] != '') {
$conversation_uri = $conversation['conversation-uri'];
$msg["from-photo"] = XML::getFirstValue($xpath, "dfrn:sender/dfrn:avatar/text()", $mail);
$msg["contact-id"] = $importer["id"];
$msg["uri"] = XML::getFirstValue($xpath, "dfrn:id/text()", $mail);
- $msg["parent-uri"] = XML::getFirstValue($xpath, "dfrn:in-reply-to/text()", $mail);
+ $msg["thr-parent"] = XML::getFirstValue($xpath, "dfrn:in-reply-to/text()", $mail);
$msg["created"] = DateTimeFormat::utc(XML::getFirstValue($xpath, "dfrn:sentdate/text()", $mail));
$msg["title"] = XML::getFirstValue($xpath, "dfrn:subject/text()", $mail);
$msg["body"] = XML::getFirstValue($xpath, "dfrn:content/text()", $mail);
*/
private static function getEntryType($importer, $item)
{
- if ($item["parent-uri"] != $item["uri"]) {
+ if ($item["thr-parent"] != $item["uri"]) {
$community = false;
if ($importer["page-flags"] == User::PAGE_FLAGS_COMMUNITY || $importer["page-flags"] == User::PAGE_FLAGS_PRVGROUP) {
$is_a_remote_action = false;
- $parent = Item::selectFirst(['parent-uri'], ['uri' => $item["parent-uri"]]);
+ $parent = Item::selectFirst(['thr-parent'], ['uri' => $item["thr-parent"]]);
if (DBA::isResult($parent)) {
$r = q(
"SELECT `item`.`forum_mode`, `item`.`wall` FROM `item`
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' OR `item`.`thr-parent` = '%s')
+ WHERE `item`.`uri` = '%s' AND (`item`.`thr-parent` = '%s' OR `item`.`thr-parent` = '%s')
AND `item`.`uid` = %d
$sql_extra
LIMIT 1",
- DBA::escape($parent["parent-uri"]),
- DBA::escape($parent["parent-uri"]),
- DBA::escape($parent["parent-uri"]),
+ DBA::escape($parent["thr-parent"]),
+ DBA::escape($parent["thr-parent"]),
+ DBA::escape($parent["thr-parent"]),
intval($importer["importer_uid"])
);
if (DBA::isResult($r)) {
if ($Blink && Strings::compareLink($Blink, DI::baseUrl() . "/profile/" . $importer["nickname"])) {
$author = DBA::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]);
- $parent = Item::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => $importer["importer_uid"]]);
+ $parent = Item::selectFirst(['id'], ['uri' => $item['thr-parent'], 'uid' => $importer["importer_uid"]]);
$item['parent'] = $parent['id'];
// send a notification
$is_like = true;
$item["gravity"] = GRAVITY_ACTIVITY;
// only one like or dislike per person
- // splitted into two queries for performance issues
+ // 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["parent-uri"]];
+ 'verb' => $item['verb'], 'parent-uri' => $item['thr-parent']];
if (Item::exists($condition)) {
return false;
}
$condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"], 'gravity' => GRAVITY_ACTIVITY,
- 'verb' => $item["verb"], 'thr-parent' => $item["parent-uri"]];
+ 'verb' => $item['verb'], 'thr-parent' => $item['thr-parent']];
if (Item::exists($condition)) {
return false;
}
}
// Is it a reply or a top level posting?
- $item["parent-uri"] = $item["uri"];
+ $item['thr-parent'] = $item['uri'];
$inreplyto = $xpath->query("thr:in-reply-to", $entry);
if (is_object($inreplyto->item(0))) {
foreach ($inreplyto->item(0)->attributes as $attributes) {
if ($attributes->name == "ref") {
- $item["parent-uri"] = $attributes->textContent;
+ $item['thr-parent'] = $attributes->textContent;
}
}
}
// Check if the message is wanted
- if (($importer["importer_uid"] == 0) && ($item['uri'] == $item['parent-uri'])) {
+ if (($importer['importer_uid'] == 0) && ($item['uri'] == $item['thr-parent'])) {
if (!self::isSolicitedMessage($item)) {
DBA::delete('item-uri', ['uri' => $item['uri']]);
return 403;
// check that the message originated elsewhere and is a top-level post
- if ($item['wall'] || $item['origin'] || ($item['uri'] != $item['parent-uri'])) {
+ if ($item['wall'] || $item['origin'] || ($item['uri'] != $item['thr-parent'])) {
return false;
}
if (isset($data->thread_parent_guid)) {
$thread_parent_guid = Strings::escapeTags(XML::unescape($data->thread_parent_guid));
- $thr_uri = self::getUriFromGuid("", $thread_parent_guid, true);
+ $thr_parent = self::getUriFromGuid("", $thread_parent_guid, true);
} else {
- $thr_uri = "";
+ $thr_parent = "";
}
$contact = self::allowedContactByHandle($importer, $sender, true);
return true;
}
- $parent_item = self::parentItem($importer["uid"], $parent_guid, $author, $contact);
- if (!$parent_item) {
+ $toplevel_parent_item = self::parentItem($importer["uid"], $parent_guid, $author, $contact);
+ if (!$toplevel_parent_item) {
return false;
}
$datarray["verb"] = Activity::POST;
$datarray["gravity"] = GRAVITY_COMMENT;
- if ($thr_uri != "") {
- $datarray["parent-uri"] = $thr_uri;
- } else {
- $datarray["parent-uri"] = $parent_item["uri"];
- }
+ $datarray['thr-parent'] = $thr_parent ?: $toplevel_parent_item['uri'];
+ $datarray['parent-uri'] = $toplevel_parent_item['uri'];
$datarray["object-type"] = Activity\ObjectType::COMMENT;
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = $created_at;
- $datarray["plink"] = self::plink($author, $guid, $parent_item['guid']);
+ $datarray["plink"] = self::plink($author, $guid, $toplevel_parent_item['guid']);
$body = Markdown::toBBCode($text);
$datarray["body"] = self::replacePeopleGuid($body, $person["url"]);
// If we are the origin of the parent we store the original data.
// We notify our followers during the item storage.
- if ($parent_item["origin"]) {
+ if ($toplevel_parent_item["origin"]) {
$datarray['diaspora_signed_text'] = json_encode($data);
}
return true;
}
- $parent_item = self::parentItem($importer["uid"], $parent_guid, $author, $contact);
- if (!$parent_item) {
+ $toplevel_parent_item = self::parentItem($importer["uid"], $parent_guid, $author, $contact);
+ if (!$toplevel_parent_item) {
return false;
}
$datarray["verb"] = $verb;
$datarray["gravity"] = GRAVITY_ACTIVITY;
- $datarray["parent-uri"] = $parent_item["uri"];
+ $datarray['thr-parent'] = $toplevel_parent_item['uri'];
$datarray["object-type"] = Activity\ObjectType::NOTE;
$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['gravity'] != GRAVITY_PARENT) {
- $toplevel = Item::selectFirst(['origin'], ['id' => $parent_item['parent']]);
+ if ($toplevel_parent_item['gravity'] != GRAVITY_PARENT) {
+ $toplevel = Item::selectFirst(['origin'], ['id' => $toplevel_parent_item['parent']]);
$origin = $toplevel["origin"];
} else {
- $origin = $parent_item["origin"];
+ $origin = $toplevel_parent_item["origin"];
}
// If we are the origin of the parent we store the original data.
return true;
}
- $parent_item = self::parentItem($importer["uid"], $parent_guid, $author, $contact);
- if (!$parent_item) {
+ $toplevel_parent_item = self::parentItem($importer["uid"], $parent_guid, $author, $contact);
+ if (!$toplevel_parent_item) {
return false;
}
- if (!$parent_item['origin']) {
+ if (!$toplevel_parent_item['origin']) {
Logger::info('Not our origin. Participation is ignored', ['parent_guid' => $parent_guid, 'guid' => $guid, 'author' => $author]);
}
- if (!in_array($parent_item['private'], [Item::PUBLIC, Item::UNLISTED])) {
+ if (!in_array($toplevel_parent_item['private'], [Item::PUBLIC, Item::UNLISTED])) {
Logger::info('Item is not public, participation is ignored', ['parent_guid' => $parent_guid, 'guid' => $guid, 'author' => $author]);
return false;
}
$datarray["verb"] = Activity::FOLLOW;
$datarray["gravity"] = GRAVITY_ACTIVITY;
- $datarray["parent-uri"] = $parent_item["uri"];
+ $datarray['thr-parent'] = $toplevel_parent_item['uri'];
+ $datarray['parent-uri'] = $toplevel_parent_item['parent-uri'];
$datarray["object-type"] = Activity\ObjectType::NOTE;
// Send all existing comments and likes to the requesting server
$comments = Item::select(['id', 'uri-id', 'parent-author-network', 'author-network', 'verb'],
- ['parent' => $parent_item['id'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
+ ['parent' => $toplevel_parent_item['id'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
while ($comment = Item::fetch($comments)) {
if (in_array($comment['verb'], [Activity::FOLLOW, Activity::TAG])) {
Logger::info('participation messages are not relayed', ['item' => $comment['id']]);
$datarray['guid'] = $parent['guid'] . '-' . $guid;
$datarray['uri'] = self::getUriFromGuid($author, $datarray['guid']);
- $datarray['parent-uri'] = $parent['uri'];
+ $datarray['thr-parent'] = $parent['uri'];
+ $datarray['parent-uri'] = $parent['parent-uri'];
$datarray['verb'] = $datarray['body'] = Activity::ANNOUNCE;
$datarray['gravity'] = GRAVITY_ACTIVITY;
$datarray["owner-id"] = $datarray["author-id"];
$datarray["guid"] = $guid;
- $datarray["uri"] = $datarray["parent-uri"] = self::getUriFromGuid($author, $guid);
+ $datarray["uri"] = $datarray["thr-parent"] = self::getUriFromGuid($author, $guid);
$datarray['uri-id'] = ItemURI::insert(['uri' => $datarray['uri'], 'guid' => $datarray['guid']]);
$datarray["verb"] = Activity::POST;
}
// Fetch items that are about to be deleted
- $fields = ['uid', 'id', 'parent', 'parent-uri', 'author-link', 'file'];
+ $fields = ['uid', 'id', 'parent', 'author-link', 'file'];
// When we receive a public retraction, we delete every item that we find.
if ($importer['uid'] == 0) {
$datarray = [];
$datarray["guid"] = $guid;
- $datarray["uri"] = $datarray["parent-uri"] = self::getUriFromGuid($author, $guid);
+ $datarray["uri"] = $datarray["thr-parent"] = self::getUriFromGuid($author, $guid);
$datarray['uri-id'] = ItemURI::insert(['uri' => $datarray['uri'], 'guid' => $datarray['guid']]);
// Attach embedded pictures to the body
*/
private static function constructLike(array $item, array $owner)
{
- $parent = Item::selectFirst(['guid', 'uri', 'parent-uri'], ['uri' => $item["thr-parent"]]);
+ $parent = Item::selectFirst(['guid', 'uri', 'thr-parent'], ['uri' => $item["thr-parent"]]);
if (!DBA::isResult($parent)) {
return false;
}
- $target_type = ($parent["uri"] === $parent["parent-uri"] ? "Post" : "Comment");
+ $target_type = ($parent["uri"] === $parent["thr-parent"] ? "Post" : "Comment");
$positive = null;
if ($item['verb'] === Activity::LIKE) {
$positive = "true";
*/
private static function constructAttend(array $item, array $owner)
{
- $parent = Item::selectFirst(['guid', 'uri', 'parent-uri'], ['uri' => $item["thr-parent"]]);
+ $parent = Item::selectFirst(['guid'], ['uri' => $item['thr-parent']]);
if (!DBA::isResult($parent)) {
return false;
}
return false;
}
- // This is a workaround for the behaviour of the "insert" function, see mod/item.php
- $item['thr-parent'] = $item['parent-uri'];
-
- $parent = Item::selectFirst(['parent-uri'], ['uri' => $item['parent-uri']]);
+ $parent = Item::selectFirst(['parent-uri'], ['uri' => $item['thr-parent']]);
if (!DBA::isResult($parent)) {
return;
}
$item["plink"] = DI::httpRequest()->finalUrl($item["plink"]);
- $item["parent-uri"] = $item["uri"];
+ $item["thr-parent"] = $item["uri"];
$item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
if ($notify) {
$item['guid'] = Item::guidFromUri($orig_plink, DI::baseUrl()->getHostname());
unset($item['uri']);
+ unset($item['thr-parent']);
unset($item['parent-uri']);
// Set the delivery priority for "remote self" to "medium"
if ($item['gravity'] != GRAVITY_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]);
+ $thrparent = Item::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"];
}
$attributes = [
- "ref" => $parent_item,
+ "ref" => $item['thr-parent'],
"href" => $parent_plink];
XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
Logger::log("Favorite ".$orig_uri." ".print_r($item, true));
$item["verb"] = Activity::LIKE;
- $item["parent-uri"] = $orig_uri;
+ $item["thr-parent"] = $orig_uri;
$item["gravity"] = GRAVITY_ACTIVITY;
$item["object-type"] = Activity\ObjectType::NOTE;
}
self::processPost($xpath, $entry, $item, $importer);
if ($initialize && (count(self::$itemlist) > 0)) {
- if (self::$itemlist[0]['uri'] == self::$itemlist[0]['parent-uri']) {
+ if (self::$itemlist[0]['uri'] == self::$itemlist[0]['thr-parent']) {
// We will import it everytime, when it is started by our contacts
$valid = Contact::isSharingByURL(self::$itemlist[0]['author-link'], self::$itemlist[0]['uid']);
}
} else {
// But we will only import complete threads
- $valid = Item::exists(['uid' => $importer["uid"], 'uri' => self::$itemlist[0]['parent-uri']]);
+ $valid = Item::exists(['uid' => $importer["uid"], 'uri' => self::$itemlist[0]['thr-parent']]);
if ($valid) {
- Logger::log("Item with uri ".self::$itemlist[0]["uri"]." belongs to parent ".self::$itemlist[0]['parent-uri']." of user ".$importer["uid"].". It will be imported.", Logger::DEBUG);
+ Logger::log("Item with uri ".self::$itemlist[0]["uri"]." belongs to parent ".self::$itemlist[0]['thr-parent']." of user ".$importer["uid"].". It will be imported.", Logger::DEBUG);
}
}
if (is_object($inreplyto->item(0))) {
foreach ($inreplyto->item(0)->attributes as $attributes) {
if ($attributes->name == "ref") {
- $item["parent-uri"] = $attributes->textContent;
+ $item["thr-parent"] = $attributes->textContent;
}
if ($attributes->name == "href") {
$related = $attributes->textContent;
self::fetchConversation($item['conversation-href'], $item['conversation-uri']);
}
- if (isset($item["parent-uri"])) {
- if (!Item::exists(['uid' => $importer["uid"], 'uri' => $item['parent-uri']])) {
+ if (isset($item["thr-parent"])) {
+ if (!Item::exists(['uid' => $importer["uid"], 'uri' => $item['thr-parent']])) {
if ($related != '') {
- self::fetchRelated($related, $item["parent-uri"], $importer);
+ self::fetchRelated($related, $item["thr-parent"], $importer);
}
} else {
Logger::log('Reply with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', Logger::DEBUG);
}
} else {
- $item["parent-uri"] = $item["uri"];
+ $item["thr-parent"] = $item["uri"];
$item["gravity"] = GRAVITY_PARENT;
}
if (is_object($inreplyto->item(0))) {
foreach ($inreplyto->item(0)->attributes as $attributes) {
if ($attributes->name == "ref") {
- $item["parent-uri"] = $attributes->textContent;
+ $item["thr-parent"] = $attributes->textContent;
}
}
}
break;
case "related":
if ($item["object-type"] != Activity\ObjectType::BOOKMARK) {
- if (!isset($item["parent-uri"])) {
- $item["parent-uri"] = $attribute['href'];
+ if (!isset($item["thr-parent"])) {
+ $item["thr-parent"] = $attribute['href'];
}
$link_data['related'] = $attribute['href'];
} else {
if ($item['gravity'] != GRAVITY_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]);
+ $thrparent = Item::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"];
}
$attributes = [
- "ref" => $parent_item,
+ "ref" => $item['thr-parent'],
"href" => $parent_plink];
XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
}
if (intval($item['parent']) > 0) {
- $conversation_href = $conversation_uri = str_replace('/objects/', '/context/', $item['parent-uri']);
+ $conversation_href = $conversation_uri = str_replace('/objects/', '/context/', $item['thr-parent']);
if (isset($parent_item)) {
$conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $parent_item]);
}
}
- if (empty($datarray['parent-uri'])) {
- $datarray['parent-uri'] = $datarray['uri'];
+ if (!empty($datarray['parent-uri'])) {
+ $datarray['thr-parent'] = $datarray['parent-uri'];
}
unset($datarray['parent-uri']);
$datarray['owner-link'] = "mailto:".$contact['addr'];
$datarray['owner-avatar'] = $contact['photo'];
- if ($datarray['parent-uri'] === $datarray['uri']) {
+ if ($datarray['thr-parent'] === $datarray['uri']) {
$datarray['private'] = Item::PRIVATE;
}