Unified content that is stored for a like
This commit is contained in:
parent
da954b92c7
commit
32d398cc93
|
@ -1924,50 +1924,6 @@ class Diaspora
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Creates the body for a "like" message
|
|
||||||
*
|
|
||||||
* @param array $contact The contact that send us the "like"
|
|
||||||
* @param array $parent_item The item array of the parent item
|
|
||||||
* @param string $guid message guid
|
|
||||||
*
|
|
||||||
* @return string the body
|
|
||||||
*/
|
|
||||||
private static function constructLikeBody($contact, $parent_item, $guid)
|
|
||||||
{
|
|
||||||
$bodyverb = L10n::t('%1$s likes %2$s\'s %3$s');
|
|
||||||
|
|
||||||
$ulink = "[url=".$contact["url"]."]".$contact["name"]."[/url]";
|
|
||||||
$alink = "[url=".$parent_item["author-link"]."]".$parent_item["author-name"]."[/url]";
|
|
||||||
$plink = "[url=".System::baseUrl()."/display/".urlencode($guid)."]".L10n::t("status")."[/url]";
|
|
||||||
|
|
||||||
return sprintf($bodyverb, $ulink, $alink, $plink);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Creates a XML object for a "like"
|
|
||||||
*
|
|
||||||
* @param array $importer Array of the importer user
|
|
||||||
* @param array $parent_item The item array of the parent item
|
|
||||||
*
|
|
||||||
* @return string The XML
|
|
||||||
*/
|
|
||||||
private static function constructLikeObject($importer, $parent_item)
|
|
||||||
{
|
|
||||||
$objtype = ACTIVITY_OBJ_NOTE;
|
|
||||||
$link = '<link rel="alternate" type="text/html" href="'.System::baseUrl()."/display/".$importer["nickname"]."/".$parent_item["id"].'" />';
|
|
||||||
$parent_body = $parent_item["body"];
|
|
||||||
|
|
||||||
$xmldata = ["object" => ["type" => $objtype,
|
|
||||||
"local" => "1",
|
|
||||||
"id" => $parent_item["uri"],
|
|
||||||
"link" => $link,
|
|
||||||
"title" => "",
|
|
||||||
"content" => $parent_body]];
|
|
||||||
|
|
||||||
return XML::fromArray($xmldata, $xml, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Processes "like" messages
|
* @brief Processes "like" messages
|
||||||
*
|
*
|
||||||
|
@ -2046,9 +2002,8 @@ class Diaspora
|
||||||
$datarray["parent-uri"] = $parent_item["uri"];
|
$datarray["parent-uri"] = $parent_item["uri"];
|
||||||
|
|
||||||
$datarray["object-type"] = ACTIVITY_OBJ_NOTE;
|
$datarray["object-type"] = ACTIVITY_OBJ_NOTE;
|
||||||
$datarray["object"] = self::constructLikeObject($importer, $parent_item);
|
|
||||||
|
|
||||||
$datarray["body"] = self::constructLikeBody($contact, $parent_item, $guid);
|
$datarray["body"] = $verb;
|
||||||
|
|
||||||
// like on comments have the comment as parent. So we need to fetch the toplevel parent
|
// like on comments have the comment as parent. So we need to fetch the toplevel parent
|
||||||
if ($parent_item["id"] != $parent_item["parent"]) {
|
if ($parent_item["id"] != $parent_item["parent"]) {
|
||||||
|
|
|
@ -338,7 +338,7 @@ class OStatus
|
||||||
$header = [];
|
$header = [];
|
||||||
$header["uid"] = $importer["uid"];
|
$header["uid"] = $importer["uid"];
|
||||||
$header["network"] = NETWORK_OSTATUS;
|
$header["network"] = NETWORK_OSTATUS;
|
||||||
$header["type"] = "remote";
|
$header["type"] = "remote-comment";
|
||||||
$header["wall"] = 0;
|
$header["wall"] = 0;
|
||||||
$header["origin"] = 0;
|
$header["origin"] = 0;
|
||||||
$header["gravity"] = GRAVITY_COMMENT;
|
$header["gravity"] = GRAVITY_COMMENT;
|
||||||
|
@ -449,9 +449,11 @@ class OStatus
|
||||||
$orig_uri = $xpath->query("activity:object/atom:id", $entry)->item(0)->nodeValue;
|
$orig_uri = $xpath->query("activity:object/atom:id", $entry)->item(0)->nodeValue;
|
||||||
logger("Favorite ".$orig_uri." ".print_r($item, true));
|
logger("Favorite ".$orig_uri." ".print_r($item, true));
|
||||||
|
|
||||||
|
$item["type"] = "activity";
|
||||||
$item["verb"] = ACTIVITY_LIKE;
|
$item["verb"] = ACTIVITY_LIKE;
|
||||||
$item["parent-uri"] = $orig_uri;
|
$item["parent-uri"] = $orig_uri;
|
||||||
$item["gravity"] = GRAVITY_ACTIVITY;
|
$item["gravity"] = GRAVITY_ACTIVITY;
|
||||||
|
$item["object-type"] = ACTIVITY_OBJ_NOTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://activitystrea.ms/schema/1.0/rsvp-yes
|
// http://activitystrea.ms/schema/1.0/rsvp-yes
|
||||||
|
@ -681,11 +683,10 @@ class OStatus
|
||||||
} else {
|
} else {
|
||||||
logger('Reply with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG);
|
logger('Reply with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
$item["type"] = 'remote-comment';
|
|
||||||
} else {
|
} else {
|
||||||
$item["parent-uri"] = $item["uri"];
|
$item["parent-uri"] = $item["uri"];
|
||||||
$item["gravity"] = GRAVITY_PARENT;
|
$item["gravity"] = GRAVITY_PARENT;
|
||||||
|
$item["type"] = "remote";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($item['author-link'] != '') && !empty($item['protocol'])) {
|
if (($item['author-link'] != '') && !empty($item['protocol'])) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user