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\Listeners\Files; |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
use daita\MySmallPhpTools\Traits\TStringTools; |
36
|
|
|
use OCA\Circles\Events\CircleMemberAddedEvent; |
37
|
|
|
use OCA\Circles\Model\Member; |
38
|
|
|
use OCP\EventDispatcher\Event; |
39
|
|
|
use OCP\EventDispatcher\IEventListener; |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Class MemberAdded |
44
|
|
|
* |
45
|
|
|
* @package OCA\Circles\Listeners\Files |
46
|
|
|
*/ |
47
|
|
|
class MemberAdded implements IEventListener { |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
use TStringTools; |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param Event $event |
55
|
|
|
*/ |
56
|
|
|
public function handle(Event $event): void { |
57
|
|
|
if (!$event instanceof CircleMemberAddedEvent) { |
58
|
|
|
return; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$federatedUsers = []; |
62
|
|
|
$member = $event->getMember(); |
63
|
|
|
if ($member->getUserType() === Member::TYPE_MAIL) { |
64
|
|
|
$federatedUsers[] = $member; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
if (empty($federatedUsers)) { |
68
|
|
|
return; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
$result = []; |
72
|
|
|
foreach ($event->getResults() as $instance => $item) { |
73
|
|
|
$result[$instance] = $item->gData('files'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
\OC::$server->getLogger()->log(3, 'FILES: ' . json_encode($result)); |
77
|
|
|
\OC::$server->getLogger()->log(3, 'MAILS: ' . json_encode($federatedUsers)); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
|