allow remote connections without owa

This commit is contained in:
nobody 2021-10-16 14:56:36 -07:00
parent 99165275f3
commit a06dd1fc37
4 changed files with 78 additions and 6 deletions

View file

@ -0,0 +1,53 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Web\Controller;
class Fedi_id extends Controller {
function post() {
$channel = channelx_by_n(argv(1));
if (! $channel) {
return;
}
if ($_REQUEST['address']) {
$x = discover_by_webbie(trim($_REQUEST['address']));
if ($x) {
$r = q("select * from xchan where xchan_hash = '%s'",
dbesc($x)
);
$ab = q("select * from abook where abook_xchan = '%s' and abook_channel = %d",
dbesc($x),
intval($channel['channel_id'])
);
if ($ab) {
notice( t('You are already connected with this channel.') );
goaway(channel_url($channel));
}
if ($r && $r[0]['xchan_follow']) {
goaway(sprintf($r[0]['xchan_follow'],urlencode(channel_reddress($channel))));
}
}
notice( t('Unknown or unreachable identifier') );
return;
}
}
function get() {
return replace_macros(get_markup_template('fedi_id.tpl'),
[
'$title' => t('Home instance'),
'$address' => [ 'address', t('Enter your channel address or fediverse ID (e.g. channel@example.com)'), '', '' ],
'$action' => 'fedi_id/' . argv(1),
'$method' => 'post',
'$submit' => t('Connect')
]
);
}
}

View file

@ -3,11 +3,21 @@ namespace Zotlabs\Module;
/*
* Update
* Performs AJAX liveUpdate of conversational content by calling the appropriate
* controller (passed as argv(1)) and passing the profile_uid (passed as $_GET['p'])
* and load flag (argv(2) === 'load') to the get() function of the controller.
* Conversational controllers have been written to expect this input. Other controllers
* have not.
* Called by main.js to load or fetch updates of content for various conversation streams/timelines.
* It invokes the appropriate module's get() function to return an array of HTML rendered conversations/posts.
* Some state is passed to the module controller prior to calling module->get() to indicate that
* the existing content should either be replaced or appended to.
* The current modules that support this manner of update are
* channel, hq, stream, display, search, and pubstream.
* The state we are passing is the profile_uid (passed to us as $_GET['p']), and argv(2) === 'load'
* to indicate that we're replacing original content.
*
* module->profile_uid - tell the module who owns this data
* module->loading - tell the module to replace existing content
* module->updating - always true to tell the module that this is a js initiated request
*
* Inside main.js we also append all of the relevant content query params which were initially used on that
* page via buildCmd so those are passed to this instance of update and are therefore available from the module.
*/
use App;

View file

@ -43,7 +43,7 @@ function abook_store_lowlevel($arr) {
function rconnect_url($channel_id,$xchan) {
if (! $xchan) {
return EMPTY_STR;
return z_root() . '/fedi_id/' . $channel_id;
}
$r = q("select abook_id from abook where abook_channel = %d and abook_xchan = '%s' limit 1",

9
view/tpl/fedi_id.tpl Normal file
View file

@ -0,0 +1,9 @@
<div class="generic-content-wrapper-styled">
<h3>{{$title}}</h3>
<form action="{{$action}}" method="{{$method}}" >
<div class="form-group">
{{include file="field_input.tpl" field=$address}}
<input class="btn btn-primary" type="submit" name="submit" id="rmagic-submit-button" value="{{$submit}}" />
</div>
</form>
</div>