From 31e237729c3cd1b0ccbef67db5b7f36e1027c6dc Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 11 Mar 2021 21:58:45 +0000 Subject: introduce the follow_failover hook --- Zotlabs/Module/Follow.php | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'Zotlabs/Module/Follow.php') diff --git a/Zotlabs/Module/Follow.php b/Zotlabs/Module/Follow.php index 11febd8fc..d4e8d1a0c 100644 --- a/Zotlabs/Module/Follow.php +++ b/Zotlabs/Module/Follow.php @@ -14,7 +14,7 @@ use Zotlabs\Daemon\Master; class Follow extends Controller { function init() { - + if (ActivityStreams::is_as_request() && argc() == 2) { $abook_id = intval(argv(1)); @@ -73,12 +73,20 @@ class Follow extends Controller { $url = notags(trim(punify($_REQUEST['url']))); $return_url = $_SESSION['return_url']; $confirm = intval($_REQUEST['confirm']); - $interactive = (($_REQUEST['interactive']) ? intval($_REQUEST['interactive']) : 1); + $interactive = (($_REQUEST['interactive']) ? intval($_REQUEST['interactive']) : 1); $channel = App::get_channel(); $result = Connect::connect($channel,$url); - + if ($result['success'] == false) { + + // this hook is currently used for mastodons remote reply functionality + $hookdata = [ + 'channel' => $channel, + 'data' => $url + ]; + call_hooks('follow_failover', $hookdata); + if ($result['message']) { notice($result['message']); } @@ -89,9 +97,9 @@ class Follow extends Controller { json_return_and_die($result); } } - + info( t('Connection added.') . EOL); - + $clone = array(); foreach ($result['abook'] as $k => $v) { if (strpos($k,'abook_') === 0) { @@ -101,30 +109,30 @@ class Follow extends Controller { unset($clone['abook_id']); unset($clone['abook_account']); unset($clone['abook_channel']); - + $abconfig = load_abconfig($channel['channel_id'],$clone['abook_xchan']); if ($abconfig) { $clone['abconfig'] = $abconfig; } Libsync::build_sync_packet(0, [ 'abook' => [ $clone ] ], true); - + $can_view_stream = their_perms_contains($channel['channel_id'],$clone['abook_xchan'],'view_stream'); - + // If we can view their stream, pull in some posts - + if (($can_view_stream) || ($result['abook']['xchan_network'] === 'rss')) { Master::Summon([ 'Onepoll', $result['abook']['abook_id'] ]); } - + if ($interactive) { goaway(z_root() . '/connedit/' . $result['abook']['abook_id'] . '?follow=1'); } else { json_return_and_die([ 'success' => true ]); } - + } - + function get() { if (! local_channel()) { return login(); -- cgit v1.2.3 From 432e7e9714a98d9438a135451fa09c9486cb160f Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 12 Mar 2021 09:06:20 +0000 Subject: revert follow_failover hook - there is a cleaner solution --- Zotlabs/Module/Follow.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'Zotlabs/Module/Follow.php') diff --git a/Zotlabs/Module/Follow.php b/Zotlabs/Module/Follow.php index d4e8d1a0c..4fe20f56b 100644 --- a/Zotlabs/Module/Follow.php +++ b/Zotlabs/Module/Follow.php @@ -79,14 +79,6 @@ class Follow extends Controller { $result = Connect::connect($channel,$url); if ($result['success'] == false) { - - // this hook is currently used for mastodons remote reply functionality - $hookdata = [ - 'channel' => $channel, - 'data' => $url - ]; - call_hooks('follow_failover', $hookdata); - if ($result['message']) { notice($result['message']); } -- cgit v1.2.3