@@ -27,41 +27,41 @@ |
||
27 | 27 | * @since 12.0.0 |
28 | 28 | */ |
29 | 29 | interface ISearchQuery { |
30 | - /** |
|
31 | - * @return ISearchOperator |
|
32 | - * @since 12.0.0 |
|
33 | - */ |
|
34 | - public function getSearchOperation(); |
|
30 | + /** |
|
31 | + * @return ISearchOperator |
|
32 | + * @since 12.0.0 |
|
33 | + */ |
|
34 | + public function getSearchOperation(); |
|
35 | 35 | |
36 | - /** |
|
37 | - * Get the maximum number of results to return |
|
38 | - * |
|
39 | - * @return integer |
|
40 | - * @since 12.0.0 |
|
41 | - */ |
|
42 | - public function getLimit(); |
|
36 | + /** |
|
37 | + * Get the maximum number of results to return |
|
38 | + * |
|
39 | + * @return integer |
|
40 | + * @since 12.0.0 |
|
41 | + */ |
|
42 | + public function getLimit(); |
|
43 | 43 | |
44 | - /** |
|
45 | - * Get the offset for returned results |
|
46 | - * |
|
47 | - * @return integer |
|
48 | - * @since 12.0.0 |
|
49 | - */ |
|
50 | - public function getOffset(); |
|
44 | + /** |
|
45 | + * Get the offset for returned results |
|
46 | + * |
|
47 | + * @return integer |
|
48 | + * @since 12.0.0 |
|
49 | + */ |
|
50 | + public function getOffset(); |
|
51 | 51 | |
52 | - /** |
|
53 | - * The fields and directions to order by |
|
54 | - * |
|
55 | - * @return ISearchOrder[] |
|
56 | - * @since 12.0.0 |
|
57 | - */ |
|
58 | - public function getOrder(); |
|
52 | + /** |
|
53 | + * The fields and directions to order by |
|
54 | + * |
|
55 | + * @return ISearchOrder[] |
|
56 | + * @since 12.0.0 |
|
57 | + */ |
|
58 | + public function getOrder(); |
|
59 | 59 | |
60 | - /** |
|
61 | - * The user that issued the search |
|
62 | - * |
|
63 | - * @return IUser |
|
64 | - * @since 12.0.0 |
|
65 | - */ |
|
66 | - public function getUser(); |
|
60 | + /** |
|
61 | + * The user that issued the search |
|
62 | + * |
|
63 | + * @return IUser |
|
64 | + * @since 12.0.0 |
|
65 | + */ |
|
66 | + public function getUser(); |
|
67 | 67 | } |
@@ -27,66 +27,66 @@ |
||
27 | 27 | use OCP\IUser; |
28 | 28 | |
29 | 29 | class SearchQuery implements ISearchQuery { |
30 | - /** @var ISearchOperator */ |
|
31 | - private $searchOperation; |
|
32 | - /** @var integer */ |
|
33 | - private $limit; |
|
34 | - /** @var integer */ |
|
35 | - private $offset; |
|
36 | - /** @var ISearchOrder[] */ |
|
37 | - private $order; |
|
38 | - /** @var IUser */ |
|
39 | - private $user; |
|
30 | + /** @var ISearchOperator */ |
|
31 | + private $searchOperation; |
|
32 | + /** @var integer */ |
|
33 | + private $limit; |
|
34 | + /** @var integer */ |
|
35 | + private $offset; |
|
36 | + /** @var ISearchOrder[] */ |
|
37 | + private $order; |
|
38 | + /** @var IUser */ |
|
39 | + private $user; |
|
40 | 40 | |
41 | - /** |
|
42 | - * SearchQuery constructor. |
|
43 | - * |
|
44 | - * @param ISearchOperator $searchOperation |
|
45 | - * @param int $limit |
|
46 | - * @param int $offset |
|
47 | - * @param array $order |
|
48 | - * @param IUser $user |
|
49 | - */ |
|
50 | - public function __construct(ISearchOperator $searchOperation, $limit, $offset, array $order, IUser $user) { |
|
51 | - $this->searchOperation = $searchOperation; |
|
52 | - $this->limit = $limit; |
|
53 | - $this->offset = $offset; |
|
54 | - $this->order = $order; |
|
55 | - $this->user = $user; |
|
56 | - } |
|
41 | + /** |
|
42 | + * SearchQuery constructor. |
|
43 | + * |
|
44 | + * @param ISearchOperator $searchOperation |
|
45 | + * @param int $limit |
|
46 | + * @param int $offset |
|
47 | + * @param array $order |
|
48 | + * @param IUser $user |
|
49 | + */ |
|
50 | + public function __construct(ISearchOperator $searchOperation, $limit, $offset, array $order, IUser $user) { |
|
51 | + $this->searchOperation = $searchOperation; |
|
52 | + $this->limit = $limit; |
|
53 | + $this->offset = $offset; |
|
54 | + $this->order = $order; |
|
55 | + $this->user = $user; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return ISearchOperator |
|
60 | - */ |
|
61 | - public function getSearchOperation() { |
|
62 | - return $this->searchOperation; |
|
63 | - } |
|
58 | + /** |
|
59 | + * @return ISearchOperator |
|
60 | + */ |
|
61 | + public function getSearchOperation() { |
|
62 | + return $this->searchOperation; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return int |
|
67 | - */ |
|
68 | - public function getLimit() { |
|
69 | - return $this->limit; |
|
70 | - } |
|
65 | + /** |
|
66 | + * @return int |
|
67 | + */ |
|
68 | + public function getLimit() { |
|
69 | + return $this->limit; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @return int |
|
74 | - */ |
|
75 | - public function getOffset() { |
|
76 | - return $this->offset; |
|
77 | - } |
|
72 | + /** |
|
73 | + * @return int |
|
74 | + */ |
|
75 | + public function getOffset() { |
|
76 | + return $this->offset; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @return ISearchOrder[] |
|
81 | - */ |
|
82 | - public function getOrder() { |
|
83 | - return $this->order; |
|
84 | - } |
|
79 | + /** |
|
80 | + * @return ISearchOrder[] |
|
81 | + */ |
|
82 | + public function getOrder() { |
|
83 | + return $this->order; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @return IUser |
|
88 | - */ |
|
89 | - public function getUser() { |
|
90 | - return $this->user; |
|
91 | - } |
|
86 | + /** |
|
87 | + * @return IUser |
|
88 | + */ |
|
89 | + public function getUser() { |
|
90 | + return $this->user; |
|
91 | + } |
|
92 | 92 | } |
@@ -24,92 +24,92 @@ |
||
24 | 24 | namespace OC\OCS; |
25 | 25 | |
26 | 26 | class Provider extends \OCP\AppFramework\Controller { |
27 | - /** @var \OCP\App\IAppManager */ |
|
28 | - private $appManager; |
|
27 | + /** @var \OCP\App\IAppManager */ |
|
28 | + private $appManager; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param string $appName |
|
32 | - * @param \OCP\IRequest $request |
|
33 | - * @param \OCP\App\IAppManager $appManager |
|
34 | - */ |
|
35 | - public function __construct($appName, |
|
36 | - \OCP\IRequest $request, |
|
37 | - \OCP\App\IAppManager $appManager) { |
|
38 | - parent::__construct($appName, $request); |
|
39 | - $this->appManager = $appManager; |
|
40 | - } |
|
30 | + /** |
|
31 | + * @param string $appName |
|
32 | + * @param \OCP\IRequest $request |
|
33 | + * @param \OCP\App\IAppManager $appManager |
|
34 | + */ |
|
35 | + public function __construct($appName, |
|
36 | + \OCP\IRequest $request, |
|
37 | + \OCP\App\IAppManager $appManager) { |
|
38 | + parent::__construct($appName, $request); |
|
39 | + $this->appManager = $appManager; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return \OCP\AppFramework\Http\JSONResponse |
|
44 | - */ |
|
45 | - public function buildProviderList() { |
|
46 | - $services = [ |
|
47 | - 'PRIVATE_DATA' => [ |
|
48 | - 'version' => 1, |
|
49 | - 'endpoints' => [ |
|
50 | - 'store' => '/ocs/v2.php/privatedata/setattribute', |
|
51 | - 'read' => '/ocs/v2.php/privatedata/getattribute', |
|
52 | - 'delete' => '/ocs/v2.php/privatedata/deleteattribute', |
|
53 | - ], |
|
54 | - ], |
|
55 | - ]; |
|
42 | + /** |
|
43 | + * @return \OCP\AppFramework\Http\JSONResponse |
|
44 | + */ |
|
45 | + public function buildProviderList() { |
|
46 | + $services = [ |
|
47 | + 'PRIVATE_DATA' => [ |
|
48 | + 'version' => 1, |
|
49 | + 'endpoints' => [ |
|
50 | + 'store' => '/ocs/v2.php/privatedata/setattribute', |
|
51 | + 'read' => '/ocs/v2.php/privatedata/getattribute', |
|
52 | + 'delete' => '/ocs/v2.php/privatedata/deleteattribute', |
|
53 | + ], |
|
54 | + ], |
|
55 | + ]; |
|
56 | 56 | |
57 | - if($this->appManager->isEnabledForUser('files_sharing')) { |
|
58 | - $services['SHARING'] = [ |
|
59 | - 'version' => 1, |
|
60 | - 'endpoints' => [ |
|
61 | - 'share' => '/ocs/v2.php/apps/files_sharing/api/v1/shares', |
|
62 | - ], |
|
63 | - ]; |
|
64 | - $services['FEDERATED_SHARING'] = [ |
|
65 | - 'version' => 1, |
|
66 | - 'endpoints' => [ |
|
67 | - 'share' => '/ocs/v2.php/cloud/shares', |
|
68 | - 'webdav' => '/public.php/webdav/', |
|
69 | - ], |
|
70 | - ]; |
|
71 | - } |
|
57 | + if($this->appManager->isEnabledForUser('files_sharing')) { |
|
58 | + $services['SHARING'] = [ |
|
59 | + 'version' => 1, |
|
60 | + 'endpoints' => [ |
|
61 | + 'share' => '/ocs/v2.php/apps/files_sharing/api/v1/shares', |
|
62 | + ], |
|
63 | + ]; |
|
64 | + $services['FEDERATED_SHARING'] = [ |
|
65 | + 'version' => 1, |
|
66 | + 'endpoints' => [ |
|
67 | + 'share' => '/ocs/v2.php/cloud/shares', |
|
68 | + 'webdav' => '/public.php/webdav/', |
|
69 | + ], |
|
70 | + ]; |
|
71 | + } |
|
72 | 72 | |
73 | - if ($this->appManager->isEnabledForUser('federation')) { |
|
74 | - if (isset($services['FEDERATED_SHARING'])) { |
|
75 | - $services['FEDERATED_SHARING']['endpoints']['shared-secret'] = '/ocs/v2.php/cloud/shared-secret'; |
|
76 | - $services['FEDERATED_SHARING']['endpoints']['system-address-book'] = '/remote.php/dav/addressbooks/system/system/system'; |
|
77 | - $services['FEDERATED_SHARING']['endpoints']['carddav-user'] = 'system'; |
|
78 | - } else { |
|
79 | - $services['FEDERATED_SHARING'] = [ |
|
80 | - 'version' => 1, |
|
81 | - 'endpoints' => [ |
|
82 | - 'shared-secret' => '/ocs/v2.php/cloud/shared-secret', |
|
83 | - 'system-address-book' => '/remote.php/dav/addressbooks/system/system/system', |
|
84 | - 'carddav-user' => 'system' |
|
85 | - ], |
|
86 | - ]; |
|
87 | - } |
|
88 | - } |
|
73 | + if ($this->appManager->isEnabledForUser('federation')) { |
|
74 | + if (isset($services['FEDERATED_SHARING'])) { |
|
75 | + $services['FEDERATED_SHARING']['endpoints']['shared-secret'] = '/ocs/v2.php/cloud/shared-secret'; |
|
76 | + $services['FEDERATED_SHARING']['endpoints']['system-address-book'] = '/remote.php/dav/addressbooks/system/system/system'; |
|
77 | + $services['FEDERATED_SHARING']['endpoints']['carddav-user'] = 'system'; |
|
78 | + } else { |
|
79 | + $services['FEDERATED_SHARING'] = [ |
|
80 | + 'version' => 1, |
|
81 | + 'endpoints' => [ |
|
82 | + 'shared-secret' => '/ocs/v2.php/cloud/shared-secret', |
|
83 | + 'system-address-book' => '/remote.php/dav/addressbooks/system/system/system', |
|
84 | + 'carddav-user' => 'system' |
|
85 | + ], |
|
86 | + ]; |
|
87 | + } |
|
88 | + } |
|
89 | 89 | |
90 | - if($this->appManager->isEnabledForUser('activity')) { |
|
91 | - $services['ACTIVITY'] = [ |
|
92 | - 'version' => 1, |
|
93 | - 'endpoints' => [ |
|
94 | - 'list' => '/ocs/v2.php/cloud/activity', |
|
95 | - ], |
|
96 | - ]; |
|
97 | - } |
|
90 | + if($this->appManager->isEnabledForUser('activity')) { |
|
91 | + $services['ACTIVITY'] = [ |
|
92 | + 'version' => 1, |
|
93 | + 'endpoints' => [ |
|
94 | + 'list' => '/ocs/v2.php/cloud/activity', |
|
95 | + ], |
|
96 | + ]; |
|
97 | + } |
|
98 | 98 | |
99 | - if($this->appManager->isEnabledForUser('provisioning_api')) { |
|
100 | - $services['PROVISIONING'] = [ |
|
101 | - 'version' => 1, |
|
102 | - 'endpoints' => [ |
|
103 | - 'user' => '/ocs/v2.php/cloud/users', |
|
104 | - 'groups' => '/ocs/v2.php/cloud/groups', |
|
105 | - 'apps' => '/ocs/v2.php/cloud/apps', |
|
106 | - ], |
|
107 | - ]; |
|
108 | - } |
|
99 | + if($this->appManager->isEnabledForUser('provisioning_api')) { |
|
100 | + $services['PROVISIONING'] = [ |
|
101 | + 'version' => 1, |
|
102 | + 'endpoints' => [ |
|
103 | + 'user' => '/ocs/v2.php/cloud/users', |
|
104 | + 'groups' => '/ocs/v2.php/cloud/groups', |
|
105 | + 'apps' => '/ocs/v2.php/cloud/apps', |
|
106 | + ], |
|
107 | + ]; |
|
108 | + } |
|
109 | 109 | |
110 | - return new \OCP\AppFramework\Http\JSONResponse([ |
|
111 | - 'version' => 2, |
|
112 | - 'services' => $services, |
|
113 | - ]); |
|
114 | - } |
|
110 | + return new \OCP\AppFramework\Http\JSONResponse([ |
|
111 | + 'version' => 2, |
|
112 | + 'services' => $services, |
|
113 | + ]); |
|
114 | + } |
|
115 | 115 | } |
@@ -29,38 +29,38 @@ |
||
29 | 29 | use ID3Parser\ID3Parser; |
30 | 30 | |
31 | 31 | class MP3 extends Provider { |
32 | - /** |
|
33 | - * {@inheritDoc} |
|
34 | - */ |
|
35 | - public function getMimeType() { |
|
36 | - return '/audio\/mpeg/'; |
|
37 | - } |
|
32 | + /** |
|
33 | + * {@inheritDoc} |
|
34 | + */ |
|
35 | + public function getMimeType() { |
|
36 | + return '/audio\/mpeg/'; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * {@inheritDoc} |
|
41 | - */ |
|
42 | - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { |
|
43 | - $getID3 = new ID3Parser(); |
|
39 | + /** |
|
40 | + * {@inheritDoc} |
|
41 | + */ |
|
42 | + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { |
|
43 | + $getID3 = new ID3Parser(); |
|
44 | 44 | |
45 | - $tmpPath = $fileview->toTmpFile($path); |
|
46 | - $tags = $getID3->analyze($tmpPath); |
|
47 | - unlink($tmpPath); |
|
48 | - $picture = isset($tags['id3v2']['APIC'][0]['data']) ? $tags['id3v2']['APIC'][0]['data'] : null; |
|
49 | - if(is_null($picture) && isset($tags['id3v2']['PIC'][0]['data'])) { |
|
50 | - $picture = $tags['id3v2']['PIC'][0]['data']; |
|
51 | - } |
|
45 | + $tmpPath = $fileview->toTmpFile($path); |
|
46 | + $tags = $getID3->analyze($tmpPath); |
|
47 | + unlink($tmpPath); |
|
48 | + $picture = isset($tags['id3v2']['APIC'][0]['data']) ? $tags['id3v2']['APIC'][0]['data'] : null; |
|
49 | + if(is_null($picture) && isset($tags['id3v2']['PIC'][0]['data'])) { |
|
50 | + $picture = $tags['id3v2']['PIC'][0]['data']; |
|
51 | + } |
|
52 | 52 | |
53 | - if(!is_null($picture)) { |
|
54 | - $image = new \OC_Image(); |
|
55 | - $image->loadFromData($picture); |
|
53 | + if(!is_null($picture)) { |
|
54 | + $image = new \OC_Image(); |
|
55 | + $image->loadFromData($picture); |
|
56 | 56 | |
57 | - if ($image->valid()) { |
|
58 | - $image->scaleDownToFit($maxX, $maxY); |
|
57 | + if ($image->valid()) { |
|
58 | + $image->scaleDownToFit($maxX, $maxY); |
|
59 | 59 | |
60 | - return $image; |
|
61 | - } |
|
62 | - } |
|
60 | + return $image; |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - return false; |
|
65 | - } |
|
64 | + return false; |
|
65 | + } |
|
66 | 66 | } |
@@ -23,18 +23,18 @@ |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | return [ |
26 | - 'routes' => [ |
|
27 | - ['name' => 'MountPublicLink#createFederatedShare', 'url' => '/createFederatedShare', 'verb' => 'POST'], |
|
28 | - ['name' => 'MountPublicLink#askForFederatedShare', 'url' => '/askForFederatedShare', 'verb' => 'POST'], |
|
29 | - ], |
|
30 | - 'ocs' => [ |
|
31 | - ['root' => '/cloud', 'name' => 'RequestHandler#createShare', 'url' => '/shares', 'verb' => 'POST'], |
|
32 | - ['root' => '/cloud', 'name' => 'RequestHandler#reShare', 'url' => '/shares/{id}/reshare', 'verb' => 'POST'], |
|
33 | - ['root' => '/cloud', 'name' => 'RequestHandler#updatePermissions', 'url' => '/shares/{id}/permissions', 'verb' => 'POST'], |
|
34 | - ['root' => '/cloud', 'name' => 'RequestHandler#acceptShare', 'url' => '/shares/{id}/accept', 'verb' => 'POST'], |
|
35 | - ['root' => '/cloud', 'name' => 'RequestHandler#declineShare', 'url' => '/shares/{id}/decline', 'verb' => 'POST'], |
|
36 | - ['root' => '/cloud', 'name' => 'RequestHandler#unshare', 'url' => '/shares/{id}/unshare', 'verb' => 'POST'], |
|
37 | - ['root' => '/cloud', 'name' => 'RequestHandler#revoke', 'url' => '/shares/{id}/revoke', 'verb' => 'POST'], |
|
38 | - ['root' => '/cloud', 'name' => 'RequestHandler#move', 'url' => '/shares/{id}/move', 'verb' => 'POST'], |
|
39 | - ], |
|
26 | + 'routes' => [ |
|
27 | + ['name' => 'MountPublicLink#createFederatedShare', 'url' => '/createFederatedShare', 'verb' => 'POST'], |
|
28 | + ['name' => 'MountPublicLink#askForFederatedShare', 'url' => '/askForFederatedShare', 'verb' => 'POST'], |
|
29 | + ], |
|
30 | + 'ocs' => [ |
|
31 | + ['root' => '/cloud', 'name' => 'RequestHandler#createShare', 'url' => '/shares', 'verb' => 'POST'], |
|
32 | + ['root' => '/cloud', 'name' => 'RequestHandler#reShare', 'url' => '/shares/{id}/reshare', 'verb' => 'POST'], |
|
33 | + ['root' => '/cloud', 'name' => 'RequestHandler#updatePermissions', 'url' => '/shares/{id}/permissions', 'verb' => 'POST'], |
|
34 | + ['root' => '/cloud', 'name' => 'RequestHandler#acceptShare', 'url' => '/shares/{id}/accept', 'verb' => 'POST'], |
|
35 | + ['root' => '/cloud', 'name' => 'RequestHandler#declineShare', 'url' => '/shares/{id}/decline', 'verb' => 'POST'], |
|
36 | + ['root' => '/cloud', 'name' => 'RequestHandler#unshare', 'url' => '/shares/{id}/unshare', 'verb' => 'POST'], |
|
37 | + ['root' => '/cloud', 'name' => 'RequestHandler#revoke', 'url' => '/shares/{id}/revoke', 'verb' => 'POST'], |
|
38 | + ['root' => '/cloud', 'name' => 'RequestHandler#move', 'url' => '/shares/{id}/move', 'verb' => 'POST'], |
|
39 | + ], |
|
40 | 40 | ]; |
@@ -21,7 +21,7 @@ |
||
21 | 21 | */ |
22 | 22 | // no php execution timeout for webdav |
23 | 23 | if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
24 | - @set_time_limit(0); |
|
24 | + @set_time_limit(0); |
|
25 | 25 | } |
26 | 26 | ignore_user_abort(true); |
27 | 27 |
@@ -30,22 +30,22 @@ |
||
30 | 30 | |
31 | 31 | $manager = \OC::$server->getNotificationManager(); |
32 | 32 | $manager->registerNotifier(function() { |
33 | - return \OC::$server->query(Notifier::class); |
|
33 | + return \OC::$server->query(Notifier::class); |
|
34 | 34 | }, function() { |
35 | - $l = \OC::$server->getL10N('files_sharing'); |
|
36 | - return [ |
|
37 | - 'id' => 'files_sharing', |
|
38 | - 'name' => $l->t('Federated sharing'), |
|
39 | - ]; |
|
35 | + $l = \OC::$server->getL10N('files_sharing'); |
|
36 | + return [ |
|
37 | + 'id' => 'files_sharing', |
|
38 | + 'name' => $l->t('Federated sharing'), |
|
39 | + ]; |
|
40 | 40 | }); |
41 | 41 | |
42 | 42 | $federatedShareProvider = $app->getFederatedShareProvider(); |
43 | 43 | |
44 | 44 | $eventDispatcher->addListener( |
45 | - 'OCA\Files::loadAdditionalScripts', |
|
46 | - function() use ($federatedShareProvider) { |
|
47 | - if ($federatedShareProvider->isIncomingServer2serverShareEnabled()) { |
|
48 | - \OCP\Util::addScript('federatedfilesharing', 'external'); |
|
49 | - } |
|
50 | - } |
|
45 | + 'OCA\Files::loadAdditionalScripts', |
|
46 | + function() use ($federatedShareProvider) { |
|
47 | + if ($federatedShareProvider->isIncomingServer2serverShareEnabled()) { |
|
48 | + \OCP\Util::addScript('federatedfilesharing', 'external'); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | ); |
@@ -23,50 +23,50 @@ |
||
23 | 23 | $application = new \OCA\Federation\AppInfo\Application(); |
24 | 24 | |
25 | 25 | $application->registerRoutes( |
26 | - $this, |
|
27 | - [ |
|
28 | - 'routes' => [ |
|
29 | - [ |
|
30 | - 'name' => 'Settings#addServer', |
|
31 | - 'url' => '/trusted-servers', |
|
32 | - 'verb' => 'POST' |
|
33 | - ], |
|
34 | - [ |
|
35 | - 'name' => 'Settings#removeServer', |
|
36 | - 'url' => '/trusted-servers/{id}', |
|
37 | - 'verb' => 'DELETE' |
|
38 | - ], |
|
39 | - [ |
|
40 | - 'name' => 'Settings#autoAddServers', |
|
41 | - 'url' => '/auto-add-servers', |
|
42 | - 'verb' => 'POST' |
|
43 | - ], |
|
44 | - ], |
|
45 | - 'ocs' => [ |
|
46 | - // old endpoints, only used by Nextcloud and ownCloud |
|
47 | - [ |
|
48 | - 'name' => 'OCSAuthAPI#getSharedSecretLegacy', |
|
49 | - 'url' => '/api/v1/shared-secret', |
|
50 | - 'verb' => 'GET', |
|
51 | - ], |
|
52 | - [ |
|
53 | - 'name' => 'OCSAuthAPI#requestSharedSecretLegacy', |
|
54 | - 'url' => '/api/v1/request-shared-secret', |
|
55 | - 'verb' => 'POST', |
|
56 | - ], |
|
57 | - // new endpoints, published as public api |
|
58 | - [ |
|
59 | - 'name' => 'OCSAuthAPI#getSharedSecret', |
|
60 | - 'root' => '/cloud', |
|
61 | - 'url' => '/shared-secret', |
|
62 | - 'verb' => 'GET', |
|
63 | - ], |
|
64 | - [ |
|
65 | - 'name' => 'OCSAuthAPI#requestSharedSecret', |
|
66 | - 'root' => '/cloud', |
|
67 | - 'url' => '/shared-secret', |
|
68 | - 'verb' => 'POST', |
|
69 | - ], |
|
70 | - ], |
|
71 | - ] |
|
26 | + $this, |
|
27 | + [ |
|
28 | + 'routes' => [ |
|
29 | + [ |
|
30 | + 'name' => 'Settings#addServer', |
|
31 | + 'url' => '/trusted-servers', |
|
32 | + 'verb' => 'POST' |
|
33 | + ], |
|
34 | + [ |
|
35 | + 'name' => 'Settings#removeServer', |
|
36 | + 'url' => '/trusted-servers/{id}', |
|
37 | + 'verb' => 'DELETE' |
|
38 | + ], |
|
39 | + [ |
|
40 | + 'name' => 'Settings#autoAddServers', |
|
41 | + 'url' => '/auto-add-servers', |
|
42 | + 'verb' => 'POST' |
|
43 | + ], |
|
44 | + ], |
|
45 | + 'ocs' => [ |
|
46 | + // old endpoints, only used by Nextcloud and ownCloud |
|
47 | + [ |
|
48 | + 'name' => 'OCSAuthAPI#getSharedSecretLegacy', |
|
49 | + 'url' => '/api/v1/shared-secret', |
|
50 | + 'verb' => 'GET', |
|
51 | + ], |
|
52 | + [ |
|
53 | + 'name' => 'OCSAuthAPI#requestSharedSecretLegacy', |
|
54 | + 'url' => '/api/v1/request-shared-secret', |
|
55 | + 'verb' => 'POST', |
|
56 | + ], |
|
57 | + // new endpoints, published as public api |
|
58 | + [ |
|
59 | + 'name' => 'OCSAuthAPI#getSharedSecret', |
|
60 | + 'root' => '/cloud', |
|
61 | + 'url' => '/shared-secret', |
|
62 | + 'verb' => 'GET', |
|
63 | + ], |
|
64 | + [ |
|
65 | + 'name' => 'OCSAuthAPI#requestSharedSecret', |
|
66 | + 'root' => '/cloud', |
|
67 | + 'url' => '/shared-secret', |
|
68 | + 'verb' => 'POST', |
|
69 | + ], |
|
70 | + ], |
|
71 | + ] |
|
72 | 72 | ); |
@@ -30,64 +30,64 @@ |
||
30 | 30 | |
31 | 31 | class SyncFederationAddressBooks { |
32 | 32 | |
33 | - /** @var DbHandler */ |
|
34 | - protected $dbHandler; |
|
33 | + /** @var DbHandler */ |
|
34 | + protected $dbHandler; |
|
35 | 35 | |
36 | - /** @var SyncService */ |
|
37 | - private $syncService; |
|
36 | + /** @var SyncService */ |
|
37 | + private $syncService; |
|
38 | 38 | |
39 | - /** @var DiscoveryService */ |
|
40 | - private $ocsDiscoveryService; |
|
39 | + /** @var DiscoveryService */ |
|
40 | + private $ocsDiscoveryService; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param DbHandler $dbHandler |
|
44 | - * @param SyncService $syncService |
|
45 | - * @param IDiscoveryService $ocsDiscoveryService |
|
46 | - */ |
|
47 | - public function __construct(DbHandler $dbHandler, |
|
48 | - SyncService $syncService, |
|
49 | - IDiscoveryService $ocsDiscoveryService |
|
50 | - ) { |
|
51 | - $this->syncService = $syncService; |
|
52 | - $this->dbHandler = $dbHandler; |
|
53 | - $this->ocsDiscoveryService = $ocsDiscoveryService; |
|
54 | - } |
|
42 | + /** |
|
43 | + * @param DbHandler $dbHandler |
|
44 | + * @param SyncService $syncService |
|
45 | + * @param IDiscoveryService $ocsDiscoveryService |
|
46 | + */ |
|
47 | + public function __construct(DbHandler $dbHandler, |
|
48 | + SyncService $syncService, |
|
49 | + IDiscoveryService $ocsDiscoveryService |
|
50 | + ) { |
|
51 | + $this->syncService = $syncService; |
|
52 | + $this->dbHandler = $dbHandler; |
|
53 | + $this->ocsDiscoveryService = $ocsDiscoveryService; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param \Closure $callback |
|
58 | - */ |
|
59 | - public function syncThemAll(\Closure $callback) { |
|
56 | + /** |
|
57 | + * @param \Closure $callback |
|
58 | + */ |
|
59 | + public function syncThemAll(\Closure $callback) { |
|
60 | 60 | |
61 | - $trustedServers = $this->dbHandler->getAllServer(); |
|
62 | - foreach ($trustedServers as $trustedServer) { |
|
63 | - $url = $trustedServer['url']; |
|
64 | - $callback($url, null); |
|
65 | - $sharedSecret = $trustedServer['shared_secret']; |
|
66 | - $syncToken = $trustedServer['sync_token']; |
|
61 | + $trustedServers = $this->dbHandler->getAllServer(); |
|
62 | + foreach ($trustedServers as $trustedServer) { |
|
63 | + $url = $trustedServer['url']; |
|
64 | + $callback($url, null); |
|
65 | + $sharedSecret = $trustedServer['shared_secret']; |
|
66 | + $syncToken = $trustedServer['sync_token']; |
|
67 | 67 | |
68 | - $endPoints = $this->ocsDiscoveryService->discover($url, 'FEDERATED_SHARING'); |
|
69 | - $cardDavUser = isset($endPoints['carddav-user']) ? $endPoints['carddav-user'] : 'system'; |
|
70 | - $addressBookUrl = isset($endPoints['system-address-book']) ? trim($endPoints['system-address-book'], '/') : 'remote.php/dav/addressbooks/system/system/system'; |
|
68 | + $endPoints = $this->ocsDiscoveryService->discover($url, 'FEDERATED_SHARING'); |
|
69 | + $cardDavUser = isset($endPoints['carddav-user']) ? $endPoints['carddav-user'] : 'system'; |
|
70 | + $addressBookUrl = isset($endPoints['system-address-book']) ? trim($endPoints['system-address-book'], '/') : 'remote.php/dav/addressbooks/system/system/system'; |
|
71 | 71 | |
72 | - if (is_null($sharedSecret)) { |
|
73 | - continue; |
|
74 | - } |
|
75 | - $targetBookId = $trustedServer['url_hash']; |
|
76 | - $targetPrincipal = "principals/system/system"; |
|
77 | - $targetBookProperties = [ |
|
78 | - '{DAV:}displayname' => $url |
|
79 | - ]; |
|
80 | - try { |
|
81 | - $newToken = $this->syncService->syncRemoteAddressBook($url, $cardDavUser, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetBookProperties); |
|
82 | - if ($newToken !== $syncToken) { |
|
83 | - $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK, $newToken); |
|
84 | - } |
|
85 | - } catch (\Exception $ex) { |
|
86 | - if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) { |
|
87 | - $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_ACCESS_REVOKED); |
|
88 | - } |
|
89 | - $callback($url, $ex); |
|
90 | - } |
|
91 | - } |
|
92 | - } |
|
72 | + if (is_null($sharedSecret)) { |
|
73 | + continue; |
|
74 | + } |
|
75 | + $targetBookId = $trustedServer['url_hash']; |
|
76 | + $targetPrincipal = "principals/system/system"; |
|
77 | + $targetBookProperties = [ |
|
78 | + '{DAV:}displayname' => $url |
|
79 | + ]; |
|
80 | + try { |
|
81 | + $newToken = $this->syncService->syncRemoteAddressBook($url, $cardDavUser, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetBookProperties); |
|
82 | + if ($newToken !== $syncToken) { |
|
83 | + $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK, $newToken); |
|
84 | + } |
|
85 | + } catch (\Exception $ex) { |
|
86 | + if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) { |
|
87 | + $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_ACCESS_REVOKED); |
|
88 | + } |
|
89 | + $callback($url, $ex); |
|
90 | + } |
|
91 | + } |
|
92 | + } |
|
93 | 93 | } |