aboutsummaryrefslogtreecommitdiffstats
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
parentd2b03f6a9bcb8f0b13bf45f9165f5f2efdfe35cb (diff)
downloadvolse-hubzilla-31e237729c3cd1b0ccbef67db5b7f36e1027c6dc.tar.gz
volse-hubzilla-31e237729c3cd1b0ccbef67db5b7f36e1027c6dc.tar.bz2
volse-hubzilla-31e237729c3cd1b0ccbef67db5b7f36e1027c6dc.zip
introduce the follow_failover hook
-rw-r--r--Zotlabs/Lib/Connect.php6
-rw-r--r--Zotlabs/Module/Follow.php32
2 files changed, 23 insertions, 15 deletions
diff --git a/Zotlabs/Lib/Connect.php b/Zotlabs/Lib/Connect.php
index 481b02ce2..21bec171b 100644
--- a/Zotlabs/Lib/Connect.php
+++ b/Zotlabs/Lib/Connect.php
@@ -207,13 +207,13 @@ class Connect {
}
$my_perms = $p['perms'];
-
+
$profile_assign = get_pconfig($uid,'system','profile_assign','');
// See if we are already connected by virtue of having an abook record
- $r = q("select abook_id, abook_xchan, abook_pending, abook_instance from abook
+ $r = q("select abook_id, abook_xchan, abook_pending, abook_instance from abook
where abook_xchan = '%s' and abook_channel = %d limit 1",
dbesc($xchan_hash),
intval($uid)
@@ -282,7 +282,7 @@ class Connect {
// fetch the entire record
- $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash
+ $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash
where abook_xchan = '%s' and abook_channel = %d limit 1",
dbesc($xchan_hash),
intval($uid)
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();