@@ -305,76 +305,13 @@ int do_psync_account_modifyshare(psync_shareid_t usrshrids[], uint32_t uperms[],
305
305
return result ;
306
306
}
307
307
308
- int do_psync_account_users (psync_userid_t userids [], int nids , result_visitor vis , void * param ) {
309
- psync_socket * sock ;
310
- binresult * bres ;
311
- char * ids = NULL ;
312
- char * idsp = 0 ;
313
- int k ,i ;
314
- const binresult * users ;
315
-
316
- if (nids ) {
317
-
318
- ids = (char * ) psync_malloc (nids * FOLDERID_ENTRY_SIZE );
319
- idsp = ids ;
320
- for (i = 0 ; i < nids ; ++ i ) {
321
- k = sprintf (idsp , "%lld" , (long long ) userids [i ]);
322
- if (unlikely (k <= 0 )) break ;
323
- idsp [k ] = ',' ;
324
- idsp = idsp + k + 1 ;
325
- }
326
- if (i > 0 )
327
- * (idsp - 1 ) = '\0' ;
328
-
329
- {
330
- binparam params [] = { P_STR ("auth" , psync_my_auth ), P_STR ("timeformat" , "timestamp" ), P_STR ("userids" , ids ) };
331
- sock = psync_apipool_get ();
332
- bres = send_command (sock , "account_users" , params );
333
- }
334
- } else {
335
- if (psync_my_auth [0 ]) {
336
- binparam params [] = {P_STR ("auth" , psync_my_auth ), P_STR ("timeformat" , "timestamp" )};
337
- sock = psync_apipool_get ();
338
- bres = send_command (sock , "account_users" , params );
339
- } else if (psync_my_user && psync_my_pass ) {
340
- binparam params [] = {P_STR ("username" , psync_my_user ), P_STR ("password" , psync_my_pass ), P_STR ("timeformat" , "timestamp" )};
341
- sock = psync_apipool_get ();
342
- bres = send_command (sock , "account_users" , params );
343
- } else return -1 ;
344
- }
345
- if (likely (bres ))
346
- psync_apipool_release (sock );
347
- else {
348
- psync_apipool_release_bad (sock );
349
- debug (D_WARNING , "Send command returned invalid result.\n" );
350
- return -1 ;
351
- }
352
-
353
-
354
- users = psync_find_result (bres , "users" , PARAM_ARRAY );
355
-
356
- if (!users -> length ){
357
- psync_free (bres );
358
- psync_free (ids );
359
- debug (D_WARNING , "Account_users returned empty result!\n" );
360
- return -2 ;
361
- } else {
362
- for (i = 0 ; i < users -> length ; ++ i )
363
- vis (i , users -> array [i ], param );
364
- }
365
-
366
- psync_free (bres );
367
- psync_free (ids );
368
- return 0 ;
369
- }
370
-
371
- static void copy_email (int i , const binresult * user , void * _this ) {
308
+ /*static void copy_email(int i, const binresult *user, void *_this) {
372
309
const char *emailret = "";
373
310
email_visitor_params *params = (email_visitor_params *) _this;
374
311
emailret = psync_find_result(user, "email", PARAM_STR)->str;
375
312
*(params->length) = strlen(emailret);
376
313
*(params->email) = psync_strndup(emailret, *(params->length));
377
- }
314
+ }*/
378
315
379
316
void get_ba_member_email (uint64_t userid , char * * email /*OUT*/ , size_t * length /*OUT*/ ) {
380
317
psync_sql_res * res ;
@@ -389,10 +326,38 @@ void get_ba_member_email(uint64_t userid, char** email /*OUT*/, size_t *length /
389
326
memcpy (* email , cstr , * length );
390
327
} else {
391
328
psync_sql_res * q ;
392
- psync_userid_t userids [] = {userid };
393
- email_visitor_params params = {email , length };
394
- do_psync_account_users (userids , 1 , & copy_email , & params );
329
+ // email_visitor_params vparams = {email, length};
330
+ // do_psync_account_users(userids, 1, ©_email, ¶ms);
331
+
332
+ psync_socket * sock ;
333
+ binresult * bres ;
334
+ const binresult * users ;
335
+ int i = 0 ;
336
+
337
+ binparam params [] = { P_STR ("auth" , psync_my_auth ), P_STR ("timeformat" , "timestamp" ), P_NUM ("userids" , userid ) };
338
+ sock = psync_apipool_get ();
339
+ bres = send_command (sock , "account_users" , params );
395
340
341
+ if (likely (bres ))
342
+ psync_apipool_release (sock );
343
+ else {
344
+ psync_apipool_release_bad (sock );
345
+ debug (D_WARNING , "Send command returned invalid result.\n" );
346
+ return ;
347
+ }
348
+
349
+ users = psync_find_result (bres , "users" , PARAM_ARRAY );
350
+ if (!users -> length ) {
351
+ psync_free (bres );
352
+ debug (D_WARNING , "Account_users returned empty result!\n" );
353
+ return ;
354
+ } else {
355
+ const char * emailret = psync_find_result (user , "email" , PARAM_STR )-> str ;
356
+ * length = strlen (emailret );
357
+ * email = psync_strndup (emailret , * length );
358
+ }
359
+ psync_free (bres );
360
+
396
361
if (* length ) {
397
362
q = psync_sql_prep_statement ("INSERT INTO baccountemail (id, mail) VALUES (?, ?)" );
398
363
psync_sql_bind_uint (q , 1 , userid );
@@ -532,11 +497,73 @@ void cache_account_emails() {
532
497
psync_sql_res * q ;
533
498
534
499
psync_sql_lock ();
535
- q = psync_sql_prep_statement ("DELETE FROM baccountemail" );
500
+ q = psync_sql_prep_statement ("DELETE FROM baccountemail " );
536
501
psync_sql_run_free (q );
502
+ psync_sql_unlock ();
537
503
538
504
do_psync_account_users (userids , 0 , & insert_cache_email , params );
539
- psync_sql_unlock ();
505
+ /*
506
+ psync_socket *sock;
507
+ binresult *bres;
508
+ char *ids = NULL;
509
+ char *idsp = 0;
510
+ int k,i;
511
+ const binresult *users;
512
+
513
+ if (nids) {
514
+
515
+ ids = (char *) psync_malloc(nids*FOLDERID_ENTRY_SIZE);
516
+ idsp = ids;
517
+ for (i = 0; i < nids; ++i) {
518
+ k = sprintf(idsp, "%lld", (long long) userids[i]);
519
+ if (unlikely(k <= 0 )) break;
520
+ idsp[k] = ',';
521
+ idsp = idsp + k + 1;
522
+ }
523
+ if (i > 0)
524
+ *(idsp - 1) = '\0';
525
+
526
+ {
527
+ binparam params[] = { P_STR("auth", psync_my_auth), P_STR("timeformat", "timestamp"), P_STR("userids", ids) };
528
+ sock = psync_apipool_get();
529
+ bres = send_command(sock, "account_users", params);
530
+ }
531
+ } else {
532
+ if (psync_my_auth[0]) {
533
+ binparam params[] = {P_STR("auth", psync_my_auth), P_STR("timeformat", "timestamp")};
534
+ sock = psync_apipool_get();
535
+ bres = send_command(sock, "account_users", params);
536
+ } else if (psync_my_user && psync_my_pass) {
537
+ binparam params[] = {P_STR("username", psync_my_user), P_STR("password", psync_my_pass), P_STR("timeformat", "timestamp")};
538
+ sock = psync_apipool_get();
539
+ bres = send_command(sock, "account_users", params);
540
+ } else return -1;
541
+ }
542
+ if (likely(bres))
543
+ psync_apipool_release(sock);
544
+ else {
545
+ psync_apipool_release_bad(sock);
546
+ debug(D_WARNING, "Send command returned invalid result.\n");
547
+ return -1;
548
+ }
549
+
550
+
551
+ users = psync_find_result(bres, "users", PARAM_ARRAY);
552
+
553
+ if (!users->length){
554
+ psync_free(bres);
555
+ psync_free(ids);
556
+ debug(D_WARNING, "Account_users returned empty result!\n");
557
+ return -2;
558
+ } else {
559
+ for (i = 0; i < users->length; ++i)
560
+ vis(i, users->array[i], param);
561
+ }
562
+
563
+ psync_free(bres);
564
+ psync_free(ids);
565
+ */
566
+
540
567
}
541
568
542
569
static void insert_cache_team (int i , const binresult * team , void * _this ) {
@@ -564,8 +591,10 @@ void cache_account_teams() {
564
591
psync_sql_lock ();
565
592
q = psync_sql_prep_statement ("DELETE FROM baccountteam " );
566
593
psync_sql_run_free (q );
567
- do_psync_account_teams (teamids , 0 , & insert_cache_team , params );
568
594
psync_sql_unlock ();
595
+
596
+ do_psync_account_teams (teamids , 0 , & insert_cache_team , params );
597
+
569
598
}
570
599
571
600
static void cache_my_team (const binresult * team1 ) {
0 commit comments