text stringlengths 0 357 |
|---|
if (chat_id && chat_id_blocked && !create_blocked) { |
dc_unblock_chat(context, chat_id); |
chat_id_blocked = 0; |
} |
} |
} |
if (chat_id==0) { |
if (dc_array_get_cnt(to_ids)==0 && to_self) { |
/* from_id==to_id==DC_CONTACT_ID_SELF - this is a self-sent messages, maybe an Autocrypt Setup Message */ |
dc_create_or_lookup_nchat_by_contact_id(context, DC_CONTACT_ID_SELF, DC_CHAT_NOT_BLOCKED, &chat_id, &chat_id_blocked); |
if (chat_id && chat_id_blocked) { |
dc_unblock_chat(context, chat_id); |
chat_id_blocked = 0; |
} |
} |
} |
if (chat_id==0) { |
chat_id = DC_CHAT_ID_TRASH; |
} |
} |
/* correct message_timestamp, it should not be used before, |
however, we cannot do this earlier as we need from_id to be set */ |
calc_timestamps(context, chat_id, from_id, sent_timestamp, (flags&DC_IMAP_SEEN)? 0 : 1 /*fresh message?*/, |
&sort_timestamp, &sent_timestamp, &rcvd_timestamp); |
/* unarchive chat */ |
dc_unarchive_chat(context, chat_id); |
// if the mime-headers should be saved, find out its size |
// (the mime-header ends with an empty line) |
int save_mime_headers = dc_sqlite3_get_config_int(context->sql, "save_mime_headers", 0); |
int header_bytes = imf_raw_bytes; |
if (save_mime_headers) { |
char* p; |
if ((p=strstr(imf_raw_not_terminated, "\r\n\r\n"))!=NULL) { |
header_bytes = (p-imf_raw_not_terminated)+4; |
} |
else if ((p=strstr(imf_raw_not_terminated, "\n\n"))!=NULL) { |
header_bytes = (p-imf_raw_not_terminated)+2; |
} |
} |
if ((field=dc_mimeparser_lookup_field(mime_parser, "In-Reply-To"))!=NULL |
&& field->fld_type==MAILIMF_FIELD_IN_REPLY_TO) |
{ |
struct mailimf_in_reply_to* fld_in_reply_to = field->fld_data.fld_in_reply_to; |
if (fld_in_reply_to) { |
mime_in_reply_to = dc_str_from_clist(field->fld_data.fld_in_reply_to->mid_list, " "); |
} |
} |
if ((field=dc_mimeparser_lookup_field(mime_parser, "References"))!=NULL |
&& field->fld_type==MAILIMF_FIELD_REFERENCES) |
{ |
struct mailimf_references* fld_references = field->fld_data.fld_references; |
if (fld_references) { |
mime_references = dc_str_from_clist(field->fld_data.fld_references->mid_list, " "); |
} |
} |
/* fine, so far. now, split the message into simple parts usable as "short messages" |
and add them to the database (mails sent by other messenger clients should result |
into only one message; mails sent by other clients may result in several messages (eg. one per attachment)) */ |
icnt = carray_count(mime_parser->parts); /* should be at least one - maybe empty - part */ |
stmt = dc_sqlite3_prepare(context->sql, |
"INSERT INTO msgs (rfc724_mid, server_folder, server_uid, chat_id, from_id, to_id," |
" timestamp, timestamp_sent, timestamp_rcvd, type, state, msgrmsg, " |
" txt, txt_raw, param, bytes, hidden, mime_headers, " |
" mime_in_reply_to, mime_references)" |
" VALUES (?,?,?,?,?,?, ?,?,?,?,?,?, ?,?,?,?,?,?, ?,?);"); |
for (i = 0; i < icnt; i++) |
{ |
dc_mimepart_t* part = (dc_mimepart_t*)carray_get(mime_parser->parts, i); |
if (part->is_meta) { |
continue; |
} |
if (mime_parser->location_kml && icnt==1 && part->msg |
&& (strcmp(part->msg, "-location-")==0 || part->msg[0]==0)) { |
hidden = 1; |
if (state==DC_STATE_IN_FRESH) { |
state = DC_STATE_IN_NOTICED; |
} |
} |
if (part->type==DC_MSG_TEXT) { |
txt_raw = dc_mprintf("%s\n\n%s", mime_parser->subject? mime_parser->subject : "", part->msg_raw); |
} |
if (mime_parser->is_system_message) { |
dc_param_set_int(part->param, DC_PARAM_CMD, mime_parser->is_system_message); |
} |
sqlite3_reset(stmt); |
sqlite3_bind_text (stmt, 1, rfc724_mid, -1, SQLITE_STATIC); |
sqlite3_bind_text (stmt, 2, server_folder, -1, SQLITE_STATIC); |
sqlite3_bind_int (stmt, 3, server_uid); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.