1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Circles - Bring cloud-users closer together. |
8
|
|
|
* |
9
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
10
|
|
|
* later. See the COPYING file. |
11
|
|
|
* |
12
|
|
|
* @author Maxence Lange <[email protected]> |
13
|
|
|
* @copyright 2021 |
14
|
|
|
* @license GNU AGPL version 3 or any later version |
15
|
|
|
* |
16
|
|
|
* This program is free software: you can redistribute it and/or modify |
17
|
|
|
* it under the terms of the GNU Affero General Public License as |
18
|
|
|
* published by the Free Software Foundation, either version 3 of the |
19
|
|
|
* License, or (at your option) any later version. |
20
|
|
|
* |
21
|
|
|
* This program is distributed in the hope that it will be useful, |
22
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
23
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
24
|
|
|
* GNU Affero General Public License for more details. |
25
|
|
|
* |
26
|
|
|
* You should have received a copy of the GNU Affero General Public License |
27
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
28
|
|
|
* |
29
|
|
|
*/ |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
namespace OCA\Circles\FederatedItems\Files; |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
use daita\MySmallPhpTools\Exceptions\InvalidItemException; |
36
|
|
|
use daita\MySmallPhpTools\Exceptions\UnknownTypeException; |
37
|
|
|
use daita\MySmallPhpTools\Traits\Nextcloud\nc22\TNC22Logger; |
38
|
|
|
use daita\MySmallPhpTools\Traits\TStringTools; |
39
|
|
|
use OCA\Circles\Db\MountRequest; |
40
|
|
|
use OCA\Circles\IFederatedItem; |
41
|
|
|
use OCA\Circles\IFederatedItemAsyncProcess; |
42
|
|
|
use OCA\Circles\IFederatedItemMemberEmpty; |
43
|
|
|
use OCA\Circles\Model\Federated\FederatedEvent; |
44
|
|
|
use OCA\Circles\Model\ShareWrapper; |
45
|
|
|
use OCA\Circles\Service\ConfigService; |
46
|
|
|
use OCA\Circles\Service\EventService; |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Class FileUnshare |
51
|
|
|
* |
52
|
|
|
* @package OCA\Circles\FederatedItems |
53
|
|
|
*/ |
54
|
|
|
class FileUnshare implements |
55
|
|
|
IFederatedItem, |
56
|
|
|
IFederatedItemAsyncProcess, |
57
|
|
|
IFederatedItemMemberEmpty { |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
use TStringTools; |
61
|
|
|
use TNC22Logger; |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
/** @var MountRequest */ |
65
|
|
|
private $mountRequest; |
66
|
|
|
|
67
|
|
|
/** @var EventService */ |
68
|
|
|
private $eventService; |
69
|
|
|
|
70
|
|
|
/** @var ConfigService */ |
71
|
|
|
private $configService; |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* FileUnshare constructor. |
76
|
|
|
* |
77
|
|
|
* @param MountRequest $mountRequest |
78
|
|
|
* @param EventService $eventService |
79
|
|
|
* @param ConfigService $configService |
80
|
|
|
*/ |
81
|
|
|
public function __construct( |
82
|
|
|
MountRequest $mountRequest, |
83
|
|
|
EventService $eventService, |
84
|
|
|
ConfigService $configService |
85
|
|
|
) { |
86
|
|
|
$this->mountRequest = $mountRequest; |
87
|
|
|
$this->eventService = $eventService; |
88
|
|
|
$this->configService = $configService; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param FederatedEvent $event |
94
|
|
|
*/ |
95
|
|
|
public function verify(FederatedEvent $event): void { |
96
|
|
|
// TODO: check and improve |
97
|
|
|
// TODO: Could we use a share lock ? |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @param FederatedEvent $event |
103
|
|
|
* |
104
|
|
|
* @throws InvalidItemException |
105
|
|
|
* @throws UnknownTypeException |
106
|
|
|
*/ |
107
|
|
|
public function manage(FederatedEvent $event): void { |
108
|
|
|
if ($this->configService->isLocalInstance($event->getOrigin())) { |
109
|
|
|
return; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** @var ShareWrapper $wrappedShare */ |
113
|
|
|
$wrappedShare = $event->getData()->gObj('wrappedShare', ShareWrapper::class); |
114
|
|
|
|
115
|
|
|
$this->mountRequest->delete($wrappedShare->getToken()); |
116
|
|
|
$this->eventService->federatedShareDeleted($wrappedShare); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param FederatedEvent $event |
122
|
|
|
* @param array $results |
123
|
|
|
*/ |
124
|
|
|
public function result(FederatedEvent $event, array $results): void { |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
|