Browse Source

Merge pull request #8457 from nextcloud/feature/8410/default-permissions

pull/8467/head
Joas Schilling 3 years ago
committed by GitHub
parent
commit
41c19803ca
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      docs/settings.md
  2. 13
      lib/Config.php
  3. 4
      lib/Participant.php
  4. 5
      lib/TInitialState.php
  5. 7
      src/components/PermissionsEditor/PermissionsEditor.vue

1
docs/settings.md

@ -81,6 +81,7 @@ Option legend:
| `session-ping-limit` | int | `200` | | Number of sessions the HPB can ping in a single request |
| `token_entropy` | int | `8` | | Length of conversation tokens, can be increased to make tokens harder to guess but reduces readability and dial-in comfort |
| `default_group_notification` | int | `2` | 🖌️ | Default notification level for group conversations [constants list](constants.md#participant-notification-levels) |
| `default_permissions` | int | `246` | | Default permissions for non-moderators (see [constants list](constants.md#attendee-permissions) for bit flags) |
| `grid_videos_limit` | int | `19` | | Maximum number of videos to show (additional to the own video) |
| `grid_videos_limit_enforced` | string<br>`yes` or `no` | `no` | | Whether the number of grid videos should be enforced |
| `changelog` | string<br>`yes` or `no` | `yes` | | Whether the changelog conversation is updated with new features on major releases |

13
lib/Config.php

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace OCA\Talk;
use OCA\Talk\Events\GetTurnServersEvent;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Vendor\Firebase\JWT\JWT;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\IEventDispatcher;
@ -33,6 +34,7 @@ use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Security\ISecureRandom;
use OCP\Server;
class Config {
public const SIGNALING_INTERNAL = 'internal';
@ -172,6 +174,17 @@ class Config {
return empty(array_intersect($allowedGroups, $userGroups));
}
public function getDefaultPermissions(): int {
// Admin configured default permissions
$configurableDefault = $this->config->getAppValue('spreed', 'default_permissions');
if ($configurableDefault !== '') {
return (int) $configurableDefault;
}
// Falling back to an unrestricted set of permissions, only ignoring the lobby is off
return Attendee::PERMISSIONS_MAX_DEFAULT & ~Attendee::PERMISSIONS_LOBBY_IGNORE;
}
public function getAttachmentFolder(string $userId): string {
return $this->config->getUserValue($userId, 'spreed', 'attachment_folder', '/Talk');
}

4
lib/Participant.php

@ -28,6 +28,7 @@ namespace OCA\Talk;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\Session;
use OCP\IConfig;
use OCP\Server;
class Participant {
public const OWNER = 1;
@ -144,7 +145,6 @@ class Participant {
return $this->room->getDefaultPermissions();
}
// Falling back to an unrestricted set of permissions, only ignoring the lobby is off
return Attendee::PERMISSIONS_MAX_DEFAULT & ~Attendee::PERMISSIONS_LOBBY_IGNORE;
return Server::get(Config::class)->getDefaultPermissions();
}
}

5
lib/TInitialState.php

@ -90,6 +90,11 @@ trait TInitialState {
'federation_enabled',
$this->talkConfig->isFederationEnabled()
);
$this->initialState->provideInitialState(
'default_permissions',
$this->talkConfig->getDefaultPermissions()
);
}
protected function publishInitialStateForUser(IUser $user, IRootFolder $rootFolder, IAppManager $appManager): void {

7
src/components/PermissionsEditor/PermissionsEditor.vue

@ -80,6 +80,7 @@ import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadi
import { PARTICIPANT } from '../../constants.js'
import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import { loadState } from '@nextcloud/initial-state'
const PERMISSIONS = PARTICIPANT.PERMISSIONS
@ -160,7 +161,11 @@ export default {
return this.permissions
}
return PERMISSIONS.MAX_DEFAULT & ~PERMISSIONS.LOBBY_IGNORE
return loadState(
'spreed',
'default_permissions',
PERMISSIONS.MAX_DEFAULT & ~PERMISSIONS.LOBBY_IGNORE
)
},
/**

Loading…
Cancel
Save