Skip to content

Commit 1598c9d

Browse files
author
Ivan Stoev
committed
Old code removed
1 parent 4db94d1 commit 1598c9d

File tree

1 file changed

+28
-41
lines changed

1 file changed

+28
-41
lines changed

pbusinessaccount.c

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ void get_ba_member_email(uint64_t userid, char** email /*OUT*/, size_t *length /
324324
{
325325
binresult *bres;
326326
const binresult *users;
327-
char* fname, *lname;
327+
const char* fname, *lname;
328328

329329
binparam params[] = { P_STR("auth", psync_my_auth), P_STR("timeformat", "timestamp"), P_NUM("userids", userid) };
330330
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
370370
const char *cstr;
371371

372372
binresult *bres;
373-
int i;
374373
const binresult *teams;
375374

376375
res=psync_sql_query("SELECT name FROM baccountteam WHERE id=?");
@@ -459,30 +458,30 @@ void cache_account_emails() {
459458
for (i = 0; i < users->length; ++i) {
460459
const char *nameret = 0;
461460
const binresult *user = users->array[i];
462-
uint64_t userid = 0;
461+
uint64_t userid = 0;
463462
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+
}
486485
}
487486
psync_sql_commit_transaction();
488487
}
@@ -491,7 +490,6 @@ void cache_account_emails() {
491490
}
492491

493492
void cache_account_teams() {
494-
//do_psync_account_teams(teamids, 0, &insert_cache_team, params);
495493
binresult *bres;
496494
int i;
497495
const binresult *users;
@@ -533,19 +531,16 @@ void cache_account_teams() {
533531
nameret = psync_find_result(users->array[i], "name", PARAM_STR)->str;
534532
uint64_t teamid = 0;
535533
psync_sql_res *res;
536-
534+
537535
teamid = psync_find_result(users->array[i], "id", PARAM_NUM)->num;
538-
539536
//debug(D_NOTICE, "Team name %s team id %lld\n", nameret,(long long)teamid);
540-
541537
res=psync_sql_prep_statement("INSERT INTO baccountteam (id, name) VALUES (?, ?)");
542538
psync_sql_bind_uint(res, 1, teamid);
543539
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();
546542
}
547-
psync_sql_commit_transaction();
548-
//vis(i, users->array[i], param);
543+
psync_sql_commit_transaction();
549544
}
550545
psync_free(bres);
551546
return;
@@ -562,9 +557,7 @@ static void cache_my_team(const binresult *team1) {
562557

563558
nameret = psync_find_result(team, "name", PARAM_STR)->str;
564559
teamid = psync_find_result(team, "id", PARAM_NUM)->num;
565-
566560
//debug(D_NOTICE, "My Team name %s team id %lld\n", nameret,(long long)teamid);
567-
568561
q=psync_sql_prep_statement("INSERT INTO myteams (id, name) VALUES (?, ?)");
569562
psync_sql_bind_uint(q, 1, teamid);
570563
psync_sql_bind_lstring(q, 2, nameret, strlen(nameret));
@@ -580,9 +573,7 @@ void cache_ba_my_teams() {
580573
int i;
581574

582575
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-
584576
bres = psync_api_run_command("account_users", params);
585-
586577
if (!bres) {
587578
debug(D_WARNING, "Send command returned invalid result.\n");
588579
return;
@@ -600,16 +591,12 @@ void cache_ba_my_teams() {
600591
}
601592

602593
psync_sql_lock();
603-
604594
q=psync_sql_prep_statement("DELETE FROM myteams");
605595
psync_sql_run_free(q);
606-
607-
608596
user = users->array[0];
609597
teams = psync_find_result(user, "teams", PARAM_ARRAY);
610598
for (i = 0; i < teams->length; i++)
611599
cache_my_team(teams->array[i]);
612-
613600
psync_free(bres);
614601
psync_sql_unlock();
615602
}

0 commit comments

Comments
 (0)