Skip to content
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

fix(flow_notifications): Improve app loading by checking if notificat… #227

Conversation

falghamdi125
Copy link
Contributor

@falghamdi125 falghamdi125 commented Oct 26, 2024

The PR basically improves app loading by checking if the notifications app is not installed and enabled when registering flow_notifications to prevent user workflow page from crashing by aborting app registering and log the error.

The error log message suggests & guides sysadmin to install the notifications app to allow registering flow_notifications.

@falghamdi125 falghamdi125 force-pushed the falghamdi125-improve-app-loading-by-making-sure-notifications-app-installed branch 2 times, most recently from add1f8a to 34921ea Compare October 26, 2024 22:02
Copy link
Member

@blizzz blizzz left a comment

Choose a reason for hiding this comment

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

Hi @falghamdi125 and thanks for your contribution!

I have a small nitpick in the code, and also please run composer i && composer run cs:fix and amend the resulting code style changes to the commit.

) {
}

public function handle(Event $event): void {
if (!$event instanceof RegisterOperationsEvent) {
return;
} else if(!$this->appManager->isInstalled('notifications') ||
!$this->appManager->isEnabledForUser('notifications')) {
$logger = \OC::$server->get(LoggerInterface::class);
Copy link
Member

Choose a reason for hiding this comment

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

please either inject the LoggerInterface in the constructor, or use \OCP\Log\logger(Application::APP_ID)->error(…)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! I pushed a followup commit for the style, that is not reflected in the cs-fixer rules yet, to have the operators on a new line.

Copy link
Member

Choose a reason for hiding this comment

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

… on hindsight, the isInstalled check is not necessary, having !$this->appManager->isEnabledForUser('notifications') is already sufficient.

Also, a brief hint into the descriptions https://github.com/nextcloud/flow_notifications/blob/master/appinfo/info.xml#L11 that notifications app is required could be a good addition, perhaps also into the Readme.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. You can't get isEnabledForUser true if the app wasn't installed. Code updated!

@falghamdi125 falghamdi125 force-pushed the falghamdi125-improve-app-loading-by-making-sure-notifications-app-installed branch 2 times, most recently from f7d2b8f to 67d3855 Compare November 5, 2024 20:22
@blizzz blizzz force-pushed the falghamdi125-improve-app-loading-by-making-sure-notifications-app-installed branch from 1cb3566 to b9228f1 Compare November 6, 2024 11:32
…ions app is not installed and enabled when registering the app

Signed-off-by: Faisal Alghamdi <[email protected]>
@falghamdi125 falghamdi125 force-pushed the falghamdi125-improve-app-loading-by-making-sure-notifications-app-installed branch from b9228f1 to cc540d3 Compare November 7, 2024 23:39
@blizzz blizzz merged commit 388d27b into nextcloud:master Nov 8, 2024
19 checks passed
@blizzz blizzz added 4. to release Ready to be released and/or waiting for tests to finish bug Something isn't working labels Nov 8, 2024
@blizzz
Copy link
Member

blizzz commented Nov 8, 2024

/backport to stable30

@backportbot backportbot bot added the backport-request A backport was requested for this pull request label Nov 8, 2024
@blizzz
Copy link
Member

blizzz commented Nov 8, 2024

/backport to stable29

@blizzz
Copy link
Member

blizzz commented Nov 8, 2024

/backport to stable28

Copy link

backportbot bot commented Nov 8, 2024

The backport to stable29 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable29
git pull origin stable29

# Create the new backport branch
git checkout -b backport/227/stable29

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts, resolve them
git cherry-pick cc540d37

# Push the cherry pick commit to the remote repository and open a pull request
git push origin backport/227/stable29

Error: No changes found in backport branch


Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

@backportbot backportbot bot removed the backport-request A backport was requested for this pull request label Nov 8, 2024
Copy link

backportbot bot commented Nov 8, 2024

The backport to stable28 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable28
git pull origin stable28

# Create the new backport branch
git checkout -b backport/227/stable28

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts, resolve them
git cherry-pick cc540d37

# Push the cherry pick commit to the remote repository and open a pull request
git push origin backport/227/stable28

Error: No changes found in backport branch


Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

@falghamdi125 falghamdi125 deleted the falghamdi125-improve-app-loading-by-making-sure-notifications-app-installed branch November 8, 2024 12:33
Copy link
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@blizzz
Copy link
Member

blizzz commented Nov 11, 2024

fwiw, code diverted a bit so backports to 29 and below do not apply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish bug Something isn't working feedback-requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User workflow page crashes when flow_notifications enabled and notifications app isn't installed.
2 participants