30
30
*/
31
31
namespace OCA \Calendar \Controller ;
32
32
33
+ use Exception ;
33
34
use OCA \Calendar \Service \ServiceException ;
35
+ use OCA \Circles \Api \v1 \Circles ;
34
36
use OCA \Circles \Exceptions \CircleNotFoundException ;
35
37
use OCP \App \IAppManager ;
36
38
use OCP \AppFramework \Controller ;
40
42
use OCP \Contacts \IManager ;
41
43
use OCP \IRequest ;
42
44
use OCP \IUserManager ;
45
+ use Psr \Log \LoggerInterface ;
43
46
44
47
/**
45
48
* Class ContactController
@@ -63,11 +66,14 @@ class ContactController extends Controller {
63
66
* @param IRequest $request
64
67
* @param IManager $contacts
65
68
*/
66
- public function __construct (string $ appName ,
69
+ public function __construct (
70
+ string $ appName ,
67
71
IRequest $ request ,
68
72
IManager $ contacts ,
69
73
IAppManager $ appManager ,
70
- IUserManager $ userManager ) {
74
+ IUserManager $ userManager ,
75
+ private LoggerInterface $ logger ,
76
+ ) {
71
77
parent ::__construct ($ appName , $ request );
72
78
$ this ->contactsManager = $ contacts ;
73
79
$ this ->appManager = $ appManager ;
@@ -196,32 +202,32 @@ public function searchAttendee(string $search):JSONResponse {
196
202
* @param string $circleId CircleId to query for members
197
203
* @return JSONResponse
198
204
* @throws Exception
199
- * @throws \OCP\AppFramework\QueryException
200
205
*
201
206
* @NoAdminRequired
202
207
*/
203
208
public function getCircleMembers (string $ circleId ):JSONResponse {
204
- if (!$ this ->appManager ->isEnabledForUser ('circles ' ) || !class_exists ('\OCA\Circles\Api\v1\Circles ' )) {
209
+ if (!class_exists ('\OCA\Circles\Api\v1\Circles ' ) || !$ this ->appManager ->isEnabledForUser ('circles ' )) {
210
+ $ this ->logger ->debug ('Circles not enabled ' );
205
211
return new JSONResponse ();
206
212
}
207
213
if (!$ this ->contactsManager ->isEnabled ()) {
214
+ $ this ->logger ->debug ('Contacts not enabled ' );
208
215
return new JSONResponse ();
209
216
}
210
217
211
218
try {
212
- $ circle = \ OCA \ Circles \ Api \ v1 \ Circles::detailsCircle ($ circleId , true );
219
+ $ circle = Circles::detailsCircle ($ circleId , true );
213
220
} catch (QueryException $ ex ) {
221
+ $ this ->logger ->error ('Could not resolve circle details ' , ['exception ' => $ ex ]);
214
222
return new JSONResponse ();
215
223
} catch (CircleNotFoundException $ ex ) {
216
- return new JSONResponse ();
217
- }
218
-
219
- if (!$ circle ) {
224
+ $ this ->logger ->error ('Could not find circle ' , ['exception ' => $ ex ]);
220
225
return new JSONResponse ();
221
226
}
222
227
223
228
$ circleMembers = $ circle ->getInheritedMembers ();
224
229
230
+ $ contacts = [];
225
231
foreach ($ circleMembers as $ circleMember ) {
226
232
if ($ circleMember ->isLocal ()) {
227
233
@@ -230,7 +236,8 @@ public function getCircleMembers(string $circleId):JSONResponse {
230
236
$ user = $ this ->userManager ->get ($ circleMemberUserId );
231
237
232
238
if ($ user === null ) {
233
- throw new ServiceException ('Could not find organizer ' );
239
+ $ this ->logger ->error ('Could not find user with user id ' . $ circleMemberUserId );
240
+ throw new ServiceException ('Could not find circle member ' );
234
241
}
235
242
236
243
$ contacts [] = [
0 commit comments