Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion apps/files_sharing/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
* Return this classes capabilities
*
* @return array{

Check failure on line 36 in apps/files_sharing/lib/Capabilities.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

MoreSpecificReturnType

apps/files_sharing/lib/Capabilities.php:36:13: MoreSpecificReturnType: The declared return type 'array{files_sharing: array{api_enabled: bool, default_permissions?: int, exclude_reshare_from_edit?: bool, federation: array{expire_date: array{enabled: bool}, expire_date_supported: array{enabled: bool}, incoming: bool, outgoing: bool}, group?: array{enabled: bool, expire_date?: array{enabled: bool}}, group_sharing?: bool, public: array{custom_tokens?: bool, enabled: bool, expire_date?: array{days?: int, enabled: bool, enforced?: bool}, expire_date_internal?: array{days?: int, enabled: bool, enforced?: bool}, expire_date_remote?: array{days?: int, enabled: bool, enforced?: bool}, multiple_links?: bool, password?: array{askForOptionalPassword: bool, enforced: bool}, send_mail?: bool, upload?: bool, upload_files_drop?: bool}, resharing: bool, sharee: array{always_show_unique: bool, query_lookup_default: bool}, user: array{expire_date?: array{enabled: bool}, send_mail: bool}}}' for OCA\Files_Sharing\Capabilities::getCapabilities is more specific than the inferred return type 'array{files_sharing: array{api_enabled: bool, default_permissions?: int, exclude_reshare_from_edit?: bool, federation: array{expire_date: array{enabled: bool}, expire_date_supported: array{enabled: bool}, incoming: bool, outgoing: bool}, group?: array{enabled: bool, expire_date: array{enabled: true}}, group_sharing?: bool, public: array{custom_tokens?: bool, enabled: bool, expire_date?: array{days?: int, default_days?: int, enabled: bool, enforced?: bool}, expire_date_internal?: array{days?: int, enabled: bool, enforced?: bool}, expire_date_remote?: array{days?: int, enabled: bool, enforced?: bool}, multiple_links?: true, password?: array{askForOptionalPassword: bool, enforced: bool}, send_mail?: bool, upload?: bool, upload_files_drop?: bool}, resharing: bool, sharee: array{always_show_unique: bool, query_lookup_default: bool}, user: array{expire_date?: array{enabled: true}, send_mail: false}}}' (see https://psalm.dev/070)
* files_sharing: array{
* api_enabled: bool,
* public: array{
Expand Down Expand Up @@ -123,7 +123,13 @@
$public['multiple_links'] = true;
$public['expire_date']['enabled'] = $this->shareManager->shareApiLinkDefaultExpireDate();
if ($public['expire_date']['enabled']) {
$public['expire_date']['days'] = $this->shareManager->shareApiLinkDefaultExpireDays();
$maxDays = $this->shareManager->shareApiLinkDefaultExpireDays();
$defaultDays = (int)$this->config->getAppValue('core', 'link_defaultExpDays', (string)$maxDays);
if ($defaultDays > $maxDays) {
$defaultDays = $maxDays;
}
$public['expire_date']['days'] = $maxDays;
$public['expire_date']['default_days'] = $defaultDays;
$public['expire_date']['enforced'] = $this->shareManager->shareApiLinkDefaultExpireDateEnforced();
}

Expand Down Expand Up @@ -186,10 +192,10 @@
// Sharee searches
$res['sharee'] = [
'query_lookup_default' => $this->config->getSystemValueBool('gs.enabled', false),
'always_show_unique' => $this->config->getAppValue('files_sharing', 'always_show_unique', 'yes') === 'yes',

Check failure on line 195 in apps/files_sharing/lib/Capabilities.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

DeprecatedMethod

apps/files_sharing/lib/Capabilities.php:195:43: DeprecatedMethod: The method OCP\IConfig::getAppValue has been marked as deprecated (see https://psalm.dev/001)
];

return [

Check failure on line 198 in apps/files_sharing/lib/Capabilities.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

LessSpecificReturnStatement

apps/files_sharing/lib/Capabilities.php:198:10: LessSpecificReturnStatement: The type 'array{files_sharing: array{api_enabled: bool, default_permissions?: int, exclude_reshare_from_edit?: bool, federation: array{expire_date: array{enabled: bool}, expire_date_supported: array{enabled: bool}, incoming: bool, outgoing: bool}, group?: array{enabled: bool, expire_date: array{enabled: true}}, group_sharing?: bool, public: array{custom_tokens?: bool, enabled: bool, expire_date?: array{days?: int, default_days?: int, enabled: bool, enforced?: bool}, expire_date_internal?: array{days?: int, enabled: bool, enforced?: bool}, expire_date_remote?: array{days?: int, enabled: bool, enforced?: bool}, multiple_links?: true, password?: array{askForOptionalPassword: bool, enforced: bool}, send_mail?: bool, upload?: bool, upload_files_drop?: bool}, resharing: bool, sharee: array{always_show_unique: bool, query_lookup_default: bool}, user: array{expire_date?: array{enabled: true}, send_mail: false}}}' is more general than the declared return type 'array{files_sharing: array{api_enabled: bool, default_permissions?: int, exclude_reshare_from_edit?: bool, federation: array{expire_date: array{enabled: bool}, expire_date_supported: array{enabled: bool}, incoming: bool, outgoing: bool}, group?: array{enabled: bool, expire_date?: array{enabled: bool}}, group_sharing?: bool, public: array{custom_tokens?: bool, enabled: bool, expire_date?: array{days?: int, enabled: bool, enforced?: bool}, expire_date_internal?: array{days?: int, enabled: bool, enforced?: bool}, expire_date_remote?: array{days?: int, enabled: bool, enforced?: bool}, multiple_links?: bool, password?: array{askForOptionalPassword: bool, enforced: bool}, send_mail?: bool, upload?: bool, upload_files_drop?: bool}, resharing: bool, sharee: array{always_show_unique: bool, query_lookup_default: bool}, user: array{expire_date?: array{enabled: bool}, send_mail: bool}}}' for OCA\Files_Sharing\Capabilities::getCapabilities (see https://psalm.dev/129)
'files_sharing' => $res,
];
}
Expand Down
16 changes: 13 additions & 3 deletions apps/files_sharing/src/services/ConfigService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ export default class Config {
* Get the default link share expiration date
*/
get defaultExpirationDate(): Date | null {
if (this.isDefaultExpireDateEnabled && this.defaultExpireDate !== null) {
return new Date(new Date().setDate(new Date().getDate() + this.defaultExpireDate))
if (this.isDefaultExpireDateEnabled) {
const days = this.linkDefaultExpDays ?? this.defaultExpireDate
if (days !== null) {
return new Date(new Date().setDate(new Date().getDate() + days))
}
}
return null
}
Expand Down Expand Up @@ -243,12 +246,19 @@ export default class Config {
}

/**
* Get the default days to link shares expiration
* Get the maximum days to link shares expiration
*/
get defaultExpireDate(): number | null {
return window.OC.appConfig.core.defaultExpireDate
}

/**
* Get the default days to link shares expiration
*/
get linkDefaultExpDays(): number | null {
return this._capabilities?.files_sharing?.public?.expire_date?.default_days ?? null
}

/**
* Get the default days to internal shares expiration
*/
Expand Down
Loading