Make it easier

This commit is contained in:
Michael 2017-12-27 21:51:16 +00:00
parent 1c72a71933
commit 9acc2ffc24
2 changed files with 22 additions and 16 deletions

View file

@ -81,13 +81,16 @@ function do_like($item_id, $verb) {
$item = $items[0]; $item = $items[0];
$uid = $item['uid']; $uid = $item['uid'];
if (!can_write_wall($a, $uid) && (($uid != 0) || !local_user())) { if (($uid == 0) && local_user()) {
$uid = local_user();
}
if (!can_write_wall($a, $uid)) {
logger('like: unable to write on wall ' . $uid); logger('like: unable to write on wall ' . $uid);
return false; return false;
} }
// Retrieves the local post owner // Retrieves the local post owner
if ($uid != 0) {
$owners = q("SELECT `contact`.* FROM `contact` $owners = q("SELECT `contact`.* FROM `contact`
WHERE `contact`.`self` WHERE `contact`.`self`
AND `contact`.`uid` = %d", AND `contact`.`uid` = %d",
@ -99,10 +102,6 @@ function do_like($item_id, $verb) {
logger('like: unknown owner ' . $uid); logger('like: unknown owner ' . $uid);
return false; return false;
} }
} else {
$uid = local_user();
$owner_self_contact = ['uid' => 0, 'nick' => 'feed-item'];
}
// Retrieve the current logged in user's public contact // Retrieve the current logged in user's public contact
$author_id = public_contact(); $author_id = public_contact();

View file

@ -154,10 +154,12 @@ class Notifier {
FROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d AND visible AND NOT moderated ORDER BY `id` ASC", FROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d AND visible AND NOT moderated ORDER BY `id` ASC",
intval($parent_id) intval($parent_id)
); );
logger('Blubb: a-'.$item_id);
if (!count($items)) { if (!count($items)) {
return; return;
} }
logger('Blubb: b-'.$item_id);
// avoid race condition with deleting entries // avoid race condition with deleting entries
if ($items[0]['deleted']) { if ($items[0]['deleted']) {
@ -171,11 +173,13 @@ class Notifier {
$top_level = true; $top_level = true;
} }
} }
logger('Blubb: 0-'.$item_id.' - '.$uid);
$owner = User::getOwnerDataById($uid); $owner = User::getOwnerDataById($uid);
if (!$owner) { if (!$owner) {
return; return;
} }
logger('Blubb: 1-'.$item_id);
$walltowall = ($top_level && ($owner['id'] != $items[0]['contact-id']) ? true : false); $walltowall = ($top_level && ($owner['id'] != $items[0]['contact-id']) ? true : false);
@ -193,12 +197,14 @@ class Notifier {
// fill this in with a single salmon slap if applicable // fill this in with a single salmon slap if applicable
$slap = ''; $slap = '';
logger('Blubb: 2-'.$item_id);
if (! ($mail || $fsuggest || $relocate)) { if (! ($mail || $fsuggest || $relocate)) {
$slap = OStatus::salmon($target_item, $owner); $slap = OStatus::salmon($target_item, $owner);
$parent = $items[0]; $parent = $items[0];
logger('Blubb: 3-'.$item_id);
$thr_parent = q("SELECT `network`, `author-link`, `owner-link` FROM `item` WHERE `uri` = '%s' AND `uid` = %d", $thr_parent = q("SELECT `network`, `author-link`, `owner-link` FROM `item` WHERE `uri` = '%s' AND `uid` = %d",
dbesc($target_item["thr-parent"]), intval($target_item["uid"])); dbesc($target_item["thr-parent"]), intval($target_item["uid"]));
@ -280,7 +286,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 +293,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'].