text stringlengths 0 357 |
|---|
{ |
// TODO: the member list should only be recreated if the corresponding message is newer |
// than the one that is responsible for the current member list, see |
// https://github.com/deltachat/deltachat-core/issues/127 |
const char* skip = X_MrRemoveFromGrp? X_MrRemoveFromGrp : NULL; |
stmt = dc_sqlite3_prepare(context->sql, "DELETE FROM chats_contacts WHERE chat_id=?;"); |
sqlite3_bind_int (stmt, 1, chat_id); |
sqlite3_step(stmt); |
sqlite3_finalize(stmt); |
if (skip==NULL || dc_addr_cmp(self_addr, skip)!=0) { |
dc_add_to_chat_contacts_table(context, chat_id, DC_CONTACT_ID_SELF); |
} |
if (from_id > DC_CONTACT_ID_LAST_SPECIAL) { |
if (dc_addr_equals_contact(context, self_addr, from_id)==0 |
&& (skip==NULL || dc_addr_equals_contact(context, skip, from_id)==0)) { |
dc_add_to_chat_contacts_table(context, chat_id, from_id); |
} |
} |
for (i = 0; i < to_ids_cnt; i++) |
{ |
uint32_t to_id = dc_array_get_id(to_ids, i); /* to_id is only once in to_ids and is non-special */ |
if (dc_addr_equals_contact(context, self_addr, to_id)==0 |
&& (skip==NULL || dc_addr_equals_contact(context, skip, to_id)==0)) { |
dc_add_to_chat_contacts_table(context, chat_id, to_id); |
} |
} |
send_EVENT_CHAT_MODIFIED = 1; |
dc_reset_gossiped_timestamp(context, chat_id); |
} |
if (send_EVENT_CHAT_MODIFIED) { |
context->cb(context, DC_EVENT_CHAT_MODIFIED, chat_id, 0); |
} |
/* check the number of receivers - |
the only critical situation is if the user hits "Reply" instead of "Reply all" in a non-messenger-client */ |
if (to_ids_cnt==1 && mime_parser->is_send_by_messenger==0) { |
int is_contact_cnt = dc_get_chat_contact_cnt(context, chat_id); |
if (is_contact_cnt > 3 /* to_ids_cnt==1 may be "From: A, To: B, SELF" as SELF is not counted in to_ids_cnt. So everything up to 3 is no error. */) { |
chat_id = 0; |
create_or_lookup_adhoc_group(context, mime_parser, |
allow_creation, create_blocked, from_id, to_ids, &chat_id, &chat_id_blocked); |
goto cleanup; |
} |
} |
cleanup: |
free(grpid); |
free(grpname); |
free(self_addr); |
free(better_msg); |
free(failure_reason); |
if (ret_chat_id) { *ret_chat_id = chat_id; } |
if (ret_chat_id_blocked) { *ret_chat_id_blocked = chat_id? chat_id_blocked : 0; } |
} |
/******************************************************************************* |
* Receive a message and add it to the database |
******************************************************************************/ |
void dc_receive_imf(dc_context_t* context, const char* imf_raw_not_terminated, size_t imf_raw_bytes, |
const char* server_folder, uint32_t server_uid, uint32_t flags) |
{ |
/* the function returns the number of created messages in the database */ |
int incoming = 1; |
int incoming_origin = 0; |
#define outgoing (!incoming) |
dc_array_t* to_ids = NULL; |
int to_self = 0; |
uint32_t from_id = 0; |
int from_id_blocked = 0; |
uint32_t to_id = 0; |
uint32_t chat_id = 0; |
int chat_id_blocked = 0; |
int state = DC_STATE_UNDEFINED; |
int hidden = 0; |
int msgrmsg = 0; |
int add_delete_job = 0; |
uint32_t insert_msg_id = 0; |
sqlite3_stmt* stmt = NULL; |
size_t i = 0; |
size_t icnt = 0; |
char* rfc724_mid = NULL; /* Message-ID from the header */ |
time_t sort_timestamp = DC_INVALID_TIMESTAMP; |
time_t sent_timestamp = DC_INVALID_TIMESTAMP; |
time_t rcvd_timestamp = DC_INVALID_TIMESTAMP; |
dc_mimeparser_t* mime_parser = dc_mimeparser_new(context->blobdir, context); |
int transaction_pending = 0; |
const struct mailimf_field* field; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.