Skip to content

Conversation

@susnux
Copy link
Contributor

@susnux susnux commented Sep 25, 2024

Summary

Migrate code from hooks to typed events, also unify the user events as some had already a getUid method -> now all provide this convenient helper.

Checklist

@susnux susnux added technical debt ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) labels Sep 25, 2024
@susnux susnux added this to the Nextcloud 31 milestone Sep 25, 2024
@susnux susnux force-pushed the chore/migrate-encryption-away-from-hooks branch from f32d12e to dbf60ac Compare September 25, 2024 01:03
@susnux susnux force-pushed the chore/migrate-encryption-away-from-hooks branch from 93dea23 to 09afc2d Compare September 25, 2024 01:22
@susnux susnux force-pushed the chore/migrate-encryption-away-from-hooks branch 5 times, most recently from a080187 to e392348 Compare September 25, 2024 15:20
@susnux susnux added the 3. to review Waiting for reviews label Sep 25, 2024
Comment on lines +301 to +304
if ($passPhrase === null) {
$this->logger->warning('Master key is disabled but not passphrase provided.');
return false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a change not entirely related to the refactor and it should also be backported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a psalm error that was ignored before as it could be possible that null is passed (e.g. with master key) this was simply ignored before.

Copy link
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I like the getUid thing, especially since it uses a different casing than the method from IUser.
Otherwise, great work!

}

/**
* @since 31.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance of moving these events to OCP without creating a mess?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC the event name is the class string of the event, meaning we can not move without also emitting the old event until it is deprecated enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I would say this makes sense, but please in a follow up

@susnux
Copy link
Contributor Author

susnux commented Sep 26, 2024

Not sure I like the getUid thing, especially since it uses a different casing than the method from IUser.

The IUser one is quite old, older than our naming guidelines that prefer Uid over UID (or Url over URL).
But I am fine with removing it again, I just thought it would make sense to unify it as there are already events with getUid (exactly that casing).

@susnux susnux force-pushed the chore/migrate-encryption-away-from-hooks branch from c9eaac9 to fa428fb Compare September 26, 2024 18:14
@susnux susnux requested review from artonge and come-nc September 26, 2024 18:16
$this->onPasswordUpdated($event->getUid(), $event->getPassword(), $event->getRecoveryPassword());
} elseif($event instanceof BeforePasswordResetEvent) {
$this->onBeforePasswordReset($event->getUid());
} elseif($event instanceof PasswordResetEvent) {

Check notice

Code scanning / Psalm

RedundantConditionGivenDocblockType

Docblock-defined type OC\Core\Events\PasswordResetEvent for $event is always OC\Core\Events\PasswordResetEvent
Copy link
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good apart from the catch Throwable thing.

@susnux susnux force-pushed the chore/migrate-encryption-away-from-hooks branch from 6654d12 to 4582d30 Compare October 11, 2024 12:20
@susnux susnux requested a review from come-nc October 11, 2024 12:20
@susnux susnux force-pushed the chore/migrate-encryption-away-from-hooks branch 3 times, most recently from 0be66d1 to bcd59f4 Compare October 15, 2024 15:06
susnux and others added 2 commits October 15, 2024 18:33
Co-authored-by: Ferdinand Thiessen <[email protected]>
Co-authored-by: Louis <[email protected]>
Co-authored-by: Côme Chilliet <[email protected]>
Signed-off-by: Ferdinand Thiessen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) technical debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants