Merge pull request #4143 from annando/comment-public
Likes on "uid=0" does work now
This commit is contained in:
commit
c40466fe2d
3 changed files with 34 additions and 26 deletions
|
@ -24,7 +24,7 @@ use Friendica\Protocol\Diaspora;
|
|||
function do_like($item_id, $verb) {
|
||||
$a = get_app();
|
||||
|
||||
if (! local_user() && ! remote_user()) {
|
||||
if (!local_user() && !remote_user()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -73,28 +73,33 @@ function do_like($item_id, $verb) {
|
|||
dbesc($item_id)
|
||||
);
|
||||
|
||||
if (! $item_id || ! DBM::is_result($items)) {
|
||||
if (!$item_id || !DBM::is_result($items)) {
|
||||
logger('like: unknown item ' . $item_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
$item = $items[0];
|
||||
$uid = $item['uid'];
|
||||
|
||||
if (! can_write_wall($a, $item['uid'])) {
|
||||
logger('like: unable to write on wall ' . $item['uid']);
|
||||
if (($uid == 0) && local_user()) {
|
||||
$uid = local_user();
|
||||
}
|
||||
|
||||
if (!can_write_wall($a, $uid)) {
|
||||
logger('like: unable to write on wall ' . $uid);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Retrieves the local post owner
|
||||
$owners = q("SELECT `contact`.* FROM `contact`
|
||||
WHERE `contact`.`self` = 1
|
||||
WHERE `contact`.`self`
|
||||
AND `contact`.`uid` = %d",
|
||||
intval($item['uid'])
|
||||
intval($uid)
|
||||
);
|
||||
if (DBM::is_result($owners)) {
|
||||
$owner_self_contact = $owners[0];
|
||||
} else {
|
||||
logger('like: unknown owner ' . $item['uid']);
|
||||
logger('like: unknown owner ' . $uid);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -112,11 +117,11 @@ function do_like($item_id, $verb) {
|
|||
}
|
||||
|
||||
// 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 = $owner_self_contact;
|
||||
} 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",
|
||||
intval($item_contact_id)
|
||||
|
@ -240,9 +245,8 @@ EOT;
|
|||
|
||||
// @todo: Explain this block
|
||||
if (! $item['visible']) {
|
||||
q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
|
||||
intval($item['id']),
|
||||
intval($item['uid'])
|
||||
q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d",
|
||||
intval($item['id'])
|
||||
);
|
||||
}
|
||||
|
||||
|
|
29
mod/like.php
29
mod/like.php
|
@ -3,33 +3,35 @@
|
|||
use Friendica\App;
|
||||
use Friendica\Core\System;
|
||||
|
||||
require_once('include/security.php');
|
||||
require_once('include/bbcode.php');
|
||||
require_once('include/items.php');
|
||||
require_once('include/like.php');
|
||||
require_once 'include/security.php';
|
||||
require_once 'include/bbcode.php';
|
||||
require_once 'include/items.php';
|
||||
require_once 'include/like.php';
|
||||
|
||||
function like_content(App $a) {
|
||||
if(! local_user() && ! remote_user()) {
|
||||
if (!local_user() && !remote_user()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$verb = notags(trim($_GET['verb']));
|
||||
|
||||
if(! $verb)
|
||||
if (!$verb) {
|
||||
$verb = 'like';
|
||||
}
|
||||
|
||||
$item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
|
||||
|
||||
$r = do_like($item_id, $verb);
|
||||
if (!$r) return;
|
||||
if (!$r) {
|
||||
return;
|
||||
}
|
||||
|
||||
// See if we've been passed a return path to redirect to
|
||||
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
|
||||
|
||||
like_content_return(System::baseUrl(), $return_path);
|
||||
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
|
||||
|
||||
function like_content_return($baseurl, $return_path) {
|
||||
|
||||
if($return_path) {
|
||||
if ($return_path) {
|
||||
$rand = '_=' . time();
|
||||
if(strpos($return_path, '?')) $rand = "&$rand";
|
||||
else $rand = "?$rand";
|
||||
if (strpos($return_path, '?')) {
|
||||
$rand = "&$rand";
|
||||
} else {
|
||||
$rand = "?$rand";
|
||||
}
|
||||
|
||||
goaway($baseurl . "/" . $return_path . $rand);
|
||||
}
|
||||
|
||||
killme();
|
||||
}
|
||||
|
||||
|
|
|
@ -280,7 +280,6 @@ class Notifier {
|
|||
}
|
||||
}
|
||||
if ($relay_to_owner) {
|
||||
logger('notifier: followup '.$target_item["guid"], LOGGER_DEBUG);
|
||||
// local followup to remote post
|
||||
$followup = true;
|
||||
$public_message = false; // not public
|
||||
|
@ -288,6 +287,8 @@ class Notifier {
|
|||
$recipients = 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'] &&
|
||||
(strlen($target_item['allow_cid'].$target_item['allow_gid'].
|
||||
|
|
Loading…
Reference in a new issue