From c0adf31da9a0d8f897dc68ab632c736891318ad5 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 22 Nov 2020 13:07:03 +0000 Subject: fix like issue with remote channels --- Zotlabs/Module/Like.php | 121 +++++++++++++++++++++++++----------------------- 1 file changed, 64 insertions(+), 57 deletions(-) (limited to 'Zotlabs/Module/Like.php') diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 02fc87756..accf075da 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -66,7 +66,8 @@ class Like extends \Zotlabs\Web\Controller { } $verb = notags(trim($_GET['verb'])); - + $mode = (($_GET['conv_mode'] === 'channel') ? 'channel' : 'network'); + if(! $verb) $verb = 'like'; @@ -304,7 +305,7 @@ class Like extends \Zotlabs\Web\Controller { $thread_owner = $r[0]; else killme(); - + $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($item['author_xchan']) ); @@ -312,8 +313,7 @@ class Like extends \Zotlabs\Web\Controller { $item_author = $r[0]; else killme(); - - + $verbs = " '".dbesc($activity)."' "; $multi_undo = false; @@ -368,33 +368,38 @@ class Like extends \Zotlabs\Web\Controller { return; if(! $multi_undo) { - if(local_channel()) { - $item_normal = item_normal(); - $activities = q("SELECT item.*, item.id AS item_id FROM item - WHERE uid = %d $item_normal - AND thr_parent = '%s' - AND verb IN ('%s', '%s', '%s', '%s', '%s')", - intval($owner_uid), - dbesc($item['mid']), - dbesc(ACTIVITY_LIKE), - dbesc(ACTIVITY_DISLIKE), - dbesc(ACTIVITY_ATTEND), - dbesc(ACTIVITY_ATTENDNO), - dbesc(ACTIVITY_ATTENDMAYBE) - ); - xchan_query($activities,true); - $convitems[] = $item; - $convitems = array_merge($convitems, $activities); - - $json = [ - 'success' => 1, - 'orig_id' => $item_id, - 'id' => $item['id'], - 'html' => conversation($convitems,'network',true,'r_preview'), - ]; - - echo json_encode($json); - } + + if($mode === 'channel') + profile_load($thread_owner['xchan_name']); + + $item_normal = item_normal(); + + $activities = q("SELECT item.*, item.id AS item_id FROM item + WHERE uid = %d $item_normal + AND thr_parent = '%s' + AND verb IN ('%s', '%s', '%s', '%s', '%s')", + intval($owner_uid), + dbesc($item['mid']), + dbesc(ACTIVITY_LIKE), + dbesc(ACTIVITY_DISLIKE), + dbesc(ACTIVITY_ATTEND), + dbesc(ACTIVITY_ATTENDNO), + dbesc(ACTIVITY_ATTENDMAYBE) + ); + + xchan_query($activities,true); + $convitems[] = $item; + $convitems = array_merge($convitems, $activities); + + $json = [ + 'success' => 1, + 'orig_id' => $item_id, + 'id' => $item['id'], + 'html' => conversation($convitems,$mode,true,'r_preview'), + ]; + + echo json_encode($json); + killme(); } @@ -536,31 +541,34 @@ class Like extends \Zotlabs\Web\Controller { $post = item_store($arr); $post_id = $post['item_id']; - if(local_channel()) { - $item_normal = item_normal(); - $activities = q("SELECT item.*, item.id AS item_id FROM item - WHERE uid = %d $item_normal - AND thr_parent = '%s' - AND verb IN ('%s', '%s', '%s', '%s', '%s')", - intval($owner_uid), - dbesc($item['mid']), - dbesc(ACTIVITY_LIKE), - dbesc(ACTIVITY_DISLIKE), - dbesc(ACTIVITY_ATTEND), - dbesc(ACTIVITY_ATTENDNO), - dbesc(ACTIVITY_ATTENDMAYBE) - ); - xchan_query($activities,true); - $convitems[] = $item; - $convitems = array_merge($convitems, $activities); - - $json = [ - 'success' => 1, - 'orig_id' => $item_id, //this is required for pubstream where $item_id != $item['id'] - 'id' => $item['id'], - 'html' => conversation($convitems,'network',true,'r_preview'), - ]; - } + if($mode === 'channel') + profile_load($thread_owner['xchan_name']); + + $item_normal = item_normal(); + + $activities = q("SELECT item.*, item.id AS item_id FROM item + WHERE uid = %d $item_normal + AND thr_parent = '%s' + AND verb IN ('%s', '%s', '%s', '%s', '%s')", + intval($owner_uid), + dbesc($item['mid']), + dbesc(ACTIVITY_LIKE), + dbesc(ACTIVITY_DISLIKE), + dbesc(ACTIVITY_ATTEND), + dbesc(ACTIVITY_ATTENDNO), + dbesc(ACTIVITY_ATTENDMAYBE) + ); + + xchan_query($activities,true); + $convitems[] = $item; + $convitems = array_merge($convitems, $activities); + + $json = [ + 'success' => 1, + 'orig_id' => $item_id, //this is required for pubstream where $item_id != $item['id'] + 'id' => $item['id'], + 'html' => conversation($convitems,$mode,true,'r_preview'), + ]; // save the conversation from expiration @@ -597,7 +605,6 @@ class Like extends \Zotlabs\Web\Controller { } - \Zotlabs\Daemon\Master::Summon(array('Notifier','like',$post_id)); if($interactive) { -- cgit v1.2.3