1
0
Fork 0

More item abstractions for DFRN and Diaspora

This commit is contained in:
Michael 2018-06-16 22:32:57 +00:00
parent 6f9ec690aa
commit 1aec8f620d
3 changed files with 108 additions and 141 deletions

View file

@ -162,9 +162,6 @@ class Item extends BaseObject
{
/*
These Fields are not added below. They are here to for bug search.
'type', 'extid', 'changed', 'moderated', 'target-type', 'target', 'resource-id',
'tag', 'inform', 'pubmail', 'visible', 'bookmark', 'unseen', 'deleted',
'forum_mode', 'mention', 'global', 'shadow',
*/
$item_fields = ['author-id', 'owner-id', 'contact-id', 'uid', 'id', 'parent',
@ -172,13 +169,24 @@ class Item extends BaseObject
'commented', 'created', 'edited', 'received', 'verb', 'object-type', 'postopts', 'plink',
'guid', 'wall', 'private', 'starred', 'origin', 'title', 'body', 'file', 'event-id',
'location', 'coord', 'app', 'attach', 'rendered-hash', 'rendered-html', 'object',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'unseen',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
'id' => 'item_id', 'network' => 'item_network'];
// The additional fields aren't needed to be selected by default.
// We need them to select the correct tables. To see the difference we split the arrays
if (!empty($selected)) {
$additional_item_fields = ['type', 'extid', 'changed', 'moderated', 'target-type', 'target',
'resource-id', 'tag', 'inform', 'pubmail', 'visible', 'bookmark', 'unseen', 'deleted',
'forum_mode', 'mention', 'global', 'shadow'];
$item_fields = array_merge($item_fields, $additional_item_fields);
}
$author_fields = ['url' => 'author-link', 'name' => 'author-name', 'thumb' => 'author-avatar'];
$owner_fields = ['url' => 'owner-link', 'name' => 'owner-name', 'thumb' => 'owner-avatar'];
$contact_fields = ['url' => 'contact-link', 'name' => 'contact-name', 'thumb' => 'contact-avatar',
'network', 'url', 'name', 'writable', 'self', 'id' => 'cid', 'alias'];
'network', 'url', 'name', 'writable', 'self', 'id' => 'cid', 'alias',
'photo', 'name-date', 'uri-date', 'avatar-date', 'thumb', 'dfrn-id'];
$event_fields = ['created' => 'event-created', 'edited' => 'event-edited',
'start' => 'event-start','finish' => 'event-finish',
@ -193,6 +201,7 @@ class Item extends BaseObject
if (!empty($selected)) {
$fields['parent-item'] = ['guid' => 'parent-guid'];
$fields['parent-item-author'] = ['url' => 'parent-author-link', 'name' => 'parent-author-name'];
$fields['sign'] = ['signed_text', 'signature', 'signer'];
}
return $fields;
@ -257,6 +266,10 @@ class Item extends BaseObject
$joins .= " LEFT JOIN `event` ON `event-id` = `event`.`id`";
}
if (strpos($sql_commands, "`sign`.") !== false) {
$joins .= " LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id`";
}
if ((strpos($sql_commands, "`parent-item`.") !== false) || (strpos($sql_commands, "`parent-author`.") !== false)) {
$joins .= " STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`";
}

View file

