src/message_api.c
changeset 2466 339399330a9b
parent 2462 48b526a0daac
child 2467 ef6bb2e8a84c
child 2469 419243d81d6f
     1.1 --- a/src/message_api.c	Mon Jan 29 12:40:43 2018 +0100
     1.2 +++ b/src/message_api.c	Mon Jan 29 16:52:54 2018 +0100
     1.3 @@ -2796,6 +2796,9 @@
     1.4      return ADD_TO_LOG(status);
     1.5  }
     1.6  
     1.7 +// Note: if comm_type_determine is false, it generally means that
     1.8 +// we were unable to get key information for anyone in the list,
     1.9 +// likely because a key is missing.
    1.10  static void _max_comm_type_from_identity_list(
    1.11          identity_list *identities,
    1.12          PEP_SESSION session,
    1.13 @@ -2813,8 +2816,17 @@
    1.14                  status = update_identity(session, il->ident);
    1.15              else
    1.16                  status = myself(session, il->ident);
    1.17 -            if (status == PEP_STATUS_OK)
    1.18 -            {
    1.19 +                
    1.20 +            // check for the return statuses which might not a representative
    1.21 +            // value in the comm_type
    1.22 +            if (status == PEP_ILLEGAL_VALUE || status == PEP_CANNOT_SET_PERSON ||
    1.23 +                status == PEP_CANNOT_FIND_IDENTITY) {
    1.24 +                // PEP_CANNOT_FIND_IDENTITY only comes back when we've really
    1.25 +                // got nothing from update_identity after applying the whole
    1.26 +                // heuristic
    1.27 +                *max_comm_type = PEP_ct_unknown;
    1.28 +            }
    1.29 +            else {
    1.30                  *max_comm_type = _get_comm_type(session, *max_comm_type,
    1.31                          il->ident);
    1.32                  *comm_type_determined = true;
    1.33 @@ -2854,8 +2866,11 @@
    1.34      _max_comm_type_from_identity_list(msg->bcc, session,
    1.35                                        &max_comm_type, &comm_type_determined);
    1.36  
    1.37 -    if (comm_type_determined == false)
    1.38 -        *rating = PEP_rating_undefined;
    1.39 +    if (comm_type_determined == false) {
    1.40 +        // likely means there was a massive screwup with no sender or recipient
    1.41 +        // keys, but regardless, this'll end up being unencrypted
    1.42 +        *rating = PEP_rating_unencrypted;
    1.43 +    }
    1.44      else
    1.45          *rating = _MAX(_rating(max_comm_type, PEP_rating_undefined),
    1.46                  PEP_rating_unencrypted);