mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 16:35:19 +00:00
upstream intergations
This commit is contained in:
parent
0b64aa9ad7
commit
9c84613763
10 changed files with 134 additions and 67 deletions
|
@ -56,7 +56,8 @@ class ActivityPub
|
|||
'actor' => Channel::url($arr['channel']),
|
||||
'type' => 'Delete',
|
||||
'object' => Channel::url($arr['channel']),
|
||||
'to' => ['https://www.w3.org/ns/activitystreams#Public']
|
||||
'to' => ['https://www.w3.org/ns/activitystreams#Public'],
|
||||
'cc' => []
|
||||
];
|
||||
|
||||
$msg = array_merge(['@context' => [
|
||||
|
@ -282,7 +283,8 @@ class ActivityPub
|
|||
'type' => (($orig_follow_type) ? $orig_follow_type : 'Follow'),
|
||||
'actor' => $p,
|
||||
'object' => $x['recipient']['xchan_hash'],
|
||||
'to' => [$x['recipient']['xchan_hash']]
|
||||
'to' => [$x['recipient']['xchan_hash']],
|
||||
'cc' => []
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -361,7 +363,8 @@ class ActivityPub
|
|||
'actor' => $x['recipient']['xchan_hash'],
|
||||
'object' => z_root() . '/channel/' . $x['sender']['channel_address']
|
||||
],
|
||||
'to' => [$x['recipient']['xchan_hash']]
|
||||
'to' => [$x['recipient']['xchan_hash']],
|
||||
'cc' => []
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -429,7 +432,8 @@ class ActivityPub
|
|||
'actor' => $recip[0]['xchan_hash'],
|
||||
'object' => $p
|
||||
],
|
||||
'to' => [$recip[0]['xchan_hash']]
|
||||
'to' => [$recip[0]['xchan_hash']],
|
||||
'cc' => []
|
||||
]
|
||||
);
|
||||
del_abconfig($recip[0]['abook_channel'], $recip[0]['xchan_hash'], 'activitypub', 'follow_id');
|
||||
|
@ -452,7 +456,8 @@ class ActivityPub
|
|||
'actor' => $p,
|
||||
'object' => $recip[0]['xchan_hash']
|
||||
],
|
||||
'to' => [$recip[0]['xchan_hash']]
|
||||
'to' => [$recip[0]['xchan_hash']],
|
||||
'cc' => []
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Zotlabs\Lib;
|
||||
|
||||
use Zotlabs\Web\HTTPSig;
|
||||
|
||||
|
||||
/**
|
||||
* @brief ActivityStreams class.
|
||||
*
|
||||
|
@ -14,6 +14,7 @@ class ActivityStreams
|
|||
|
||||
public $raw = null;
|
||||
public $data = null;
|
||||
public $meta = null;
|
||||
public $hub = null;
|
||||
public $valid = false;
|
||||
public $deleted = false;
|
||||
|
@ -67,10 +68,10 @@ class ActivityStreams
|
|||
logger('Unpacked: ' . json_encode($tmp, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT), LOGGER_DATA, LOG_DEBUG);
|
||||
$saved = json_encode($this->data, JSON_UNESCAPED_SLASHES);
|
||||
$this->data = $tmp;
|
||||
$this->data['signer'] = $ret['signer'];
|
||||
$this->data['signed_data'] = $saved;
|
||||
$this->meta['signer'] = $ret['signer'];
|
||||
$this->meta['signed_data'] = $saved;
|
||||
if ($ret['hubloc']) {
|
||||
$this->data['hubloc'] = $ret['hubloc'];
|
||||
$this->meta['hubloc'] = $ret['hubloc'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -314,7 +315,16 @@ class ActivityStreams
|
|||
|
||||
public function fetch_property($url, $channel = null, $hub = null)
|
||||
{
|
||||
return Activity::fetch($url, $channel, $hub);
|
||||
$x = Activity::fetch($url, $channel, $hub);
|
||||
if ($x === null && strpos($url, '/channel/')) {
|
||||
// look for other nomadic channels which might be alive
|
||||
$zf = Zotfinger::exec($url, $channel);
|
||||
|
||||
$url = $zf['signature']['signer'];
|
||||
$x = Activity::fetch($url, $channel);
|
||||
}
|
||||
|
||||
return $x;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -413,10 +423,10 @@ class ActivityStreams
|
|||
logger('Unpacked: ' . json_encode($tmp, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT), LOGGER_DATA, LOG_DEBUG);
|
||||
$saved = json_encode($x, JSON_UNESCAPED_SLASHES);
|
||||
$x = $tmp;
|
||||
$x['signer'] = $ret['signer'];
|
||||
$x['signed_data'] = $saved;
|
||||
$x['meta']['signer'] = $ret['signer'];
|
||||
$x['meta']['signed_data'] = $saved;
|
||||
if ($ret['hubloc']) {
|
||||
$x['hubloc'] = $ret['hubloc'];
|
||||
$x['meta']['hubloc'] = $ret['hubloc'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1488,9 +1488,9 @@ class Libzot
|
|||
}
|
||||
}
|
||||
}
|
||||
if ($AS->data['signed_data']) {
|
||||
IConfig::Set($arr, 'activitypub', 'signed_data', $AS->data['signed_data'], false);
|
||||
$j = json_decode($AS->data['signed_data'], true);
|
||||
if ($AS->meta['signed_data']) {
|
||||
IConfig::Set($arr, 'activitypub', 'signed_data', $AS->meta['signed_data'], false);
|
||||
$j = json_decode($AS->meta['signed_data'], true);
|
||||
if ($j) {
|
||||
IConfig::Set($arr, 'activitypub', 'rawmsg', json_encode(JSalmon::unpack($j['data'])), true);
|
||||
}
|
||||
|
@ -2391,12 +2391,12 @@ class Libzot
|
|||
$arr['owner_xchan'] = $a['signature']['signer'];
|
||||
}
|
||||
|
||||
if ($AS->data['hubloc'] || $arr['author_xchan'] === $arr['owner_xchan']) {
|
||||
if ($AS->meta['hubloc'] || $arr['author_xchan'] === $arr['owner_xchan']) {
|
||||
$arr['item_verified'] = true;
|
||||
}
|
||||
|
||||
if ($AS->data['signed_data']) {
|
||||
IConfig::Set($arr, 'activitystreams', 'signed_data', $AS->data['signed_data'], false);
|
||||
if ($AS->meta['signed_data']) {
|
||||
IConfig::Set($arr, 'activitystreams', 'signed_data', $AS->meta['signed_data'], false);
|
||||
}
|
||||
|
||||
logger('FOF Activity received: ' . print_r($arr, true), LOGGER_DATA, LOG_DEBUG);
|
||||
|
|
|
@ -35,7 +35,7 @@ class Permcat
|
|||
*
|
||||
* @param int $channel_id
|
||||
*/
|
||||
public function __construct($channel_id)
|
||||
public function __construct($channel_id, $abook_id = 0)
|
||||
{
|
||||
|
||||
$perms = [];
|
||||
|
@ -79,7 +79,7 @@ class Permcat
|
|||
];
|
||||
|
||||
|
||||
$p = $this->load_permcats($channel_id);
|
||||
$p = $this->load_permcats($channel_id, $abook_id);
|
||||
if ($p) {
|
||||
for ($x = 0; $x < count($p); $x++) {
|
||||
$this->permcats[] = [
|
||||
|
@ -92,6 +92,32 @@ class Permcat
|
|||
}
|
||||
}
|
||||
|
||||
public function match($current) {
|
||||
if ($current) {
|
||||
$perms = Permissions::FilledPerms($current);
|
||||
$operms = Permissions::Operms($perms);
|
||||
}
|
||||
|
||||
if ($this->permcats && $operms) {
|
||||
foreach($this->permcats as $permcat) {
|
||||
$pp = $permcat['perms'];
|
||||
$matching = 0;
|
||||
foreach ($pp as $rp) {
|
||||
foreach ($operms as $op) {
|
||||
if ($rp['name'] === $op['name'] && intval($rp['value']) === intval($op['value'])) {
|
||||
$matching ++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($matching === count($pp)) {
|
||||
return $permcat['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return 'custom';
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return array with permcats.
|
||||
*
|
||||
|
@ -118,12 +144,11 @@ class Permcat
|
|||
return $permcat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return ['error' => true];
|
||||
}
|
||||
|
||||
public function load_permcats($uid)
|
||||
public function load_permcats($uid, $abook_id = 0)
|
||||
{
|
||||
|
||||
$permcats = [
|
||||
|
@ -155,6 +180,17 @@ class Permcat
|
|||
}
|
||||
}
|
||||
|
||||
if ($abook_id) {
|
||||
$r = q("select * from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d",
|
||||
intval($abook_id),
|
||||
intval($uid)
|
||||
);
|
||||
if ($r) {
|
||||
$my_perms = explode(',', get_abconfig($uid, $r[0]['xchan_hash'], 'system', 'my_perms', EMPTY_STR));
|
||||
$permcats[] = [ 'custom', t('custom'), $my_perms, 1];
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* @hooks permcats
|
||||
* * \e array
|
||||
|
|
|
@ -60,7 +60,10 @@ class Zotfinger
|
|||
if ($hubs) {
|
||||
foreach ($hubs as $hub) {
|
||||
if ($hub['hubloc_id_url'] !== $resource and !$hub['hubloc_deleted']) {
|
||||
return self::exec($hub['hubloc_id_url'],$channel,$verify);
|
||||
$rzf = self::exec($hub['hubloc_id_url'],$channel,$verify);
|
||||
if ($rzf) {
|
||||
return $rzf;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -354,7 +354,7 @@ class Connedit extends Controller
|
|||
});\n\n";
|
||||
foreach ($connect_perms['perms'] as $p => $v) {
|
||||
if ($v) {
|
||||
$o .= "\$('#me_id_perms_" . $p . "').prop('checked', true); \n";
|
||||
$o .= "\$('#id_perms_" . $p . "').prop('checked', true); \n";
|
||||
}
|
||||
}
|
||||
$o .= " }\n</script>\n";
|
||||
|
@ -772,13 +772,19 @@ class Connedit extends Controller
|
|||
$perms[] = array('perms_' . $k, $v, ((array_key_exists($k, $their_perms)) ? intval($their_perms[$k]) : ''), $thisperm, $yes_no, (($checkinherited & PERMS_SPECIFIC) ? '' : '1'), '', $checkinherited);
|
||||
}
|
||||
|
||||
$pcat = new Permcat(local_channel());
|
||||
$pcatlist = $pcat->listing();
|
||||
$permcats = [];
|
||||
if ($pcatlist) {
|
||||
foreach ($pcatlist as $pc) {
|
||||
$permcats[$pc['name']] = $pc['localname'];
|
||||
$current_permcat = EMPTY_STR;
|
||||
|
||||
if (Apps::System_app_installed(local_channel(),'Roles')) {
|
||||
$pcat = new Permcat(local_channel(), $contact['abook_id']);
|
||||
$pcatlist = $pcat->listing();
|
||||
$permcats = [];
|
||||
if ($pcatlist) {
|
||||
foreach ($pcatlist as $pc) {
|
||||
$permcats[$pc['name']] = $pc['localname'];
|
||||
}
|
||||
}
|
||||
|
||||
$current_permcat = $pcat->match($my_perms);
|
||||
}
|
||||
|
||||
$locstr = locations_by_netid($contact['xchan_hash']);
|
||||
|
@ -805,7 +811,7 @@ class Connedit extends Controller
|
|||
$o .= replace_macros($tpl, [
|
||||
'$header' => (($self) ? t('Connection Default Permissions') : sprintf(t('Connection: %s'), $contact['xchan_name']) . (($contact['abook_alias']) ? ' <' . $contact['abook_alias'] . '>' : '')),
|
||||
'$autoperms' => array('autoperms', t('Apply these permissions automatically'), ((get_pconfig(local_channel(), 'system', 'autoperms')) ? 1 : 0), t('Connection requests will be approved without your interaction'), $yes_no),
|
||||
'$permcat' => ['permcat', t('Permission role'), '', '<span class="loading invisible">' . t('Loading') . '<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span></span>', $permcats],
|
||||
'$permcat' => ['permcat', t('Permission role'), $current_permcat, '<span class="loading invisible">' . t('Loading') . '<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span></span>', $permcats],
|
||||
'$permcat_new' => t('Add permission role'),
|
||||
'$permcat_enable' => Apps::system_app_installed(local_channel(),'Roles'),
|
||||
'$addr' => unpunify($contact['xchan_addr']),
|
||||
|
|
|
@ -12,13 +12,16 @@ class Permcat extends Controller
|
|||
|
||||
public function init()
|
||||
{
|
||||
if (! local_channel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$permcat = new Zlib\Permcat(local_channel());
|
||||
if (! (local_channel() && Zlib\Apps::system_app_installed(local_channel(),'Roles'))) {
|
||||
json_return_and_die([ 'success' => false ]);
|
||||
}
|
||||
|
||||
$abook_id = (argc() > 2) ? argv(2) : EMPTY_STR;
|
||||
$permcat = new Zlib\Permcat(local_channel(), $abook_id);
|
||||
|
||||
if (argc() > 1) {
|
||||
// logger('fetched ' . argv(1) . ':' . print_r($permcat->fetch(argv(1)),true));
|
||||
json_return_and_die($permcat->fetch(argv(1)));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
$(document).ready(function() {
|
||||
|
||||
// Warn member about unsaved settings
|
||||
// Warn members about unsaved settings
|
||||
$('form').areYouSure({'addRemoveFieldsMarksDirty':true, 'message': aStr['leavethispage'] });
|
||||
|
||||
if(typeof(after_following) !== 'undefined' && after_following) {
|
||||
|
@ -17,14 +17,21 @@ $(document).ready(function() {
|
|||
connectFullShare();
|
||||
});
|
||||
|
||||
let abookId = $("#contact_id").val();
|
||||
|
||||
$('#id_permcat').change(function() {
|
||||
$('.loading').toggleClass('invisible');
|
||||
var permName = $('#id_permcat').val();
|
||||
loadAbookRole(permName);
|
||||
});
|
||||
|
||||
let permName = $('#id_permcat').val();
|
||||
if (typeof(permName) !== 'undefined') {
|
||||
$('.loading').toggleClass('invisible');
|
||||
loadAbookRole(permName, abookId);
|
||||
}
|
||||
});
|
||||
|
||||
let permName = $('#id_permcat').val();
|
||||
if (typeof(permName) !== 'undefined') {
|
||||
$('.loading').toggleClass('invisible');
|
||||
loadAbookRole(permName, abookId);
|
||||
}
|
||||
|
||||
$(document).on('click', '.vcard-header, .vcard-cancel-btn', updateView);
|
||||
$(document).on('click', '.add-field', doAdd);
|
||||
|
@ -98,35 +105,32 @@ function connectFullShare() {
|
|||
if(! $(this).is(':disabled'))
|
||||
$(this).removeAttr('checked');
|
||||
});
|
||||
$('#me_id_perms_view_stream').attr('checked','checked');
|
||||
$('#me_id_perms_view_profile').attr('checked','checked');
|
||||
$('#me_id_perms_view_contacts').attr('checked','checked');
|
||||
$('#me_id_perms_view_storage').attr('checked','checked');
|
||||
$('#me_id_perms_view_pages').attr('checked','checked');
|
||||
$('#me_id_perms_send_stream').attr('checked','checked');
|
||||
$('#me_id_perms_post_wall').attr('checked','checked');
|
||||
$('#me_id_perms_post_comments').attr('checked','checked');
|
||||
$('#me_id_perms_post_mail').attr('checked','checked');
|
||||
$('#me_id_perms_chat').attr('checked','checked');
|
||||
$('#me_id_perms_view_storage').attr('checked','checked');
|
||||
$('#me_id_perms_republish').attr('checked','checked');
|
||||
$('#me_id_perms_post_like').attr('checked','checked');
|
||||
$('#id_perms_view_stream').attr('checked','checked');
|
||||
$('#id_perms_view_profile').attr('checked','checked');
|
||||
$('#id_perms_view_contacts').attr('checked','checked');
|
||||
$('#id_perms_view_storage').attr('checked','checked');
|
||||
$('#id_perms_view_pages').attr('checked','checked');
|
||||
$('#id_perms_send_stream').attr('checked','checked');
|
||||
$('#id_perms_post_wall').attr('checked','checked');
|
||||
$('#id_perms_post_comments').attr('checked','checked');
|
||||
$('#id_perms_post_mail').attr('checked','checked');
|
||||
$('#id_perms_chat').attr('checked','checked');
|
||||
$('#id_perms_view_storage').attr('checked','checked');
|
||||
$('#id_perms_republish').attr('checked','checked');
|
||||
$('#id_perms_post_like').attr('checked','checked');
|
||||
}
|
||||
|
||||
function loadAbookRole(name) {
|
||||
|
||||
if(! name)
|
||||
name = 'default';
|
||||
function loadAbookRole(name, abookId) {
|
||||
|
||||
$('.abook-edit-me').each(function() {
|
||||
if(! $(this).is(':disabled'))
|
||||
$(this).removeAttr('checked');
|
||||
});
|
||||
|
||||
$.get('permcat/' + name, function(data) {
|
||||
$.get('permcat/' + name + '/' + abookId, function(data) {
|
||||
$(data.perms).each(function() {
|
||||
if(this.value)
|
||||
$('#me_id_perms_' + this.name).attr('checked','checked');
|
||||
$('#id_perms_' + this.name).attr('checked','checked');
|
||||
});
|
||||
$('.loading').toggleClass('invisible');
|
||||
});
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
|
||||
<form id="abook-edit-form" action="connedit/{{$contact_id}}" method="post" >
|
||||
|
||||
<input type="hidden" name="contact_id" value="{{$contact_id}}">
|
||||
<input type="hidden" id="contact_id" name="contact_id" value="{{$contact_id}}">
|
||||
<input type="hidden" name="section" value="{{$section}}">
|
||||
|
||||
<div class="panel-group" id="contact-edit-tools" role="tablist" aria-multiselectable="true">
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
<tr class="highlight" style="line-height: 2";>
|
||||
<td>
|
||||
<label class="mainlabel" for='me_id_{{$field.0}}'>{{$field.1}}</label><br>
|
||||
<label class="mainlabel" for='id_{{$field.0}}'>{{$field.1}}</label><br>
|
||||
<span class='field_abook_help'>{{$field.6}}</span>
|
||||
</td>
|
||||
{{if $notself}}
|
||||
<td class="abook-them form-group checkbox">
|
||||
<div>
|
||||
<input type="checkbox" name='them-id-{{$field.0}}' id='id_{{$field.0}}' value="1" {{if $field.2}}checked="checked"{{/if}} disabled="disabled" /><label class="switchlabel" for='id_{{$field.0}}'> <span class="onoffswitch-inner" data-on='{{if $field.4}}{{$field.4.1}}{{/if}}' data-off='{{if $field.4}}{{$field.4.0}}{{/if}}'></span><span class="onoffswitch-switch"></span>
|
||||
<input type="checkbox" name='them-id-{{$field.0}}' id='them_id_{{$field.0}}' value="1" {{if $field.2}}checked="checked"{{/if}} disabled="disabled" /><label class="switchlabel" for='them_id_{{$field.0}}'> <span class="onoffswitch-inner" data-on='{{if $field.4}}{{$field.4.1}}{{/if}}' data-off='{{if $field.4}}{{$field.4.0}}{{/if}}'></span><span class="onoffswitch-switch"></span>
|
||||
</div>
|
||||
</td>
|
||||
{{/if}}
|
||||
<td class="abook-me form-group checkbox" >
|
||||
{{if $self || !$field.5 }}
|
||||
<div>
|
||||
<input type="checkbox" class="abook-edit-me" name='{{$field.0}}' id='me_id_{{$field.0}}' value="1" {{if $field.2}}checked="checked"{{/if}} {{if $field.5}}disabled="disabled"{{/if}} /><label class="switchlabel" for='id_{{$field.0}}'> <span class="onoffswitch-inner" data-on='{{if $field.4}}{{$field.4.1}}{{/if}}' data-off='{{if $field.4}}{{$field.4.0}}{{/if}}'></span><span class="onoffswitch-switch"></span></label>
|
||||
<input type="checkbox" class="abook-edit-me" name='{{$field.0}}' id='id_{{$field.0}}' value="1" {{if $field.3}}checked="checked"{{/if}} {{if $field.5}}disabled="disabled"{{/if}} /><label class="switchlabel" for='id_{{$field.0}}'> <span class="onoffswitch-inner" data-on='{{if $field.4}}{{$field.4.1}}{{/if}}' data-off='{{if $field.4}}{{$field.4.0}}{{/if}}'></span><span class="onoffswitch-switch"></span></label>
|
||||
<!--input type="checkbox" name='{{$field.0}}' class='abook-edit-me' id='me_id_{{$field.0}}' value="{{$field.4}}" {{if $field.3}}checked="checked"{{/if}} /-->
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if $notself && $field.5}}
|
||||
<div>
|
||||
<input type="hidden" name='{{$field.0}}' value="{{if $field.7}}1{{else}}0{{/if}}" />
|
||||
<input type="checkbox" name='{{$field.0}}' id='me_id_{{$field.0}}' value="{{if $field.7}}1{{else}}0{{/if}}" {{if $field.2}}checked="checked"{{/if}} {{if $field.5}}disabled="disabled"{{/if}} /><label class="switchlabel" for='id_{{$field.0}}'> <span class="onoffswitch-inner" data-on='{{if $field.4}}{{$field.4.1}}{{/if}}' data-off='{{if $field.4}}{{$field.4.0}}{{/if}}'></span><span class="onoffswitch-switch"></span></label>
|
||||
<input type="checkbox" name='{{$field.0}}' id='id_{{$field.0}}' value="{{if $field.7}}1{{else}}0{{/if}}" {{if $field.3}}checked="checked"{{/if}} {{if $field.5}}disabled="disabled"{{/if}} /><label class="switchlabel" for='id_{{$field.0}}'> <span class="onoffswitch-inner" data-on='{{if $field.4}}{{$field.4.1}}{{/if}}' data-off='{{if $field.4}}{{$field.4.0}}{{/if}}'></span><span class="onoffswitch-switch"></span></label>
|
||||
</div>
|
||||
|
||||
{{*if $field.3}}<i class="fa fa-check-square-o" style="color:#800;"></i>{{else}}<i class="fa fa-square-o"></i>{{/if*}}
|
||||
|
|
Loading…
Reference in a new issue