diff options
author | call-me-matt <nextcloud@matthiasheinisch.de> | 2020-09-06 01:48:04 +0300 |
---|---|---|
committer | call-me-matt <nextcloud@matthiasheinisch.de> | 2020-09-06 01:48:04 +0300 |
commit | ba67a50ecedc7dfa9eba36992726504c0e6d39bc (patch) | |
tree | 1c84dd93e0df8374a325ca348136d8c879043f8d /lib/Cron | |
parent | 33a53fc732e9f65bf37d162cc449ef80ab122303 (diff) |
perform sanity checks
Signed-off-by: call-me-matt <nextcloud@matthiasheinisch.de>
Diffstat (limited to 'lib/Cron')
-rw-r--r-- | lib/Cron/SocialUpdate.php | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Cron/SocialUpdate.php b/lib/Cron/SocialUpdate.php index af9da459..46621e25 100644 --- a/lib/Cron/SocialUpdate.php +++ b/lib/Cron/SocialUpdate.php @@ -42,8 +42,8 @@ class SocialUpdate extends \OC\BackgroundJob\QueuedJob { protected function run($arguments) { $userId = $arguments['userId']; - $offsetBook = $arguments['offsetBook']; - $offsetContact = $arguments['offsetContact']; + $offsetBook = $arguments['offsetBook'] ?? null; + $offsetContact = $arguments['offsetContact'] ?? null; // update contacts with first available social media profile $result = $this->social->updateAddressbooks('any', $userId, $offsetBook, $offsetContact); @@ -53,6 +53,16 @@ class SocialUpdate extends \OC\BackgroundJob\QueuedJob { $report = $result->getData(); $stoppedAtBook = $report[0]['stoppedAt']['addressBook']; $stoppedAtContact = $report[0]['stoppedAt']['contact']; + + // make sure the offset contact/address book are still existing + if ($this->social->existsAddressBook($stoppedAtBook, $userId) == false) { + $stoppedAtBook = null; + } + if ($this->social->existsContact($stoppedAtContact, $stoppedAtBook, $userId) == false) { + $stoppedAtContact = null; + } + // TODO: can we check the userId still exists? + $this->jobList->add(self::class, [ 'userId' => $userId, 'offsetBook' => $stoppedAtBook, |