aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-03-11 21:58:45 +0000
committerMario <mario@mariovavti.com>2021-03-11 21:58:45 +0000
commit31e237729c3cd1b0ccbef67db5b7f36e1027c6dc (patch)
treebf895e6ca8e779424a9d9b63bf242c0cec31b6ca /Zotlabs/Module
parentd2b03f6a9bcb8f0b13bf45f9165f5f2efdfe35cb (diff)
downloadvolse-hubzilla-31e237729c3cd1b0ccbef67db5b7f36e1027c6dc.tar.gz
volse-hubzilla-31e237729c3cd1b0ccbef67db5b7f36e1027c6dc.tar.bz2
volse-hubzilla-31e237729c3cd1b0ccbef67db5b7f36e1027c6dc.zip
introduce the follow_failover hook
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Follow.php32
1 files changed, 20 insertions, 12 deletions
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();