From fc0031f4ba37117c25b2a613731951a82eb41a6c Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 24 Dec 2017 11:36:30 +0000 Subject: [PATCH] First steps to support public likes --- include/like.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/include/like.php b/include/like.php index 6b8c138b9..05bb758c2 100644 --- a/include/like.php +++ b/include/like.php @@ -80,22 +80,26 @@ function do_like($item_id, $verb) { $item = $items[0]; - if (!can_write_wall($a, $item['uid'])) { + if (!can_write_wall($a, $item['uid']) && ($item['uid'] != 0)) { logger('like: unable to write on wall ' . $item['uid']); return false; } // Retrieves the local post owner - $owners = q("SELECT `contact`.* FROM `contact` - WHERE `contact`.`self` - AND `contact`.`uid` = %d", - intval($item['uid']) - ); - if (DBM::is_result($owners)) { - $owner_self_contact = $owners[0]; + if ($item['uid'] != 0) { + $owners = q("SELECT `contact`.* FROM `contact` + WHERE `contact`.`self` + AND `contact`.`uid` = %d", + intval($item['uid']) + ); + if (DBM::is_result($owners)) { + $owner_self_contact = $owners[0]; + } else { + logger('like: unknown owner ' . $item['uid']); + return false; + } } else { - logger('like: unknown owner ' . $item['uid']); - return false; + $owner_self_contact = ['uid' => 0, 'nick' => 'feed-item']; } // Retrieve the current logged in user's public contact