From 2738e08abbd5ff42ed9a8edc009800dc6fc16d4f Mon Sep 17 00:00:00 2001 From: Alfonso Salces Date: Wed, 24 May 2023 15:37:20 +0200 Subject: [PATCH] MOBILE-4344 cron: Check notification and messages --- src/addons/messages/services/handlers/mainmenu.ts | 9 ++++++++- src/addons/notifications/services/handlers/cron.ts | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/addons/messages/services/handlers/mainmenu.ts b/src/addons/messages/services/handlers/mainmenu.ts index 33a78c18c..fe778d9ed 100644 --- a/src/addons/messages/services/handlers/mainmenu.ts +++ b/src/addons/messages/services/handlers/mainmenu.ts @@ -191,7 +191,14 @@ export class AddonMessagesMainMenuHandlerService implements CoreMainMenuHandler, * @returns Promise resolved when done, rejected if failure. */ async execute(siteId?: string): Promise { - if (!CoreSites.isCurrentSite(siteId)) { + const site = CoreSites.getCurrentSite(); + + if ( + !CoreSites.isCurrentSite(siteId) || + !site || + site.isFeatureDisabled('CoreMainMenuDelegate_AddonMessages') || + !site.canUseAdvancedFeature('messaging') + ) { return; } diff --git a/src/addons/notifications/services/handlers/cron.ts b/src/addons/notifications/services/handlers/cron.ts index eebd2e1cb..b4633305d 100644 --- a/src/addons/notifications/services/handlers/cron.ts +++ b/src/addons/notifications/services/handlers/cron.ts @@ -67,7 +67,13 @@ export class AddonNotificationsCronHandlerService implements CoreCronHandler { */ // eslint-disable-next-line @typescript-eslint/no-unused-vars async execute(siteId?: string, force?: boolean): Promise { - if (!CoreSites.isCurrentSite(siteId)) { + const site = CoreSites.getCurrentSite(); + + if ( + !CoreSites.isCurrentSite(siteId) || + !site || + site.isFeatureDisabled('CoreMainMenuDelegate_AddonNotifications') + ) { return; }