text stringlengths 0 357 |
|---|
} |
sqlite3_free(q3); |
q3 = NULL; |
q3 = sqlite3_mprintf("DELETE FROM msgs WHERE chat_id=%i;", chat_id); |
if (!dc_sqlite3_execute(context->sql, q3)) { |
goto cleanup; |
} |
sqlite3_free(q3); |
q3 = NULL; |
q3 = sqlite3_mprintf("DELETE FROM chats_contacts WHERE chat_id=%i;", chat_id); |
if (!dc_sqlite3_execute(context->sql, q3)) { |
goto cleanup; |
} |
sqlite3_free(q3); |
q3 = NULL; |
q3 = sqlite3_mprintf("DELETE FROM chats WHERE id=%i;", chat_id); |
if (!dc_sqlite3_execute(context->sql, q3)) { |
goto cleanup; |
} |
sqlite3_free(q3); |
q3 = NULL; |
dc_sqlite3_commit(context->sql); |
pending_transaction = 0; |
context->cb(context, DC_EVENT_MSGS_CHANGED, 0, 0); |
dc_job_kill_action(context, DC_JOB_HOUSEKEEPING); |
dc_job_add(context, DC_JOB_HOUSEKEEPING, 0, NULL, DC_HOUSEKEEPING_DELAY_SEC); |
cleanup: |
if (pending_transaction) { dc_sqlite3_rollback(context->sql); } |
dc_chat_unref(obj); |
sqlite3_free(q3); |
} |
/******************************************************************************* |
* Handle Group Chats |
******************************************************************************/ |
#define IS_SELF_IN_GROUP (dc_is_contact_in_chat(context, chat_id, DC_CONTACT_ID_SELF)==1) |
#define DO_SEND_STATUS_MAILS (dc_param_get_int(chat->param, DC_PARAM_UNPROMOTED, 0)==0) |
int dc_is_group_explicitly_left(dc_context_t* context, const char* grpid) |
{ |
sqlite3_stmt* stmt = dc_sqlite3_prepare(context->sql, "SELECT id FROM leftgrps WHERE grpid=?;"); |
sqlite3_bind_text (stmt, 1, grpid, -1, SQLITE_STATIC); |
int ret = (sqlite3_step(stmt)==SQLITE_ROW); |
sqlite3_finalize(stmt); |
return ret; |
} |
void dc_set_group_explicitly_left(dc_context_t* context, const char* grpid) |
{ |
if (!dc_is_group_explicitly_left(context, grpid)) |
{ |
sqlite3_stmt* stmt = dc_sqlite3_prepare(context->sql, "INSERT INTO leftgrps (grpid) VALUES(?);"); |
sqlite3_bind_text (stmt, 1, grpid, -1, SQLITE_STATIC); |
sqlite3_step(stmt); |
sqlite3_finalize(stmt); |
} |
} |
static int real_group_exists(dc_context_t* context, uint32_t chat_id) |
{ |
// check if a group or a verified group exists under the given ID |
sqlite3_stmt* stmt = NULL; |
int ret = 0; |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC || context->sql->cobj==NULL |
|| chat_id<=DC_CHAT_ID_LAST_SPECIAL) { |
return 0; |
} |
stmt = dc_sqlite3_prepare(context->sql, |
"SELECT id FROM chats " |
" WHERE id=? " |
" AND (type=" DC_STRINGIFY(DC_CHAT_TYPE_GROUP) " OR type=" DC_STRINGIFY(DC_CHAT_TYPE_VERIFIED_GROUP) ");"); |
sqlite3_bind_int(stmt, 1, chat_id); |
if (sqlite3_step(stmt)==SQLITE_ROW) { |
ret = 1; |
} |
sqlite3_finalize(stmt); |
return ret; |
} |
/** |
* Create a new group chat. |
* |
* After creation, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.