@@ -324,7 +324,7 @@ void get_ba_member_email(uint64_t userid, char** email /*OUT*/, size_t *length /
324
324
{
325
325
binresult * bres ;
326
326
const binresult * users ;
327
- char * fname , * lname ;
327
+ const char * fname , * lname ;
328
328
329
329
binparam params [] = { P_STR ("auth" , psync_my_auth ), P_STR ("timeformat" , "timestamp" ), P_NUM ("userids" , userid ) };
330
330
bres = psync_api_run_command ("account_users" , params );
@@ -370,7 +370,6 @@ void get_ba_team_name(uint64_t teamid, char** name /*OUT*/, size_t *length /*OUT
370
370
const char * cstr ;
371
371
372
372
binresult * bres ;
373
- int i ;
374
373
const binresult * teams ;
375
374
376
375
res = psync_sql_query ("SELECT name FROM baccountteam WHERE id=?" );
@@ -459,30 +458,30 @@ void cache_account_emails() {
459
458
for (i = 0 ; i < users -> length ; ++ i ) {
460
459
const char * nameret = 0 ;
461
460
const binresult * user = users -> array [i ];
462
- uint64_t userid = 0 ;
461
+ uint64_t userid = 0 ;
463
462
psync_sql_res * res ;
464
- char * fname , * lname ;
465
- int active = 0 ;
466
- int frozen = 0 ;
467
-
468
- active = psync_find_result (user , "active" , PARAM_BOOL )-> num ;
469
- frozen = psync_find_result (user , "frozen" , PARAM_BOOL )-> num ;
470
- nameret = psync_find_result (user , "email" , PARAM_STR )-> str ;
471
- userid = psync_find_result (user , "id" , PARAM_NUM )-> num ;
472
- fname = psync_find_result (user , "firstname" , PARAM_STR )-> str ;
473
- lname = psync_find_result (user , "lastname" , PARAM_STR )-> str ;
474
-
475
- if (userid && (active || frozen )) {
476
- res = psync_sql_prep_statement ("INSERT INTO baccountemail (id, mail, firstname, lastname) VALUES (?, ?, ?, ?)" );
477
- psync_sql_bind_uint (res , 1 , userid );
478
- psync_sql_bind_lstring (res , 2 , nameret , strlen (nameret ));
479
- psync_sql_bind_lstring (res , 3 , fname , strlen (fname ));
480
- psync_sql_bind_lstring (res , 4 , lname , strlen (lname ));
481
- if (unlikely (psync_sql_run_free (res ))) {
482
- psync_sql_rollback_transaction ();
483
- goto end_close ;
484
- }
485
- }
463
+ const char * fname , * lname ;
464
+ int active = 0 ;
465
+ int frozen = 0 ;
466
+
467
+ active = psync_find_result (user , "active" , PARAM_BOOL )-> num ;
468
+ frozen = psync_find_result (user , "frozen" , PARAM_BOOL )-> num ;
469
+ nameret = psync_find_result (user , "email" , PARAM_STR )-> str ;
470
+ userid = psync_find_result (user , "id" , PARAM_NUM )-> num ;
471
+ fname = psync_find_result (user , "firstname" , PARAM_STR )-> str ;
472
+ lname = psync_find_result (user , "lastname" , PARAM_STR )-> str ;
473
+
474
+ if (userid && (active || frozen )) {
475
+ res = psync_sql_prep_statement ("INSERT INTO baccountemail (id, mail, firstname, lastname) VALUES (?, ?, ?, ?)" );
476
+ psync_sql_bind_uint (res , 1 , userid );
477
+ psync_sql_bind_lstring (res , 2 , nameret , strlen (nameret ));
478
+ psync_sql_bind_lstring (res , 3 , fname , strlen (fname ));
479
+ psync_sql_bind_lstring (res , 4 , lname , strlen (lname ));
480
+ if (unlikely (psync_sql_run_free (res ))) {
481
+ psync_sql_rollback_transaction ();
482
+ goto end_close ;
483
+ }
484
+ }
486
485
}
487
486
psync_sql_commit_transaction ();
488
487
}
@@ -491,7 +490,6 @@ void cache_account_emails() {
491
490
}
492
491
493
492
void cache_account_teams () {
494
- //do_psync_account_teams(teamids, 0, &insert_cache_team, params);
495
493
binresult * bres ;
496
494
int i ;
497
495
const binresult * users ;
@@ -533,19 +531,16 @@ void cache_account_teams() {
533
531
nameret = psync_find_result (users -> array [i ], "name" , PARAM_STR )-> str ;
534
532
uint64_t teamid = 0 ;
535
533
psync_sql_res * res ;
536
-
534
+
537
535
teamid = psync_find_result (users -> array [i ], "id" , PARAM_NUM )-> num ;
538
-
539
536
//debug(D_NOTICE, "Team name %s team id %lld\n", nameret,(long long)teamid);
540
-
541
537
res = psync_sql_prep_statement ("INSERT INTO baccountteam (id, name) VALUES (?, ?)" );
542
538
psync_sql_bind_uint (res , 1 , teamid );
543
539
psync_sql_bind_lstring (res , 2 , nameret , strlen (nameret ));
544
- if (unlikely (psync_sql_run_free (res )))
545
- psync_sql_rollback_transaction ();
540
+ if (unlikely (psync_sql_run_free (res )))
541
+ psync_sql_rollback_transaction ();
546
542
}
547
- psync_sql_commit_transaction ();
548
- //vis(i, users->array[i], param);
543
+ psync_sql_commit_transaction ();
549
544
}
550
545
psync_free (bres );
551
546
return ;
@@ -562,9 +557,7 @@ static void cache_my_team(const binresult *team1) {
562
557
563
558
nameret = psync_find_result (team , "name" , PARAM_STR )-> str ;
564
559
teamid = psync_find_result (team , "id" , PARAM_NUM )-> num ;
565
-
566
560
//debug(D_NOTICE, "My Team name %s team id %lld\n", nameret,(long long)teamid);
567
-
568
561
q = psync_sql_prep_statement ("INSERT INTO myteams (id, name) VALUES (?, ?)" );
569
562
psync_sql_bind_uint (q , 1 , teamid );
570
563
psync_sql_bind_lstring (q , 2 , nameret , strlen (nameret ));
@@ -580,9 +573,7 @@ void cache_ba_my_teams() {
580
573
int i ;
581
574
582
575
binparam params [] = { P_STR ("auth" , psync_my_auth ), P_STR ("timeformat" , "timestamp" ), P_STR ("userids" , "me" ), P_STR ("showteams" , "1" ), P_STR ("showeveryone" , "1" ) };
583
-
584
576
bres = psync_api_run_command ("account_users" , params );
585
-
586
577
if (!bres ) {
587
578
debug (D_WARNING , "Send command returned invalid result.\n" );
588
579
return ;
@@ -600,16 +591,12 @@ void cache_ba_my_teams() {
600
591
}
601
592
602
593
psync_sql_lock ();
603
-
604
594
q = psync_sql_prep_statement ("DELETE FROM myteams" );
605
595
psync_sql_run_free (q );
606
-
607
-
608
596
user = users -> array [0 ];
609
597
teams = psync_find_result (user , "teams" , PARAM_ARRAY );
610
598
for (i = 0 ; i < teams -> length ; i ++ )
611
599
cache_my_team (teams -> array [i ]);
612
-
613
600
psync_free (bres );
614
601
psync_sql_unlock ();
615
602
}
0 commit comments