Merge branch 'nomadic' of codeberg.org:streams/streams into nomadic

This commit is contained in:
Mike Macgirvin 2024-06-18 17:06:44 +10:00
commit 8ff343da08
11 changed files with 2191 additions and 2137 deletions

View file

@ -541,7 +541,6 @@ function check_deliver_permissions($item, $arr, $includeMentions = false)
if (in_array($recipient, $theyAccept)) {
$accepting = true;
}
if (!in_array($recipient,$willNotSend)) {
$deliverable = true;
}

View file

@ -316,6 +316,18 @@ class Permissions
return ( [ 'perms' => $my_perms, 'automatic' => $automatic ] );
}
static public function perm_remove($arr, $perm)
{
$retval = [];
if ($arr) {
foreach ($arr as $element) {
if ($element !== $perm) {
$retval[] = $element;
}
}
}
return $retval;
}
public static function serialise($p)
{

View file

@ -2165,17 +2165,13 @@ class Activity
}
$x = PermissionRoles::role_perms('social');
$p = Permissions::FilledPerms($x['perms_connect']);
$theirPerms = $x['perms_connect'];
// add tag_deliver permissions to remote groups
if (is_array($person_obj) && $person_obj['type'] === 'Group') {
$p['tag_deliver'] = 1;
// add tag_deliver permissions to remote groups (deprecated, use post_wall instead)
if (is_array($person_obj) && $person_obj['type'] === 'Group' && !in_array('tag_deliver', $theirPerms)) {
$theirPerms[] = 'tag_deliver';
}
$their_perms = Permissions::serialise($p);
if ($contact && $contact['abook_id']) {
// A relationship of some form already exists on this site.
@ -2195,16 +2191,21 @@ class Activity
set_abconfig($channel['channel_id'], $person_obj['id'], 'activitypub', 'their_follow_id', $their_follow_id);
set_abconfig($channel['channel_id'], $person_obj['id'], 'activitypub', 'their_follow_type', $act->type);
// In case they unfollowed us and followed again, reset their permissions to show that we're connected again.
if ($their_perms) {
AbConfig::Set($channel['channel_id'], $person_obj['id'], 'system', 'their_perms', $their_perms);
if ($theirPerms) {
AbConfig::Set($channel['channel_id'], $person_obj['id'], 'system', 'their_perms', implode(',', $theirPerms));
}
Run::Summon(['Notifier', 'permissions_accept', $contact['abook_id']]);
return;
case 'Accept':
// They accepted our Follow request - set default permissions
set_abconfig($channel['channel_id'], $contact['abook_xchan'], 'system', 'their_perms', $their_perms);
// They accepted our Follow request - set default permissions, but if this is a one-sided new
// connection, as indicated by their_perms not yet existing, leave out send_stream in their_perms
// - because they aren't following us
$findPerms = AbConfig::Get($channel['channel_id'], $contact['abook_xchan'], 'system', 'their_perms');
if (!$findPerms) {
$theirPerms = Permissions::perm_remove($theirPerms, 'send_stream');
}
AbConfig::Set($channel['channel_id'], $contact['abook_xchan'], 'system', 'their_perms', implode(',', $theirPerms));
$abook_instance = $contact['abook_instance'];
@ -2292,8 +2293,8 @@ class Activity
AbConfig::Set($channel['channel_id'], $ret['xchan_hash'], 'system', 'my_perms', $my_perms);
}
if ($their_perms) {
AbConfig::Set($channel['channel_id'], $ret['xchan_hash'], 'system', 'their_perms', $their_perms);
if ($theirPerms) {
AbConfig::Set($channel['channel_id'], $ret['xchan_hash'], 'system', 'their_perms', implode(',', $theirPerms));
}
// not widely used: save an intro message if it's here.

View file

@ -345,7 +345,7 @@ class Connections extends Controller
];
$oneway = false;
if (!their_perms_contains(local_channel(), $rr['xchan_hash'], 'post_comments')) {
if (!their_perms_contains(local_channel(), $rr['xchan_hash'], 'send_stream')) {
$oneway = true;
}
@ -395,6 +395,8 @@ class Connections extends Controller
'recent_label' => t('Recent activity'),
'recentlink' => z_root() . '/stream/?cid=' . intval($rr['abook_id']),
'oneway' => $oneway,
'oneway_desc' => t('Is not following your posts'),
'group_desc' => t('Is only following group posts'),
'allow_delete' => ($rr['abook_pending'] || get_pconfig(local_channel(), 'system', 'connections_quick_delete')),
];
}

View file

@ -69,11 +69,14 @@ class Viewconnections extends Controller
'thumb' => $rr['xchan_photo_m'],
'name' => substr($rr['xchan_name'], 0, 20),
'username' => $rr['xchan_addr'],
'channel_type' => $rr['xchan_type'],
'link' => $url,
'sparkle' => '',
'itemurl' => $rr['url'],
'network' => '',
'oneway' => $oneway
'oneway' => $oneway,
'oneway_desc' => t('Is not following back'),
'group_desc' => t('Is only following group posts')
];
}
}

View file

@ -51,7 +51,7 @@ function po2php_run($argc, $argv)
}
foreach ($infile as $l) {
$l = str_replace(array('$projectname','$Projectname'), array('\$projectname','\$Projectname'), $l);
$l = str_replace(array('$projectname','$Projectname', '$Sitename', '$sitename'), array('\$projectname','\$Projectname', '\$Sitename', '\$sitename'), $l);
$len = strlen($l);
if ($l[0] == '#') {
$l = '';

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -40,7 +40,11 @@
{{/if}}
<!--/a -->
{{if $contact.oneway}}
<i class="fa fa-fw fa-minus-circle oneway-overlay text-danger"></i>
{{if $contact.channel_type == 1}}
<i class="fa fa-fw fa-plus-circle oneway-overlay text-danger" title="{{$contact.group_desc}}"></i>
{{else}}
<i class="fa fa-fw fa-minus-circle oneway-overlay text-danger" title="{{$contact.oneway_desc}}"></i>
{{/if}}
{{/if}}
</div>
<div class="contact-info">

View file

@ -1,8 +1,12 @@
<div class="contact-entry-wrapper" id="contact-entry-wrapper-{{$contact.id}}" >
<div class="contact-entry-photo-wrapper" >
<a href="{{$contact.link}}" title="{{$contact.img_hover}}" ><img class="contact-block-img" src="{{$contact.thumb}}" alt="{{$contact.name}}" /></a>
{{if $contact.oneway}}
<i class="fa fa-fw fa-minus-circle oneway-overlay text-danger"></i>
{{if $contact.oneway}}
{{if $contact.channel_type == 1}}
<i class="fa fa-fw fa-plus-circle oneway-overlay text-danger" title="{{$contact.group_desc}}"></i>
{{else}}
<i class="fa fa-fw fa-minus-circle oneway-overlay text-danger" title="{{$contact.oneway_desc}}"></i>
{{/if}}
{{/if}}
</div>
<div class="contact-entry-photo-end" ></div>