|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Lukas Reschke <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* @license AGPL-3.0 |
|
8
|
|
|
* |
|
9
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
11
|
|
|
* as published by the Free Software Foundation. |
|
12
|
|
|
* |
|
13
|
|
|
* This program is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
* GNU Affero General Public License for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
20
|
|
|
* |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
namespace OCA\UpdateNotification; |
|
24
|
|
|
|
|
25
|
|
|
use OC\BackgroundJob\TimedJob; |
|
26
|
|
|
use OCP\AppFramework\Utility\ITimeFactory; |
|
27
|
|
|
use OCP\IConfig; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Class ResetTokenBackgroundJob deletes any configured token all 24 hours for |
|
31
|
|
|
* |
|
32
|
|
|
* |
|
33
|
|
|
* @package OCA\UpdateNotification |
|
34
|
|
|
*/ |
|
35
|
|
|
class ResetTokenBackgroundJob extends TimedJob { |
|
36
|
|
|
/** @var IConfig */ |
|
37
|
|
|
private $config; |
|
38
|
|
|
/** @var ITimeFactory */ |
|
39
|
|
|
private $timeFactory; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param IConfig $config |
|
43
|
|
|
* @param ITimeFactory $timeFactory |
|
44
|
|
|
*/ |
|
45
|
|
|
public function __construct(IConfig $config, |
|
46
|
|
|
ITimeFactory $timeFactory) { |
|
47
|
|
|
// Run all 10 minutes |
|
48
|
|
|
$this->setInterval(60 * 10); |
|
49
|
|
|
$this->config = $config; |
|
50
|
|
|
$this->timeFactory = $timeFactory; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param $argument |
|
55
|
|
|
*/ |
|
56
|
|
|
protected function run($argument) { |
|
57
|
|
|
// Delete old tokens after 2 days |
|
58
|
|
|
if($this->timeFactory->getTime() - $this->config->getAppValue('core', 'updater.secret.created', $this->timeFactory->getTime()) >= 172800) { |
|
59
|
|
|
$this->config->deleteSystemValue('updater.secret'); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
|