text stringlengths 0 357 |
|---|
stmt = dc_sqlite3_prepare(context->sql, q3); |
while (sqlite3_step(stmt)==SQLITE_ROW) |
{ |
const char* to_addr = (const char*)sqlite3_column_text(stmt, 0); |
int is_verified = sqlite3_column_int (stmt, 1); |
if (dc_hash_find_str(mimeparser->e2ee_helper->gossipped_addr, to_addr) |
&& dc_apeerstate_load_by_addr(peerstate, context->sql, to_addr)) |
{ |
// if we're here, we know the gossip key is verified: |
// - use the gossip-key as verified-key if there is no verified-key |
// - OR if the verified-key does not match public-key or gossip-key |
// (otherwise a verified key can _only_ be updated through QR scan which might be annoying, |
// see https://github.com/nextleap-project/countermitm/issues/46 for a discussion about this point) |
if (!is_verified |
|| (strcmp(peerstate->verified_key_fingerprint, peerstate->public_key_fingerprint)!=0 |
&& strcmp(peerstate->verified_key_fingerprint, peerstate->gossip_key_fingerprint)!=0)) |
{ |
dc_log_info(context, 0, "%s has verfied %s.", contact->addr, to_addr); |
dc_apeerstate_set_verified(peerstate, DC_PS_GOSSIP_KEY, peerstate->gossip_key_fingerprint, DC_BIDIRECT_VERIFIED); |
dc_apeerstate_save_to_db(peerstate, context->sql, 0); |
is_verified = 1; |
} |
} |
if (!is_verified) |
{ |
char* err = dc_mprintf("%s is not a member of this verified group.", to_addr); |
VERIFY_FAIL(err) |
free(err); |
goto cleanup; |
} |
} |
// it's up to the caller to check if the sender is a member of the group |
// (we do this for both, verified and unverified group, so we do not check this here) |
everythings_okay = 1; |
cleanup: |
sqlite3_finalize(stmt); |
dc_contact_unref(contact); |
dc_apeerstate_unref(peerstate); |
free(to_ids_str); |
sqlite3_free(q3); |
return everythings_okay; |
} |
static void set_better_msg(dc_mimeparser_t* mime_parser, |
char** better_msg) |
{ |
if (*better_msg |
&& carray_count(mime_parser->parts)>0) { |
dc_mimepart_t* part = (dc_mimepart_t*)carray_get(mime_parser->parts, 0); |
if (part->type==DC_MSG_TEXT) { |
free(part->msg); |
part->msg = *better_msg; |
*better_msg = NULL; |
} |
} |
} |
/* the function tries extracts the group-id from the message and returns the |
corresponding chat_id. If the chat_id is not existant, it is created. |
If the message contains groups commands (name, profile image, changed members), |
they are executed as well. |
if no group-id could be extracted from the message, create_or_lookup_adhoc_group() is called |
which tries to create or find out the chat_id by: |
- is there a group with the same recipients? if so, use this (if there are multiple, use the most recent one) |
- create an ad-hoc group based on the recipient list |
So when the function returns, the caller has the group id matching the current |
state of the group. */ |
static void create_or_lookup_group(dc_context_t* context, dc_mimeparser_t* mime_parser, |
int allow_creation, int create_blocked, |
int32_t from_id, const dc_array_t* to_ids, |
uint32_t* ret_chat_id, int* ret_chat_id_blocked) |
{ |
uint32_t chat_id = 0; |
int chat_id_blocked = 0; |
int chat_id_verified = 0; |
char* grpid = NULL; |
char* grpname = NULL; |
sqlite3_stmt* stmt; |
int i = 0; |
int to_ids_cnt = dc_array_get_cnt(to_ids); |
char* self_addr = NULL; |
int recreate_member_list = 0; |
int send_EVENT_CHAT_MODIFIED = 0; |
char* X_MrRemoveFromGrp = NULL; /* pointer somewhere into mime_parser, must not be freed */ |
char* X_MrAddToGrp = NULL; /* pointer somewhere into mime_parser, must not be freed */ |
int X_MrGrpNameChanged = 0; |
const char* X_MrGrpImageChanged = NULL; |
char* better_msg = NULL; |
char* failure_reason = NULL; |
/* some preparations not really related to groups */ |
if (mime_parser->is_system_message==DC_CMD_LOCATION_STREAMING_ENABLED) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.