add deliver_stream permission

This commit is contained in:
nobody 2022-02-18 14:14:22 -08:00
parent 47206383b4
commit cfa5328c70
7 changed files with 68 additions and 23 deletions

View file

@ -39,7 +39,7 @@ class PermissionRoles
$ret['directory_publish'] = true;
$ret['online'] = true;
$ret['perms_connect'] = [
'view_stream', 'view_profile', 'view_contacts', 'view_storage',
'view_stream', 'deliver_stream', 'view_profile', 'view_contacts', 'view_storage',
'view_pages', 'send_stream', 'post_mail', 'post_wall', 'post_comments'
];
$ret['limits'] = PermissionLimits::Std_Limits();
@ -51,7 +51,7 @@ class PermissionRoles
$ret['directory_publish'] = true;
$ret['online'] = false;
$ret['perms_connect'] = [
'view_stream', 'view_profile', 'view_storage',
'view_stream', 'deliver_stream', 'view_profile', 'view_storage',
'view_pages', 'send_stream', 'post_mail', 'post_wall', 'post_comments'
];
$ret['limits'] = PermissionLimits::Std_Limits();
@ -64,7 +64,7 @@ class PermissionRoles
$ret['directory_publish'] = true;
$ret['online'] = false;
$ret['perms_connect'] = [
'view_stream', 'view_profile', 'view_contacts', 'view_storage', 'write_storage',
'view_stream', 'deliver_stream', 'view_profile', 'view_contacts', 'view_storage', 'write_storage',
'view_pages', 'post_mail', 'post_wall', 'post_comments'
];
$ret['limits'] = PermissionLimits::Std_Limits();
@ -79,7 +79,7 @@ class PermissionRoles
$ret['directory_publish'] = true;
$ret['online'] = false;
$ret['perms_connect'] = [
'view_stream', 'view_profile', 'view_contacts', 'view_storage',
'view_stream', 'deliver_stream', 'view_profile', 'view_contacts', 'view_storage',
'view_pages', 'post_mail', 'post_wall', 'post_comments', 'moderated'
];
$ret['limits'] = PermissionLimits::Std_Limits();
@ -93,7 +93,7 @@ class PermissionRoles
$ret['directory_publish'] = true;
$ret['online'] = false;
$ret['perms_connect'] = [
'view_stream', 'view_profile', 'view_contacts', 'view_storage', 'write_storage',
'view_stream', 'deliver_stream', 'view_profile', 'view_contacts', 'view_storage', 'write_storage',
'view_pages', 'post_mail', 'post_wall', 'post_comments'
];
$ret['limits'] = PermissionLimits::Std_Limits();

View file

