Use person.main_key_id
authorEdouard Tisserant
Tue, 17 May 2016 17:19:19 +0200
changeset 641ae3b959b3a7d
parent 639 0a2411d3d55a
child 642 dd10f7d3f20d
Use person.main_key_id
src/pEpEngine.c
     1.1 --- a/src/pEpEngine.c	Tue May 17 09:07:50 2016 +0200
     1.2 +++ b/src/pEpEngine.c	Tue May 17 17:19:19 2016 +0200
     1.3 @@ -217,8 +217,12 @@
     1.4          sql_trustword = "select id, word from wordlist where lang = lower(?1) "
     1.5                         "and id = ?2 ;";
     1.6  
     1.7 -        sql_set_person = "insert or replace into person (id, username, lang) "
     1.8 -                         "values (?1, ?2, ?3) ;";
     1.9 +        // Set person, but if already exist, only update.
    1.10 +        // if main_key_id already set, don't touch.
    1.11 +        sql_set_person = "insert or replace into person (id, username, lang, main_key_id)"
    1.12 +                         "  values (?1, ?2, ?3,"
    1.13 +                         "    (select coalesce((select main_key_id from person "
    1.14 +                         "      where id = ?1), ?4 ))) ;";
    1.15  
    1.16          sql_set_pgp_keypair = "insert or replace into pgp_keypair (fpr) "
    1.17                                "values (upper(replace(?1,' ',''))) ;";
    1.18 @@ -822,6 +826,8 @@
    1.19                  SQLITE_STATIC);
    1.20      else
    1.21          sqlite3_bind_null(session->set_person, 3);
    1.22 +    sqlite3_bind_text(session->set_person, 4, identity->fpr, -1,
    1.23 +                      SQLITE_STATIC);
    1.24      result = sqlite3_step(session->set_person);
    1.25      sqlite3_reset(session->set_person);
    1.26      if (result != SQLITE_DONE) {