-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(files_sharing): allow not deleting expiring shares #48225
base: master
Are you sure you want to change the base?
Conversation
85a6fa2
to
1cbec70
Compare
099984d
to
98e0fe3
Compare
*/ | ||
private function getHumanBooleanConfig(string $app, string $key, bool $default = false): bool { | ||
return $this->config->getAppValue($app, $key, $default ? 'yes' : 'no') === 'yes'; | ||
return $this->config->getAppValue($app, $key, $default ? 'yes' : 'no') !== 'no'; |
Check notice
Code scanning / Psalm
DeprecatedMethod
98e0fe3
to
3f32873
Compare
d4aab4b
to
fda83da
Compare
All green and ready 🚀 |
fda83da
to
b436212
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed PHP changes only
apps/files_sharing/lib/Controller/ShareApiControllerFactory.php
Outdated
Show resolved
Hide resolved
apps/files_sharing/lib/Controller/DeletedShareAPIController.php
Outdated
Show resolved
Hide resolved
apps/files_sharing/lib/Controller/DeletedShareAPIController.php
Outdated
Show resolved
Hide resolved
apps/files_sharing/lib/Controller/ExpiredShareAPIController.php
Outdated
Show resolved
Hide resolved
8274d2a
to
2eaedc6
Compare
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
2eaedc6
to
fc3ae5c
Compare
Addressed @come-nc |
/** | ||
* @psalm-import-type Files_SharingShare from ResponseDefinitions | ||
*/ | ||
abstract class ShareApiControllerFactory extends OCSController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstract class ShareApiControllerFactory extends OCSController { | |
abstract class ShareApiControllerBase extends OCSController { |
I’m still unhappy with the name, this is not a factory.
See https://en.wikipedia.org/wiki/Factory_method_pattern
A Factory has static methods to create instances. This here is simply a base to be used as parent by other controllers.
protected ShareManager $shareManager, | ||
protected ?string $userId, | ||
protected IUserManager $userManager, | ||
protected IGroupManager $groupManager, | ||
protected IRootFolder $rootFolder, | ||
protected IAppManager $appManager, | ||
protected ContainerInterface $serverContainer, | ||
protected UserStatusManager $userStatusManager, | ||
protected IPreview $previewManager, | ||
protected IDateTimeZone $dateTimeZone, | ||
protected IURLGenerator $urlGenerator, | ||
protected IL10N $l, | ||
protected LoggerInterface $logger, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected ShareManager $shareManager, | |
protected ?string $userId, | |
protected IUserManager $userManager, | |
protected IGroupManager $groupManager, | |
protected IRootFolder $rootFolder, | |
protected IAppManager $appManager, | |
protected ContainerInterface $serverContainer, | |
protected UserStatusManager $userStatusManager, | |
protected IPreview $previewManager, | |
protected IDateTimeZone $dateTimeZone, | |
protected IURLGenerator $urlGenerator, | |
protected IL10N $l, | |
protected LoggerInterface $logger, | |
ShareManager $shareManager, | |
?string $userId, | |
IUserManager $userManager, | |
IGroupManager $groupManager, | |
IRootFolder $rootFolder, | |
IAppManager $appManager, | |
ContainerInterface $serverContainer, | |
UserStatusManager $userStatusManager, | |
IPreview $previewManager, | |
IDateTimeZone $dateTimeZone, | |
IURLGenerator $urlGenerator, | |
IL10N $l, | |
LoggerInterface $logger, |
public function __construct( | ||
IRequest $request, | ||
ShareManager $shareManager, | ||
?string $userId, | ||
IUserManager $userManager, | ||
IGroupManager $groupManager, | ||
IRootFolder $rootFolder, | ||
IAppManager $appManager, | ||
ContainerInterface $serverContainer, | ||
UserStatusManager $userStatusManager, | ||
IPreview $previewManager, | ||
IDateTimeZone $dateTimeZone, | ||
IURLGenerator $urlGenerator, | ||
IL10N $l, | ||
LoggerInterface $logger, | ||
) { | ||
parent::__construct( | ||
$request, | ||
$shareManager, | ||
$userId, | ||
$userManager, | ||
$groupManager, | ||
$rootFolder, | ||
$appManager, | ||
$serverContainer, | ||
$userStatusManager, | ||
$previewManager, | ||
$dateTimeZone, | ||
$urlGenerator, | ||
$l, | ||
$logger, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function __construct( | |
IRequest $request, | |
ShareManager $shareManager, | |
?string $userId, | |
IUserManager $userManager, | |
IGroupManager $groupManager, | |
IRootFolder $rootFolder, | |
IAppManager $appManager, | |
ContainerInterface $serverContainer, | |
UserStatusManager $userStatusManager, | |
IPreview $previewManager, | |
IDateTimeZone $dateTimeZone, | |
IURLGenerator $urlGenerator, | |
IL10N $l, | |
LoggerInterface $logger, | |
) { | |
parent::__construct( | |
$request, | |
$shareManager, | |
$userId, | |
$userManager, | |
$groupManager, | |
$rootFolder, | |
$appManager, | |
$serverContainer, | |
$userStatusManager, | |
$previewManager, | |
$dateTimeZone, | |
$urlGenerator, | |
$l, | |
$logger, | |
); | |
} |
This one is really empty or did I miss something?
protected IManager $shareManager, | ||
protected IGroupManager $groupManager, | ||
protected IUserManager $userManager, | ||
protected IRootFolder $rootFolder, | ||
protected IURLGenerator $urlGenerator, | ||
protected IL10N $l, | ||
protected IConfig $config, | ||
protected IAppManager $appManager, | ||
protected ContainerInterface $serverContainer, | ||
protected IUserStatusManager $userStatusManager, | ||
protected IPreview $previewManager, | ||
protected IDateTimeZone $dateTimeZone, | ||
protected LoggerInterface $logger, | ||
protected IProviderFactory $factory, | ||
protected IMailer $mailer, | ||
string $userId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected IManager $shareManager, | |
protected IGroupManager $groupManager, | |
protected IUserManager $userManager, | |
protected IRootFolder $rootFolder, | |
protected IURLGenerator $urlGenerator, | |
protected IL10N $l, | |
protected IConfig $config, | |
protected IAppManager $appManager, | |
protected ContainerInterface $serverContainer, | |
protected IUserStatusManager $userStatusManager, | |
protected IPreview $previewManager, | |
protected IDateTimeZone $dateTimeZone, | |
protected LoggerInterface $logger, | |
protected IProviderFactory $factory, | |
protected IMailer $mailer, | |
string $userId, | |
IManager $shareManager, | |
IGroupManager $groupManager, | |
IUserManager $userManager, | |
IRootFolder $rootFolder, | |
IURLGenerator $urlGenerator, | |
IL10N $l, | |
protected IConfig $config, | |
IAppManager $appManager, | |
ContainerInterface $serverContainer, | |
IUserStatusManager $userStatusManager, | |
IPreview $previewManager, | |
IDateTimeZone $dateTimeZone, | |
LoggerInterface $logger, | |
protected IProviderFactory $factory, | |
protected IMailer $mailer, | |
?string $userId, |
Ideally I would also reorder to keep promoted properties together, I would say at the end (so, start with parameters from parent constructor in the same order as parent, add you own after)
protected LoggerInterface $logger, | ||
) { | ||
parent::__construct(Application::APP_ID, $request); | ||
$this->currentUser = $userId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->currentUser = $userId; |
Is there any added value to duplicate $this->userId into $this->currentUser?
If this is to have a clearer name, then remove the protected in front of $userId parameter to not turn it into a property, and keep $this->currentUser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's here because it was used by the controllers before this pr.
I want to keep changes to the existing parts to a minimal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was changed on master, so you should update your PR accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I need to take that PR back 🙈
Other issues this may address (did not link since I wasn't certain, but do so if appropriate please 😄 ): Related too: |
IRequest $request, | ||
ShareManager $shareManager, | ||
?string $userId, | ||
IUserManager $userManager, | ||
IGroupManager $groupManager, | ||
IRootFolder $rootFolder, | ||
IAppManager $appManager, | ||
ContainerInterface $serverContainer, | ||
UserStatusManager $userStatusManager, | ||
IPreview $previewManager, | ||
IDateTimeZone $dateTimeZone, | ||
IURLGenerator $urlGenerator, | ||
IL10N $l, | ||
LoggerInterface $logger, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are these properties and their access modifiers defined?
$groupShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_GROUP, null, -1, 0); | ||
$roomShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_ROOM, null, -1, 0); | ||
$deckShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_DECK, null, -1, 0); | ||
$sciencemeshShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_SCIENCEMESH, null, -1, 0); | ||
$linkShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_LINK, null, -1, 0); | ||
$userShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_USER, null, -1, 0); | ||
$emailsShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_EMAIL, null, -1, 0); | ||
$circlesShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_CIRCLE, null, -1, 0); | ||
$remoteShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_REMOTE, null, -1, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No way to get all? shareType
-1, could be default parameter in share Manager that returns all?
$groupShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_GROUP, null, -1, 0); | ||
$roomShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_ROOM, null, -1, 0); | ||
$deckShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_DECK, null, -1, 0); | ||
$sciencemeshShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_SCIENCEMESH, null, -1, 0); | ||
$linkShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_LINK, null, -1, 0); | ||
$userShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_USER, null, -1, 0); | ||
$emailsShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_EMAIL, null, -1, 0); | ||
$circlesShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_CIRCLE, null, -1, 0); | ||
$remoteShares = $this->shareManager->getExpiredShares($this->userId, IShare::TYPE_REMOTE, null, -1, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No way to get all? shareType
-1, could be default parameter in share Manager that returns all?
@@ -42,13 +41,16 @@ public function __construct(ITimeFactory $time, IManager $shareManager, IDBConne | |||
* @param array $argument unused argument | |||
*/ | |||
public function run($argument) { | |||
//Current time | |||
if ($this->config->getValueString('core', 'shareapi_delete_on_expire', 'yes') === 'no') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this would be a thing for config.php... We should
- Update
config.sample.php
that is an in code source documentation - Document this somewhere the administration manual
private $serverContainer; | ||
|
||
public function __construct(string $appName, | ||
class DeletedShareAPIController extends ShareApiControllerFactory { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick : Is this BaseShareApiController
or Factory? Factories are to help easy object creation, testing, decoupling not exactly DRY-ing?
Fix #17996
Feature
Shares that expires are just deleted. Which leads to confusion.
Solution
Status