From d0fff89928a8d5f7f0e7c69809dba6fcc19f8f52 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 18 Feb 2022 17:45:17 +0100 Subject: [PATCH] Mark background jobs as time sensitive/insensitive Signed-off-by: Christoph Wurst --- lib/Cron/SocialUpdateRegistration.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/Cron/SocialUpdateRegistration.php b/lib/Cron/SocialUpdateRegistration.php index 1f4e1497..ddb2e4b7 100644 --- a/lib/Cron/SocialUpdateRegistration.php +++ b/lib/Cron/SocialUpdateRegistration.php @@ -1,4 +1,7 @@ * @@ -29,11 +32,13 @@ use OCA\Contacts\AppInfo\Application; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJobList; +use OCP\BackgroundJob\TimedJob; use OCP\IUser; use OCP\IConfig; use OCP\IUserManager; +use function method_exists; -class SocialUpdateRegistration extends \OC\BackgroundJob\TimedJob { +class SocialUpdateRegistration extends TimedJob { private $appName; /** @var IUserManager */ @@ -53,19 +58,25 @@ class SocialUpdateRegistration extends \OC\BackgroundJob\TimedJob { * @param IJobList $jobList */ public function __construct( - // ITimeFactory $time, + ITimeFactory $time, IUserManager $userManager, IConfig $config, IJobList $jobList) { - //parent::__construct($time); - + parent::__construct($time); + $this->appName = Application::APP_ID; $this->userManager = $userManager; $this->config = $config; $this->jobList = $jobList; // Run once a week - parent::setInterval(7 * 24 * 60 * 60); + $this->setInterval(7 * 24 * 60 * 60); + /** + * @todo remove check with 24+ + */ + if (method_exists($this, 'setTimeSensitivity')) { + $this->setTimeSensitivity(self::TIME_INSENSITIVE); + } } /**