text stringlengths 0 357 |
|---|
stmt = NULL; |
if (!success) { |
// there are no messages of other users - use the first message if SELF as parent |
stmt = dc_sqlite3_prepare(chat->context->sql, |
"SELECT rfc724_mid, mime_in_reply_to, mime_references" |
" FROM msgs" |
" WHERE chat_id=? AND timestamp=(SELECT min(timestamp) FROM msgs WHERE chat_id=? AND from_id==?);"); |
sqlite3_bind_int (stmt, 1, chat->id); |
sqlite3_bind_int (stmt, 2, chat->id); |
sqlite3_bind_int (stmt, 3, DC_CONTACT_ID_SELF); |
if (sqlite3_step(stmt)==SQLITE_ROW) { |
*parent_rfc724_mid = dc_strdup((const char*)sqlite3_column_text(stmt, 0)); |
*parent_in_reply_to = dc_strdup((const char*)sqlite3_column_text(stmt, 1)); |
*parent_references = dc_strdup((const char*)sqlite3_column_text(stmt, 2)); |
success = 1; |
} |
} |
cleanup: |
sqlite3_finalize(stmt); |
return success; |
} |
static uint32_t prepare_msg_raw(dc_context_t* context, dc_chat_t* chat, const dc_msg_t* msg, time_t timestamp) |
{ |
char* parent_rfc724_mid = NULL; |
char* parent_references = NULL; |
char* parent_in_reply_to = NULL; |
char* new_rfc724_mid = NULL; |
char* new_references = NULL; |
char* new_in_reply_to = NULL; |
sqlite3_stmt* stmt = NULL; |
uint32_t msg_id = 0; |
uint32_t to_id = 0; |
uint32_t location_id = 0; |
if (!DC_CHAT_TYPE_CAN_SEND(chat->type)) { |
dc_log_error(context, 0, "Cannot send to chat type #%i.", chat->type); |
goto cleanup; |
} |
if (DC_CHAT_TYPE_IS_MULTI(chat->type) && !dc_is_contact_in_chat(context, chat->id, DC_CONTACT_ID_SELF)) { |
dc_log_event(context, DC_EVENT_ERROR_SELF_NOT_IN_GROUP, 0, |
"Cannot send message; self not in group."); |
goto cleanup; |
} |
{ |
char* from = dc_sqlite3_get_config(context->sql, "configured_addr", NULL); |
if (from==NULL) { |
dc_log_error(context, 0, "Cannot send message, not configured."); |
goto cleanup; |
} |
new_rfc724_mid = dc_create_outgoing_rfc724_mid(DC_CHAT_TYPE_IS_MULTI(chat->type)? chat->grpid : NULL, from); |
free(from); |
} |
if (chat->type==DC_CHAT_TYPE_SINGLE) |
{ |
stmt = dc_sqlite3_prepare(context->sql, |
"SELECT contact_id FROM chats_contacts WHERE chat_id=?;"); |
sqlite3_bind_int(stmt, 1, chat->id); |
if (sqlite3_step(stmt)!=SQLITE_ROW) { |
dc_log_error(context, 0, "Cannot send message, contact for chat #%i not found.", chat->id); |
goto cleanup; |
} |
to_id = sqlite3_column_int(stmt, 0); |
sqlite3_finalize(stmt); |
stmt = NULL; |
} |
else if (DC_CHAT_TYPE_IS_MULTI(chat->type)) |
{ |
if (dc_param_get_int(chat->param, DC_PARAM_UNPROMOTED, 0)==1) { |
/* mark group as being no longer unpromoted */ |
dc_param_set(chat->param, DC_PARAM_UNPROMOTED, NULL); |
dc_chat_update_param(chat); |
} |
} |
/* check if we can guarantee E2EE for this message. |
if we guarantee E2EE, and circumstances change |
so that E2EE is no longer available at a later point (reset, changed settings), |
we do not send the message out at all */ |
int do_guarantee_e2ee = 0; |
int e2ee_enabled = dc_sqlite3_get_config_int(context->sql, "e2ee_enabled", DC_E2EE_DEFAULT_ENABLED); |
if (e2ee_enabled && dc_param_get_int(msg->param, DC_PARAM_FORCE_PLAINTEXT, 0)==0) |
{ |
int can_encrypt = 1, all_mutual = 1; /* be optimistic */ |
stmt = dc_sqlite3_prepare(context->sql, |
"SELECT ps.prefer_encrypted, c.addr" |
" FROM chats_contacts cc " |
" LEFT JOIN contacts c ON cc.contact_id=c.id " |
" LEFT JOIN acpeerstates ps ON c.addr=ps.addr " |
" WHERE cc.chat_id=? " /* take care that this statement returns NULL rows if there is no peerstates for a chat member! */ |
" AND cc.contact_id>" DC_STRINGIFY(DC_CONTACT_ID_LAST_SPECIAL) ";"); /* for DC_PARAM_SELFTALK this statement does not return any row */ |
sqlite3_bind_int(stmt, 1, chat->id); |
while (sqlite3_step(stmt)==SQLITE_ROW) |
{ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.