Merge pull request #4143 from annando/comment-public

Likes on "uid=0" does work now
This commit is contained in:
Hypolite Petovan 2017-12-27 20:05:20 -06:00 committed by GitHub
commit c40466fe2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 26 deletions

View file

@ -79,22 +79,27 @@ function do_like($item_id, $verb) {
} }
$item = $items[0]; $item = $items[0];
$uid = $item['uid'];
if (! can_write_wall($a, $item['uid'])) { if (($uid == 0) && local_user()) {
logger('like: unable to write on wall ' . $item['uid']); $uid = local_user();
}
if (!can_write_wall($a, $uid)) {
logger('like: unable to write on wall ' . $uid);
return false; return false;
} }
// Retrieves the local post owner // Retrieves the local post owner
$owners = q("SELECT `contact`.* FROM `contact` $owners = q("SELECT `contact`.* FROM `contact`
WHERE `contact`.`self` = 1 WHERE `contact`.`self`
AND `contact`.`uid` = %d", AND `contact`.`uid` = %d",
intval($item['uid']) intval($uid)
); );
if (DBM::is_result($owners)) { if (DBM::is_result($owners)) {
$owner_self_contact = $owners[0]; $owner_self_contact = $owners[0];
} else { } else {
logger('like: unknown owner ' . $item['uid']); logger('like: unknown owner ' . $uid);
return false; return false;
} }
@ -112,11 +117,11 @@ function do_like($item_id, $verb) {
} }
// Contact-id is the uid-dependant author contact // Contact-id is the uid-dependant author contact
if (local_user() == $item['uid']) { if (local_user() == $uid) {
$item_contact_id = $owner_self_contact['id']; $item_contact_id = $owner_self_contact['id'];
$item_contact = $owner_self_contact; $item_contact = $owner_self_contact;
} else { } else {
$item_contact_id = Contact::getIdForURL($author_contact['url'], $item['uid']); $item_contact_id = Contact::getIdForURL($author_contact['url'], $uid);
$contacts = q("SELECT * FROM `contact` WHERE `id` = %d", $contacts = q("SELECT * FROM `contact` WHERE `id` = %d",
intval($item_contact_id) intval($item_contact_id)
@ -240,9 +245,8 @@ EOT;
// @todo: Explain this block // @todo: Explain this block
if (! $item['visible']) { if (! $item['visible']) {
q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d", q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d",
intval($item['id']), intval($item['id'])
intval($item['uid'])
); );
} }

View file

@ -3,10 +3,10 @@
use Friendica\App; use Friendica\App;
use Friendica\Core\System; use Friendica\Core\System;
require_once('include/security.php'); require_once 'include/security.php';
require_once('include/bbcode.php'); require_once 'include/bbcode.php';
require_once('include/items.php'); require_once 'include/items.php';
require_once('include/like.php'); require_once 'include/like.php';
function like_content(App $a) { function like_content(App $a) {
if (!local_user() && !remote_user()) { if (!local_user() && !remote_user()) {
@ -16,20 +16,22 @@ function like_content(App $a) {
$verb = notags(trim($_GET['verb'])); $verb = notags(trim($_GET['verb']));
if(! $verb) if (!$verb) {
$verb = 'like'; $verb = 'like';
}
$item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0); $item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
$r = do_like($item_id, $verb); $r = do_like($item_id, $verb);
if (!$r) return; if (!$r) {
return;
}
// See if we've been passed a return path to redirect to // See if we've been passed a return path to redirect to
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
like_content_return(System::baseUrl(), $return_path); like_content_return(System::baseUrl(), $return_path);
killme(); // NOTREACHED killme(); // NOTREACHED
// return; // NOTREACHED
} }
@ -37,15 +39,16 @@ function like_content(App $a) {
// then redirect back to the calling page. If not, just quietly end // then redirect back to the calling page. If not, just quietly end
function like_content_return($baseurl, $return_path) { function like_content_return($baseurl, $return_path) {
if ($return_path) { if ($return_path) {
$rand = '_=' . time(); $rand = '_=' . time();
if(strpos($return_path, '?')) $rand = "&$rand"; if (strpos($return_path, '?')) {
else $rand = "?$rand"; $rand = "&$rand";
} else {
$rand = "?$rand";
}
goaway($baseurl . "/" . $return_path . $rand); goaway($baseurl . "/" . $return_path . $rand);
} }
killme(); killme();
} }

View file

@ -280,7 +280,6 @@ class Notifier {
} }
} }
if ($relay_to_owner) { if ($relay_to_owner) {
logger('notifier: followup '.$target_item["guid"], LOGGER_DEBUG);
// local followup to remote post // local followup to remote post
$followup = true; $followup = true;
$public_message = false; // not public $public_message = false; // not public
@ -288,6 +287,8 @@ class Notifier {
$recipients = array($parent['contact-id']); $recipients = array($parent['contact-id']);
$recipients_followup = array($parent['contact-id']); $recipients_followup = array($parent['contact-id']);
logger('notifier: followup '.$target_item["guid"].' to '.$conversant_str, LOGGER_DEBUG);
//if (!$target_item['private'] && $target_item['wall'] && //if (!$target_item['private'] && $target_item['wall'] &&
if (!$target_item['private'] && if (!$target_item['private'] &&
(strlen($target_item['allow_cid'].$target_item['allow_gid']. (strlen($target_item['allow_cid'].$target_item['allow_gid'].