Shelving to check for changes. Next step here is to continue dealing with PEP_OWN_USERID as the only marker all over the DB ENGINE-289
authorKrista Bennett <krista@pep-project.org>
Wed, 22 Nov 2017 09:43:14 +0100
branchENGINE-289
changeset 22944ef0fb6bdf61
parent 2293 c634fbe5a8f3
child 2300 cfa7b4d7e59d
Shelving to check for changes. Next step here is to continue dealing with PEP_OWN_USERID as the only marker all over the DB
src/message_api.c
src/pEpEngine.c
     1.1 --- a/src/message_api.c	Tue Nov 21 18:15:19 2017 +0100
     1.2 +++ b/src/message_api.c	Wed Nov 22 09:43:14 2017 +0100
     1.3 @@ -2566,8 +2566,7 @@
     1.4      // 1. Check to see if this message is to us and contains an own key imported 
     1.5      // from own trusted message 
     1.6      if (msg && *rating >= PEP_rating_trusted && imported_private_key_address &&
     1.7 -        msg->to->ident->user_id &&
     1.8 -        strcmp(msg->to->ident->user_id, PEP_OWN_USERID) == 0) {
     1.9 +        msg->to && _identity_me(msg->to) {
    1.10  
    1.11          // flag it as such
    1.12          *flags |= PEP_decrypt_flag_own_private_key;
     2.1 --- a/src/pEpEngine.c	Tue Nov 21 18:15:19 2017 +0100
     2.2 +++ b/src/pEpEngine.c	Wed Nov 22 09:43:14 2017 +0100
     2.3 @@ -77,10 +77,12 @@
     2.4      "      where id = ?1), upper(replace(?4,' ','')))),"
     2.5      "    (select device_group from person where id = ?1)) ;";
     2.6  
     2.7 +// FIXME: PEP_OWN_USERID
     2.8  static const char *sql_set_device_group = 
     2.9      "update person set device_group = ?1 "
    2.10      "where id = '" PEP_OWN_USERID "';";
    2.11  
    2.12 +// FIXME: PEP_OWN_USERID
    2.13  static const char *sql_get_device_group = 
    2.14      "select device_group from person "
    2.15      "where id = '" PEP_OWN_USERID "';";
    2.16 @@ -172,6 +174,7 @@
    2.17                  
    2.18  
    2.19  // Own keys
    2.20 +// FIXME: PEP_OWN_USERID
    2.21  static const char *sql_own_key_is_listed = 
    2.22      "select count(*) from ("
    2.23      " select main_key_id from person "
    2.24 @@ -194,14 +197,16 @@
    2.25      "   join pgp_keypair on fpr = identity.main_key_id"
    2.26      "   join trust on id = trust.user_id"
    2.27      "       and pgp_keypair_fpr = identity.main_key_id"
    2.28 -    "   where identity.user_id = '" PEP_OWN_USERID "'"
    2.29 +    "   where identity.is_own = 1"
    2.30      "       and (identity.flags & ?1) = 0;";
    2.31 -        
    2.32 +
    2.33 +// FIXME: PEP_OWN_USERID        
    2.34  static const char *sql_own_keys_retrieve =  
    2.35      "select fpr from own_keys"
    2.36      "   natural join identity"
    2.37      "   where (identity.flags & ?1) = 0;";
    2.38  
    2.39 +// FIXME: PEP_OWN_USERID
    2.40  static const char *sql_set_own_key = 
    2.41      "insert or replace into own_keys (address, user_id, fpr)"
    2.42      " values (?1, '" PEP_OWN_USERID "', upper(replace(?2,' ','')));";
    2.43 @@ -456,7 +461,7 @@
    2.44                  "       on delete cascade,\n"
    2.45                  "   foreign key (address, user_id)\n"
    2.46                  "       references identity\n"
    2.47 -                "       on delete cascade,\n"
    2.48 +                "       on delete cascade\n"
    2.49  //                "   check (user_id = '" PEP_OWN_USERID "')\n"
    2.50                  "   primary key (address, fpr)\n"
    2.51                  ");\n" 
    2.52 @@ -1361,7 +1366,7 @@
    2.53      }
    2.54  
    2.55      if (has_fpr) {
    2.56 -        if(strcmp(identity->user_id, PEP_OWN_USERID) == 0) {
    2.57 +        if(_identity_me(identity)) {
    2.58              sqlite3_reset(session->set_own_key);
    2.59              sqlite3_bind_text(session->set_own_key, 1, identity->address, -1,
    2.60                  SQLITE_STATIC);