text stringlengths 0 357 |
|---|
chat_id_blocked = sqlite3_column_int(stmt, 1); |
goto cleanup; /* success, chat found */ |
} |
} |
if (!allow_creation) { |
goto cleanup; |
} |
/* we do not check if the message is a reply to another group, this may result in |
chats with unclear member list. instead we create a new group in the following lines ... */ |
/* create a new ad-hoc group |
- there is no need to check if this group exists; otherwise we would have catched it above */ |
if ((grpid = create_adhoc_grp_id(context, member_ids))==NULL) { |
goto cleanup; |
} |
/* use subject as initial chat name */ |
if (mime_parser->subject && mime_parser->subject[0]) { |
grpname = dc_strdup(mime_parser->subject); |
} |
else { |
grpname = dc_stock_str_repl_int(context, DC_STR_MEMBER, dc_array_get_cnt(member_ids)); |
} |
/* create group record */ |
chat_id = create_group_record(context, grpid, grpname, create_blocked, 0); |
chat_id_blocked = create_blocked; |
for (i = 0; i < dc_array_get_cnt(member_ids); i++) { |
dc_add_to_chat_contacts_table(context, chat_id, dc_array_get_id(member_ids, i)); |
} |
context->cb(context, DC_EVENT_CHAT_MODIFIED, chat_id, 0); |
cleanup: |
dc_array_unref(member_ids); |
dc_array_unref(chat_ids); |
free(chat_ids_str); |
free(grpid); |
free(grpname); |
sqlite3_finalize(stmt); |
sqlite3_free(q3); |
if (ret_chat_id) { *ret_chat_id = chat_id; } |
if (ret_chat_id_blocked) { *ret_chat_id_blocked = chat_id_blocked; } |
} |
static int check_verified_properties(dc_context_t* context, dc_mimeparser_t* mimeparser, |
uint32_t from_id, const dc_array_t* to_ids, |
char** failure_reason) |
{ |
int everythings_okay = 0; |
dc_contact_t* contact = dc_contact_new(context); |
dc_apeerstate_t* peerstate = dc_apeerstate_new(context); |
char* to_ids_str = NULL; |
char* q3 = NULL; |
sqlite3_stmt* stmt = NULL; |
#define VERIFY_FAIL(a) \ |
*failure_reason = dc_mprintf("%s. See \"Info\" for details.", (a)); \ |
dc_log_warning(context, 0, *failure_reason); |
if (!dc_contact_load_from_db(contact, context->sql, from_id)) { |
VERIFY_FAIL("Internal Error; cannot load contact.") |
goto cleanup; |
} |
// ensure, the message is encrypted |
if (!mimeparser->e2ee_helper->encrypted) { |
VERIFY_FAIL("This message is not encrypted.") |
goto cleanup; |
} |
// ensure, the contact is verified |
// and the message is signed with a verified key of the sender. |
// this check is skipped for SELF as there is no proper SELF-peerstate |
// and results in group-splits otherwise. |
if (from_id!=DC_CONTACT_ID_SELF) |
{ |
if (!dc_apeerstate_load_by_addr(peerstate, context->sql, contact->addr) |
|| dc_contact_is_verified_ex(contact, peerstate) != DC_BIDIRECT_VERIFIED) { |
VERIFY_FAIL("The sender of this message is not verified.") |
goto cleanup; |
} |
if (!dc_apeerstate_has_verified_key(peerstate, mimeparser->e2ee_helper->signatures)) { |
VERIFY_FAIL("The message was sent with non-verified encryption.") |
goto cleanup; |
} |
} |
// check that all members are verified. |
// if a verification is missing, check if this was just gossiped - as we've verified the sender, we verify the member then. |
to_ids_str = dc_array_get_string(to_ids, ","); |
q3 = sqlite3_mprintf("SELECT c.addr, LENGTH(ps.verified_key_fingerprint) " |
" FROM contacts c " |
" LEFT JOIN acpeerstates ps ON c.addr=ps.addr " |
" WHERE c.id IN(%s) ", |
to_ids_str); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.