mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:55:15 +00:00
Merge branch 'zap' into dev
This commit is contained in:
commit
df7605435f
5 changed files with 45 additions and 140 deletions
|
@ -591,7 +591,7 @@ function get_atom_elements($feed, $item) {
|
|||
$res['title'] = '';
|
||||
}
|
||||
elseif($res['plink'] && $res['title']) {
|
||||
$res['body'] = '#^[url=' . $res['plink'] . ']' . $res['title'] . '[/url]' . "\n\n" . $res['body'];
|
||||
$res['body'] = '[url=' . $res['plink'] . ']' . $res['title'] . '[/url]' . "\n\n" . $res['body'];
|
||||
$terms = array();
|
||||
$terms[] = array(
|
||||
'otype' => TERM_OBJ_POST,
|
||||
|
@ -601,7 +601,7 @@ function get_atom_elements($feed, $item) {
|
|||
);
|
||||
}
|
||||
elseif($res['plink']) {
|
||||
$res['body'] = '#^[url]' . $res['plink'] . '[/url]' . "\n\n" . $res['body'];
|
||||
$res['body'] = '[url]' . $res['plink'] . '[/url]' . "\n\n" . $res['body'];
|
||||
$terms = array();
|
||||
$terms[] = array(
|
||||
'otype' => TERM_OBJ_POST,
|
||||
|
|
|
@ -22,7 +22,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||
$is_zot = false;
|
||||
$protocol = '';
|
||||
|
||||
|
||||
if(substr($url,0,1) === '[') {
|
||||
$x = strpos($url,']');
|
||||
if($x) {
|
||||
|
@ -31,8 +30,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||
}
|
||||
}
|
||||
|
||||
$is_http = ((strpos($url,'://') !== false) ? true : false);
|
||||
|
||||
$url = rtrim($url,'/');
|
||||
|
||||
if(! allowed_url($url)) {
|
||||
|
@ -45,7 +42,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||
return $result;
|
||||
}
|
||||
|
||||
|
||||
// check service class limits
|
||||
|
||||
$r = q("select count(*) as total from abook where abook_channel = %d and abook_self = 0 ",
|
||||
|
@ -59,111 +55,49 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||
return $result;
|
||||
}
|
||||
|
||||
$xchan_hash = '';
|
||||
$sql_options = (($protocol) ? " and xchan_network = '" . dbesc($protocol) . "' " : '');
|
||||
|
||||
$r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' or xchan_addr = '%s' $sql_options limit 1",
|
||||
dbesc($url),
|
||||
dbesc($url),
|
||||
dbesc($url)
|
||||
);
|
||||
|
||||
$arr = array('url' => $url, 'protocol' => $protocol, 'channel' => array());
|
||||
$singleton = false;
|
||||
$d = false;
|
||||
|
||||
call_hooks('follow_init', $arr);
|
||||
if(! $r) {
|
||||
|
||||
$x = false;
|
||||
// try RSS discovery
|
||||
|
||||
if($arr['channel']['success'])
|
||||
$ret = $arr['channel'];
|
||||
else {
|
||||
$href = \Zotlabs\Lib\Webfinger::zot_url(punify($url));
|
||||
if($href) {
|
||||
$zf = \Zotlabs\Lib\Zotfinger::exec($href,$channel);
|
||||
$wf = discover_by_webbie($url,$protocol);
|
||||
|
||||
$feeds = get_config('system','feed_contacts');
|
||||
|
||||
if(($feeds) && ($protocol === '' || $protocol === 'feed' || $protocol === 'rss')) {
|
||||
$d = discover_feed($url);
|
||||
}
|
||||
if(is_array($zf) && array_path_exists('signature/signer',$zf) && $zf['signature']['signer'] === $href
|
||||
&& intval($zf['signature']['header_valid']) && array_path_exists('data/permissions',$zf)) {
|
||||
$x = Libzot::import_xchan($zf['data']);
|
||||
$j = $zf['data'];
|
||||
$is_zot = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$p = \Zotlabs\Access\Permissions::connect_perms($uid);
|
||||
$my_perms = \Zotlabs\Access\Permissions::serialise($p['perms']);
|
||||
|
||||
if($x) {
|
||||
|
||||
// Premium channel, set confirm before callback to avoid recursion
|
||||
|
||||
// if(array_key_exists('connect_url',$j) && (! $confirm)) {
|
||||
// if($interactive) {
|
||||
// goaway(zid($j['connect_url']));
|
||||
// }
|
||||
// else {
|
||||
// $result['message'] = t('Premium channel - please visit:') . ' ' . zid($j['connect_url']);
|
||||
// logger('mod_follow: ' . $result['message']);
|
||||
// return $result;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
if(array_key_exists('deleted',$j) && intval($j['deleted'])) {
|
||||
$result['message'] = t('Channel was deleted and no longer exists.');
|
||||
else {
|
||||
$result['message'] = t('Remote channel or protocol unavailable.');
|
||||
return $result;
|
||||
}
|
||||
|
||||
if(! $x['success'])
|
||||
return $x;
|
||||
|
||||
$xchan_hash = $x['hash'];
|
||||
|
||||
$permissions = $j['permissions'];
|
||||
|
||||
set_abconfig($channel['channel_uid'],$xchan_hash,'system','their_perms',$j['permissions']);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$xchan_hash = '';
|
||||
$sql_options = (($protocol) ? " and xchan_network = '" . dbesc($protocol) . "' " : '');
|
||||
|
||||
$r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' or xchan_addr = '%s' $sql_options limit 1",
|
||||
dbesc($url),
|
||||
if($wf || $d) {
|
||||
$r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' or xchan_addr = '%s' limit 1",
|
||||
dbesc(($wf) ? $wf : $url),
|
||||
dbesc($url),
|
||||
dbesc($url)
|
||||
);
|
||||
}
|
||||
|
||||
if(! $r) {
|
||||
// if discovery was a success we should have an xchan record in $r
|
||||
|
||||
// attempt network auto-discovery
|
||||
|
||||
$wf = discover_by_webbie($url,$protocol);
|
||||
|
||||
if((! $wf) && ($is_http)) {
|
||||
|
||||
// try RSS discovery
|
||||
|
||||
$feeds = get_config('system','feed_contacts');
|
||||
|
||||
if(($feeds) && ($protocol === '' || $protocol === 'feed' || $protocol === 'rss')) {
|
||||
$d = discover_by_url($url);
|
||||
}
|
||||
else {
|
||||
$result['message'] = t('Remote channel or protocol unavailable.');
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if($wf || $d) {
|
||||
$r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' or xchan_addr = '%s' limit 1",
|
||||
dbesc(($wf) ? $wf : $url),
|
||||
dbesc($url),
|
||||
dbesc($url)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// if discovery was a success we should have an xchan record in $r
|
||||
|
||||
if($r) {
|
||||
$xchan = $r[0];
|
||||
$xchan_hash = $r[0]['xchan_hash'];
|
||||
$their_perms = EMPTY_STR;
|
||||
}
|
||||
if($r) {
|
||||
$xchan = $r[0];
|
||||
$xchan_hash = $r[0]['xchan_hash'];
|
||||
$their_perms = EMPTY_STR;
|
||||
}
|
||||
|
||||
if(! $xchan_hash) {
|
||||
|
@ -172,24 +106,10 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||
return $result;
|
||||
}
|
||||
|
||||
$allowed = (($is_zot || $r[0]['xchan_network'] === 'rss') ? 1 : 0);
|
||||
|
||||
$x = array('channel_id' => $uid, 'follow_address' => $url, 'xchan' => $r[0], 'allowed' => $allowed, 'singleton' => 0);
|
||||
|
||||
call_hooks('follow_allow',$x);
|
||||
|
||||
if($r[0]['xchan_network'] === 'activitypub') {
|
||||
$x['allowed'] = 1;
|
||||
$x['singleton'] = 1;
|
||||
$singleton = 1;
|
||||
}
|
||||
|
||||
if(! $x['allowed']) {
|
||||
$result['message'] = t('Protocol disabled.');
|
||||
return $result;
|
||||
}
|
||||
|
||||
$singleton = intval($x['singleton']);
|
||||
|
||||
$aid = $channel['channel_account_id'];
|
||||
$hash = $channel['channel_hash'];
|
||||
$default_group = $channel['channel_default_group'];
|
||||
|
@ -225,6 +145,9 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||
|
||||
}
|
||||
|
||||
$p = \Zotlabs\Access\Permissions::connect_perms($uid);
|
||||
$my_perms = \Zotlabs\Access\Permissions::serialise($p['perms']);
|
||||
|
||||
$profile_assign = get_pconfig($uid,'system','profile_assign','');
|
||||
|
||||
|
||||
|
@ -276,7 +199,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||
}
|
||||
|
||||
if(! $r)
|
||||
logger('mod_follow: abook creation failed');
|
||||
logger('abook creation failed');
|
||||
|
||||
if($my_perms) {
|
||||
set_abconfig($uid,$xchan_hash,'system','my_perms',$my_perms);
|
||||
|
@ -290,20 +213,20 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||
|
||||
if($r) {
|
||||
$result['abook'] = $r[0];
|
||||
Zotlabs\Daemon\Master::Summon(array('Notifier', 'permissions_create', $result['abook']['abook_id']));
|
||||
Zotlabs\Daemon\Master::Summon([ 'Notifier', 'permissions_create', $result['abook']['abook_id'] ]);
|
||||
}
|
||||
|
||||
$arr = array('channel_id' => $uid, 'channel' => $channel, 'abook' => $result['abook']);
|
||||
$arr = [ 'channel_id' => $uid, 'channel' => $channel, 'abook' => $result['abook'] ];
|
||||
|
||||
call_hooks('follow', $arr);
|
||||
|
||||
/** If there is a default group for this channel, add this connection to it */
|
||||
|
||||
if($default_group) {
|
||||
|
||||
$g = Group::rec_byhash($uid,$default_group);
|
||||
if($g)
|
||||
Group_member_add($uid,'',$xchan_hash,$g['id']);
|
||||
if($g) {
|
||||
Group::member_add($uid,'',$xchan_hash,$g['id']);
|
||||
}
|
||||
}
|
||||
|
||||
$result['success'] = true;
|
||||
|
|
|
@ -1006,7 +1006,7 @@ function email_header_encode($in_str, $charset = 'UTF-8') {
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function discover_by_url($url, $arr = null) {
|
||||
function discover_feed($url, $arr = null) {
|
||||
|
||||
$x = scrape_feed($url);
|
||||
if(! $x) {
|
||||
|
@ -1209,23 +1209,7 @@ function discover_by_webbie($webbie, $protocol = '') {
|
|||
|
||||
$x = Libzot::import_xchan($record['data']);
|
||||
if($x['success']) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if($link['rel'] === PROTOCOL_ZOT && ((! $protocol) || (strtolower($protocol) === 'zot'))) {
|
||||
logger('zot found for ' . $webbie, LOGGER_DEBUG);
|
||||
if(array_key_exists('zot',$x) && $x['zot']['success']) {
|
||||
$i = import_xchan($x['zot']);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
$z = z_fetch_url($link['href']);
|
||||
if($z['success']) {
|
||||
$j = json_decode($z['body'],true);
|
||||
$i = import_xchan($j);
|
||||
return true;
|
||||
}
|
||||
return $x['hash'];
|
||||
}
|
||||
}
|
||||
if($link['rel'] === 'self' && ($link['type'] === 'application/activity+json' || strpos($link['type'],'ld+json') !== false) && ((! $protocol) || (strtolower($protocol) === 'activitypub'))) {
|
||||
|
|
|
@ -214,9 +214,9 @@ function red_zrl_callback($matches) {
|
|||
if($matches[1] === '#^')
|
||||
$matches[1] = '';
|
||||
if($zrl)
|
||||
return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]';
|
||||
return $matches[1] . '[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]';
|
||||
|
||||
return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]';
|
||||
return $matches[1] . '[url=' . $matches[2] . ']' . $matches[2] . '[/url]';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -146,10 +146,8 @@ web server platforms.
|
|||
a nickname of 'zaddons'. You can pull in other addon repositories by
|
||||
giving them different nicknames.
|
||||
|
||||
|
||||
util/add_addon_repo https://framagit.org/macgirvin/osada-addons.git zaddons
|
||||
|
||||
|
||||
- For keeping the addon tree updated, you should be on your top level website
|
||||
directory and issue an update command for that repository.
|
||||
|
||||
|
|
Loading…
Reference in a new issue