@ -228,17 +228,10 @@ class DFRN
$check_date = DateTimeFormat::utc($last_update);
$r = q(
"SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`network`, `contact`.`photo`, `contact`.`url`,
`contact`.`name-date`, `contact`.`uri-date`, `contact`.`avatar-date`,
`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
`sign`.`signed_text`, `sign`.`signature`, `sign`.`signer`
"SELECT `item`.`id`
FROM `item` USE INDEX (`uid_wall_changed`) $sql_post_table
STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id`
WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND `item`.`parent` != 0
AND `item`.`wall` AND `item`.`changed` > '%s'
WHERE `item`.`uid` = %d AND `item`.`wall` AND `item`.`changed` > '%s'
$sql_extra
ORDER BY `item`.`parent` ".$sort.", `item`.`created` ASC LIMIT 0, 300",
intval($owner_id),
@ -246,13 +239,26 @@ class DFRN
dbesc($sort)
);
$ids = [];
foreach ($r as $item) {
$ids[] = $item['id'];
}
$condition = ['id' => $ids];
$fields = ['author-id', 'uid', 'id', 'parent', 'uri', 'thr-parent',
'parent-uri', 'created', 'edited', 'verb', 'object-type',
'guid', 'private', 'title', 'body', 'location', 'coord', 'app',
'attach', 'object', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
'extid', 'target', 'tag', 'bookmark', 'deleted',
'author-link', 'owner-link', 'signed_text', 'signature', 'signer'];
$ret = Item::select($owner_id, $fields, $condition);
$items = dba::inArray($ret);
/*
* Will check further below if this actually returned results.
* We will provide an empty feed if that is the case.
*/
$items = $r;
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
@ -321,33 +327,24 @@ class DFRN
public static function itemFeed($item_id, $conversation = false)
{
if ($conversation) {
$condition = '`item`.`parent`';
$condition = ['parent' => $item_id];
} else {
$condition = '`item`.`id`';
$condition = ['id' => $item_id];
}
$r = q(
"SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`network`, `contact`.`photo`, `contact`.`url`,
`contact`.`name-date`, `contact`.`uri-date`, `contact`.`avatar-date`,
`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
`sign`.`signed_text`, `sign`.`signature`, `sign`.`signer`
FROM `item`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id`
WHERE %s = %d AND `item`.`visible` AND NOT `item`.`moderated` AND `item`.`parent` != 0
AND NOT `item`.`private`",
$condition,
intval($item_id)
);
if (!DBM::is_result($r)) {
$fields = ['author-id', 'uid', 'id', 'parent', 'uri', 'thr-parent',
'parent-uri', 'created', 'edited', 'verb', 'object-type',
'guid', 'private', 'title', 'body', 'location', 'coord', 'app',
'attach', 'object', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
'extid', 'target', 'tag', 'bookmark', 'deleted',
'author-link', 'owner-link', 'signed_text', 'signature', 'signer'];
$ret = Item::select(0, $fields, $condition);
$items = dba::inArray($ret);
if (!DBM::is_result($items)) {
killme();
}
$items = $r;
$item = $r[0];
$item = $items[0];
if ($item['uid'] != 0) {
$owner = User::getOwnerDataById($item['uid']);
@ -2253,6 +2250,8 @@ class DFRN
}
if ($Blink && link_compare($Blink, System::baseUrl() . "/profile/" . $importer["nickname"])) {
$author = dba::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]);
// send a notification
notification(
[
@ -2264,10 +2263,9 @@ class DFRN
"uid" => $importer["importer_uid"],
"item" => $item,
"link" => System::baseUrl()."/display/".urlencode(Item::getGuidById($posted_id)),
"source_name" => stripslashes($item["author-name"]),
"source_link" => $item["author-link"],
"source_photo" => ((link_compare($item["author-link"], $importer["url"]))
? $importer["thumb"] : $item["author-avatar"]),
"source_name" => $author["name"],
"source_link" => $author["url"],
"source_photo" => $author["thumb"],
"verb" => $item["verb"],
"otype" => "person",
"activity" => $verb,
@ -2334,9 +2332,9 @@ class DFRN
// only one like or dislike per person
// splitted into two queries for performance issues
$r = q(
"SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `parent-uri` = '%s' AND NOT `deleted` LIMIT 1",
"SELECT `id` FROM `item` WHERE `uid` = %d AND `author-id` = %d AND `verb` = '%s' AND `parent-uri` = '%s' AND NOT `deleted` LIMIT 1",
intval($item["uid"]),
dbesc($item["author-link"]),
intval($item["author-id"]),
dbesc($item["verb"]),
dbesc($item["parent-uri"])
);
@ -2345,9 +2343,9 @@ class DFRN
}
$r = q(
"SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1",
"SELECT `id` FROM `item` WHERE `uid` = %d AND `author-id` = %d AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1",
intval($item["uid"]),
dbesc($item["author-link"]),
intval($item["author-id"]),
dbesc($item["verb"]),
dbesc($item["parent-uri"])
);
@ -2469,16 +2467,14 @@ class DFRN
// Fetch the owner
$owner = self::fetchauthor($xpath, $entry, $importer, "dfrn:owner", true);
$item["owner-name"] = $owner["name"];
$item["owner-link"] = $owner["link"];
$item["owner-avatar"] = $owner["avatar"];
$item["owner-id"] = Contact::getIdForURL($owner["link"], 0);
// fetch the author
$author = self::fetchauthor($xpath, $entry, $importer, "atom:author", true);
$item["author-name"] = $author["name"];
$item["author-link"] = $author["link"];
$item["author-avatar"] = $author["avatar"];
$item["author-id"] = Contact::getIdForURL($author["link"], 0);
$item["title"] = $xpath->query("atom:title/text()", $entry)->item(0)->nodeValue;
@ -2736,9 +2732,8 @@ class DFRN
* but we're going to unconditionally correct it here so that the post will always be owned by our contact.
*/
logger('Correcting item owner.', LOGGER_DEBUG);
$item["owner-name"] = $importer["senderName"];
$item["owner-link"] = $importer["url"];
$item["owner-avatar"] = $importer["thumb"];
$item["owner-link"] = $importer["url"];
$item["owner-id"] = Contact::getIdForURL($importer["url"], 0);
}
if (($importer["rel"] == CONTACT_IS_FOLLOWER) && (!self::tgroupCheck($importer["importer_uid"], $item))) {

View file

@ -69,7 +69,7 @@ class Diaspora
if (Config::get("system", "relay_directly", false)) {
// We distribute our stuff based on the parent to ensure that the thread will be complete
$parent = dba::selectFirst('item', ['parent'], ['id' => $item_id]);
$parent = Item::selectFirst(0, ['parent'], ['id' => $item_id]);
if (!DBM::is_result($parent)) {
return;
}
@ -1170,15 +1170,10 @@ class Diaspora
*/
private static function messageExists($uid, $guid)
{
$r = q(
"SELECT `id` FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
intval($uid),
dbesc($guid)
);
if (DBM::is_result($r)) {
$item = Item::selectFirst($uid, ['id'], ['uid' => $uid, 'guid' => $guid]);
if (DBM::is_result($item)) {
logger("message ".$guid." already exists for user ".$uid);
return $r[0]["id"];
return $item["id"];
}
return false;
@ -1385,16 +1380,13 @@ class Diaspora
*/
private static function parentItem($uid, $guid, $author, $contact)
{
$r = q(
"SELECT `id`, `parent`, `body`, `wall`, `uri`, `guid`, `private`, `origin`,
`author-name`, `author-link`, `author-avatar`,
`owner-name`, `owner-link`, `owner-avatar`
FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
intval($uid),
dbesc($guid)
);
$fields = ['id', 'parent', 'body', 'wall', 'uri', 'guid', 'private', 'origin',
'author-name', 'author-link', 'author-avatar',
'owner-name', 'owner-link', 'owner-avatar'];
$condition = ['uid' => $uid, 'guid' => $guid];
$item = Item::selectFirst($uid, $fields, $condition);
if (!$r) {
if (!DBM::is_result($item)) {
$result = self::storeByGuid($guid, $contact["url"], $uid);
if (!$result) {
@ -1405,23 +1397,16 @@ class Diaspora
if ($result) {
logger("Fetched missing item ".$guid." - result: ".$result, LOGGER_DEBUG);
$r = q(
"SELECT `id`, `body`, `wall`, `uri`, `private`, `origin`,
`author-name`, `author-link`, `author-avatar`,
`owner-name`, `owner-link`, `owner-avatar`
FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
intval($uid),
dbesc($guid)
);
$item = Item::selectFirst($uid, $fields, $condition);
}
}
if (!$r) {
if (!DBM::is_result($item)) {
logger("parent item not found: parent: ".$guid." - user: ".$uid);
return false;
} else {
logger("parent item found: parent: ".$guid." - user: ".$uid);
return $r[0];
return $item;
}
}
@ -1602,7 +1587,7 @@ class Diaspora
*/
private static function getUriFromGuid($author, $guid, $onlyfound = false)
{
$item = dba::selectFirst('item', ['uri'], ['guid' => $guid]);
$item = Item::selectFirst(0, ['uri'], ['guid' => $guid]);
if (DBM::is_result($item)) {
return $item["uri"];
} elseif (!$onlyfound) {
@ -1632,9 +1617,9 @@ class Diaspora
*/
private static function getGuidFromUri($uri, $uid)
{
$r = q("SELECT `guid` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($uri), intval($uid));
if (DBM::is_result($r)) {
return $r[0]["guid"];
$item = Item::selectFirst($uid, ['guid'], ['uri' => $uri, 'uid' => $uid]);
if (DBM::is_result($item)) {
return $item["guid"];
} else {
return false;
}
@ -1649,11 +1634,10 @@ class Diaspora
*/
private static function importerForGuid($guid)
{
$item = dba::fetch_first("SELECT `uid` FROM `item` WHERE `origin` AND `guid` = ? LIMIT 1", $guid);
$item = Item::selectFirst(0, ['uid'], ['origin' => true, 'guid' => $guid]);
if (DBM::is_result($item)) {
logger("Found user ".$item['uid']." as owner of item ".$guid, LOGGER_DEBUG);
$contact = dba::fetch_first("SELECT * FROM `contact` WHERE `self` AND `uid` = ?", $item['uid']);
$contact = dba::selectFirst('contact', [], ['self' => true, 'uid' => $item['uid']]);
if (DBM::is_result($contact)) {
return $contact;
}
@ -1721,13 +1705,11 @@ class Diaspora
$datarray["contact-id"] = $author_contact["cid"];
$datarray["network"] = $author_contact["network"];
$datarray["author-name"] = $person["name"];
$datarray["author-link"] = $person["url"];
$datarray["author-avatar"] = ((x($person, "thumb")) ? $person["thumb"] : $person["photo"]);
$datarray["author-id"] = Contact::getIdForURL($person["url"], 0);
$datarray["owner-name"] = $contact["name"];
$datarray["owner-link"] = $contact["url"];
$datarray["owner-avatar"] = ((x($contact, "thumb")) ? $contact["thumb"] : $contact["photo"]);
$datarray["owner-id"] = Contact::getIdForURL($contact["url"], 0);
$datarray["guid"] = $guid;
$datarray["uri"] = self::getUriFromGuid($author, $guid);
@ -2056,13 +2038,11 @@ class Diaspora
$datarray["contact-id"] = $author_contact["cid"];
$datarray["network"] = $author_contact["network"];
$datarray["author-name"] = $person["name"];
$datarray["author-link"] = $person["url"];
$datarray["author-avatar"] = ((x($person, "thumb")) ? $person["thumb"] : $person["photo"]);
$datarray["author-id"] = Contact::getIdForURL($person["url"], 0);
$datarray["owner-name"] = $contact["name"];
$datarray["owner-link"] = $contact["url"];
$datarray["owner-avatar"] = ((x($contact, "thumb")) ? $contact["thumb"] : $contact["photo"]);
$datarray["owner-id"] = Contact::getIdForURL($contact["url"], 0);
$datarray["guid"] = $guid;
$datarray["uri"] = self::getUriFromGuid($author, $guid);
@ -2079,7 +2059,7 @@ class Diaspora
// like on comments have the comment as parent. So we need to fetch the toplevel parent
if ($parent_item["id"] != $parent_item["parent"]) {
$toplevel = dba::selectFirst('item', ['origin'], ['id' => $parent_item["parent"]]);
$toplevel = Item::selectFirst($importer["uid"], ['origin'], ['id' => $parent_item["parent"]]);
$origin = $toplevel["origin"];
} else {
$origin = $parent_item["origin"];
@ -2216,7 +2196,7 @@ class Diaspora
return false;
}
$item = dba::selectFirst('item', ['id'], ['guid' => $parent_guid, 'origin' => true, 'private' => false]);
$item = Item::selectFirst(0, ['id'], ['guid' => $parent_guid, 'origin' => true, 'private' => false]);
if (!DBM::is_result($item)) {
logger('Item not found, no origin or private: '.$parent_guid);
return false;
@ -2237,11 +2217,11 @@ class Diaspora
}
// Send all existing comments and likes to the requesting server
$comments = dba::p("SELECT `item`.`id`, `item`.`verb`, `contact`.`self`
FROM `item`
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`parent` = ? AND `item`.`id` != `item`.`parent`", $item['id']);
$comments = Item::select(0, ['id', 'verb', 'self'], ['parent' => $item['id']]);
while ($comment = dba::fetch($comments)) {
if ($comment['id'] == $comment['parent']) {
continue;
}
if ($comment['verb'] == ACTIVITY_POST) {
$cmd = $comment['self'] ? 'comment-new' : 'comment-import';
} else {
@ -2599,7 +2579,7 @@ class Diaspora
$fields = ['body', 'tag', 'app', 'created', 'object-type', 'uri', 'guid',
'author-name', 'author-link', 'author-avatar'];
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => false];
$item = dba::selectfirst('item', $fields, $condition);
$item = Item::selectFirst(0, $fields, $condition);
if (DBM::is_result($item)) {
logger("reshared message ".$guid." already exists on system.");
@ -2643,7 +2623,7 @@ class Diaspora
$fields = ['body', 'tag', 'app', 'created', 'object-type', 'uri', 'guid',
'author-name', 'author-link', 'author-avatar'];
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => false];
$item = dba::selectfirst('item', $fields, $condition);
$item = Item::selectFirst(0, $fields, $condition);
if (DBM::is_result($item)) {
// If it is a reshared post from another network then reformat to avoid display problems with two share elements
@ -2701,13 +2681,11 @@ class Diaspora
$datarray["contact-id"] = $contact["id"];
$datarray["network"] = NETWORK_DIASPORA;
$datarray["author-name"] = $contact["name"];
$datarray["author-link"] = $contact["url"];
$datarray["author-avatar"] = ((x($contact, "thumb")) ? $contact["thumb"] : $contact["photo"]);
$datarray["author-id"] = Contact::getIdForURL($contact["url"], 0);
$datarray["owner-name"] = $datarray["author-name"];
$datarray["owner-link"] = $datarray["author-link"];
$datarray["owner-avatar"] = $datarray["author-avatar"];
$datarray["owner-id"] = $datarray["author-id"];
$datarray["guid"] = $guid;
$datarray["uri"] = $datarray["parent-uri"] = self::getUriFromGuid($author, $guid);
@ -2787,7 +2765,7 @@ class Diaspora
} else {
$condition = ["`guid` = ? AND `uid` = ? AND NOT `file` LIKE '%%[%%' AND NOT `deleted`", $target_guid, $importer['uid']];
}
$r = dba::select('item', $fields, $condition);
$r = Item::select($importer['uid'], $fields, $condition);
if (!DBM::is_result($r)) {
logger("Target guid ".$target_guid." was not found on this system for user ".$importer['uid'].".");
return false;
@ -2795,7 +2773,7 @@ class Diaspora
while ($item = dba::fetch($r)) {
// Fetch the parent item
$parent = dba::selectFirst('item', ['author-link'], ['id' => $item["parent"]]);
$parent = Item::selectFirst(0, ['author-link'], ['id' => $item["parent"]]);
// Only delete it if the parent author really fits
if (!link_compare($parent["author-link"], $contact["url"]) && !link_compare($item["author-link"], $contact["url"])) {
@ -2921,13 +2899,11 @@ class Diaspora
$datarray["contact-id"] = $contact["id"];
$datarray["network"] = NETWORK_DIASPORA;
$datarray["author-name"] = $contact["name"];
$datarray["author-link"] = $contact["url"];
$datarray["author-avatar"] = ((x($contact, "thumb")) ? $contact["thumb"] : $contact["photo"]);
$datarray["author-id"] = Contact::getIdForURL($contact["url"], 0);
$datarray["owner-name"] = $datarray["author-name"];
$datarray["owner-link"] = $datarray["author-link"];
$datarray["owner-avatar"] = $datarray["author-avatar"];
$datarray["owner-id"] = $datarray["author-id"];
$datarray["guid"] = $guid;
$datarray["uri"] = $datarray["parent-uri"] = self::getUriFromGuid($author, $guid);
@ -3433,7 +3409,7 @@ class Diaspora
if (($guid != "") && $complete) {
$condition = ['guid' => $guid, 'network' => [NETWORK_DFRN, NETWORK_DIASPORA]];
$item = dba::selectFirst('item', ['contact-id'], $condition);
$item = Item::selectFirst(0, ['contact-id'], $condition);
if (DBM::is_result($item)) {
$ret= [];
$ret["root_handle"] = self::handleFromContact($item["contact-id"]);
@ -3700,16 +3676,11 @@ class Diaspora
*/
private static function constructLike($item, $owner)
{
$p = q(
"SELECT `guid`, `uri`, `parent-uri` FROM `item` WHERE `uri` = '%s' LIMIT 1",
dbesc($item["thr-parent"])
);
if (!DBM::is_result($p)) {
$parent = Item::selectFirst(0, ['guid', 'uri', 'parent-uri'], ['uri' => $item["thr-parent"]]);
if (!DBM::is_result($parent)) {
return false;
}
$parent = $p[0];
$target_type = ($parent["uri"] === $parent["parent-uri"] ? "Post" : "Comment");
$positive = null;
if ($item['verb'] === ACTIVITY_LIKE) {
@ -3736,16 +3707,11 @@ class Diaspora
*/
private static function constructAttend($item, $owner)
{
$p = q(
"SELECT `guid`, `uri`, `parent-uri` FROM `item` WHERE `uri` = '%s' LIMIT 1",
dbesc($item["thr-parent"])
);
if (!DBM::is_result($p)) {
$parent = Item::selectFirst(0, ['guid', 'uri', 'parent-uri'], ['uri' => $item["thr-parent"]]);
if (!DBM::is_result($parent)) {
return false;
}
$parent = $p[0];
switch ($item['verb']) {
case ACTIVITY_ATTEND:
$attend_answer = 'accepted';
@ -3785,18 +3751,11 @@ class Diaspora
return $result;
}
$p = q(
"SELECT `guid` FROM `item` WHERE `parent` = %d AND `id` = %d LIMIT 1",
intval($item["parent"]),
intval($item["parent"])
);
if (!DBM::is_result($p)) {
$parent = Item::selectFirst(0, ['guid'], ['id' => $item["parent"], 'parent' => $item["parent"]]);
if (!DBM::is_result($parent)) {
return false;
}
$parent = $p[0];
$text = html_entity_decode(BBCode::toMarkdown($item["body"]));
$created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);
@ -4265,16 +4224,16 @@ class Diaspora
$contact["uprvkey"] = $r[0]['prvkey'];
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($post_id));
if (!DBM::is_result($r)) {
$item = Item::selectFirst(0, [], ['id' => $post_id]);
if (!DBM::is_result($item)) {
return false;
}
if (!in_array($r[0]["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
if (!in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
return false;
}
$message = self::constructLike($r[0], $contact);
$message = self::constructLike($item, $contact);
if ($message === false) {
return false;
}