@ -58,18 +58,19 @@ class Permissions
{
$perms = [
'view_stream' => t('Grant viewing access to and delivery of your channel stream and posts'),
'view_profile' => t('Grant viewing access to your default channel profile'),
'view_contacts' => t('Grant viewing access to your address book (connections)'),
'view_storage' => t('Grant viewing access to your file storage and photos'),
'post_wall' => t('Grant permission to post on your channel (wall) page'),
'post_mail' => t('Accept delivery of direct messages and personal mail'),
'send_stream' => t('Accept delivery of their posts and all comments to their posts'),
'post_comments' => t('Accept delivery of their comments and likes on your posts'),
'write_storage' => t('Grant upload permissions to your file storage and photos'),
'republish' => t('Grant permission to republish/mirror your posts'),
'moderated' => t('Accept comments and wall posts only after approval (moderation)'),
'delegate' => t('Grant channel administration (delegation) permission')
'view_stream' => t('Grant viewing access to your channel stream and posts'),
'deliver_stream' => t('Provide delivery of your channel stream and posts'),
'view_profile' => t('Grant viewing access to your default channel profile'),
'view_contacts' => t('Grant viewing access to your address book (connections)'),
'view_storage' => t('Grant viewing access to your file storage and photos'),
'post_wall' => t('Grant permission to post on your channel (wall) page'),
'post_mail' => t('Accept delivery of direct messages and personal mail'),
'send_stream' => t('Accept delivery of their posts and all comments to their posts'),
'post_comments' => t('Accept delivery of their comments and likes on your posts'),
'write_storage' => t('Grant upload permissions to your file storage and photos'),
'republish' => t('Grant permission to republish/mirror your posts'),
'moderated' => t('Accept comments and wall posts only after approval (moderation)'),
'delegate' => t('Grant channel administration (delegation) permission')
];
$x = [

View file

@ -13,6 +13,7 @@ use Code\Lib\Libsync;
use Code\Lib\AccessList;
use Code\Lib\Crypto;
use Code\Lib\Connect;
use Code\Lib\ABConfig;
use Code\Access\PermissionRoles;
use Code\Access\PermissionLimits;
use Code\Access\Permissions;
@ -89,7 +90,7 @@ class Channel
$sys = self::get_system();
if ($sys) {
// upgrade the default network drivers if this looks like an upgraded zot6-based platform.
// upgrade the default network drivers and permissions if this looks like an upgraded zot6-based platform.
if ($sys['xchan_network'] !== 'nomad') {
$chans = q("select * from channel where true");
@ -107,6 +108,25 @@ class Channel
intval(XCHAN_TYPE_ORGANIZATION),
dbesc($sys['xchan_hash'])
);
// Add the new "deliver_stream" permission
$c = q("select * from channel where true");
if ($c) {
foreach ($c as $cv) {
PConfig::Set($cv['channel_id'],'perm_limits','deliver_stream', PERMS_SPECIFIC);
}
}
$ab = q("SELECT * from abook where abook_self = 0");
if ($ab) {
foreach ($ab as $abv) {
$p = explode(',', ABConfig::Get($abv['abook_channel'], $abv['abook_xchan'], 'system', 'my_perms', EMPTY_STR));
if (! in_array('deliver_stream', $p)) {
$p[] = 'deliver_stream';
}
ABConfig::Set($abv['abook_channel'], $abv['abook_xchan'], 'system', 'my_perms', implode(',', $p));
}
}
}
// fix lost system keys, since we cannot communicate without them

25
Code/Update/_1255.php Normal file
View file

@ -0,0 +1,25 @@
<?php
namespace Code\Update;
use Code\Lib\PConfig;
class _1255
{
public function run()
{
$r = q("SELECT * from channel where true");
if ($r) {
foreach ($r as $rv) {
PConfig::Set($rv['channel_id'], 'perm_limits', 'deliver_stream', PERMS_SPECIFIC);
}
}
return UPDATE_SUCCESS;
}
public function verify()
{
return true;
}
}

View file

@ -27,7 +27,7 @@ require_once('version.php');
define ( 'PLATFORM_NAME', 'streams' );
define ( 'DB_UPDATE_VERSION', 1254 );
define ( 'DB_UPDATE_VERSION', 1255 );
define ( 'ZOT_REVISION', '11.0' );
define ( 'PLATFORM_ARCHITECTURE', 'zap' );

View file

@ -170,10 +170,9 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) {
}
// This is a somewhat expensive operation but important.
// Don't send this item to anybody who isn't allowed to see it
// Don't send this item to anybody who doesn't have the deliver_stream permission
// Note: commented out - no longer needed in zap and later projects because we do not allow this permission to be changed.
// $recipients = check_list_permissions($item['uid'],$recipients,'view_stream');
$recipients = check_list_permissions($item['uid'],$recipients,'deliver_stream');
// remove any upstream recipients from our list.
// If it is ourself we'll add it back in a second.

View file

@ -9,7 +9,7 @@ require_once('include/security.php');
/**
* @file include/permissions.php
*
* This file conntains functions to check and work with permissions.
* This file contains functions to check and work with permissions.
*
*/