ENGINE-463: reconcile pEp status ENGINE-463
authorKrista Bennett <krista@pep-project.org>
Tue, 02 Oct 2018 15:47:10 +0200
branchENGINE-463
changeset 29707c0ad677fbca
parent 2969 b927bb5f437c
child 2971 124bcf396623
ENGINE-463: reconcile pEp status
src/pEpEngine.c
     1.1 --- a/src/pEpEngine.c	Tue Oct 02 15:37:59 2018 +0200
     1.2 +++ b/src/pEpEngine.c	Tue Oct 02 15:47:10 2018 +0200
     1.3 @@ -2970,10 +2970,36 @@
     1.4      return result;
     1.5  }
     1.6  
     1.7 +PEP_STATUS reconcile_pEp_status(PEP_SESSION session, const char* old_uid, 
     1.8 +                                const char* new_uid) {
     1.9 +    PEP_STATUS status = PEP_STATUS_OK;
    1.10 +    // We'll make this easy - if the old one has a pEp status, we set no matter
    1.11 +    // what.
    1.12 +    pEp_identity* ident = new_identity(NULL, NULL, old_uid, NULL);
    1.13 +    bool is_pEp_peep = false;
    1.14 +    status = is_pep_user(session, ident, &is_pEp_peep);
    1.15 +    if (is_pEp_peep) {
    1.16 +        free(ident->user_id);
    1.17 +        ident->user_id = strdup(new_uid);
    1.18 +        if (!ident->user_id) {
    1.19 +            status = PEP_OUT_OF_MEMORY;
    1.20 +            goto pEp_free;
    1.21 +        }
    1.22 +        status = set_as_pep_user(session, ident);
    1.23 +    }
    1.24 +pEp_free:
    1.25 +    free_identity(ident);
    1.26 +    return status;
    1.27 +}
    1.28 +
    1.29  PEP_STATUS merge_records(PEP_SESSION session, const char* old_uid,
    1.30                           const char* new_uid) {
    1.31      PEP_STATUS status = PEP_STATUS_OK;
    1.32      
    1.33 +    status = reconcile_pEp_status(session, old_uid, new_uid);
    1.34 +    if (status != PEP_STATUS_OK)
    1.35 +        goto pEp_free;
    1.36 +        
    1.37  pEp_free:
    1.38      return status;
    1.39  }