mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-05 02:29:28 +02:00
add verified-group-type
This commit is contained in:
parent
06279a6f7b
commit
88019229de
11 changed files with 35 additions and 17 deletions
|
@ -705,8 +705,10 @@ char* mrmailbox_cmdline(mrmailbox_t* mailbox, const char* cmdline)
|
|||
|
||||
char* temp_subtitle = mrchat_get_subtitle(chat);
|
||||
char* temp_name = mrchat_get_name(chat);
|
||||
int chat_type = mrchat_get_type(chat);
|
||||
const char* verified = mrchat_is_verified(chat)? " √√": "";
|
||||
mrmailbox_log_info(mailbox, 0, "%s#%i: %s%s [%s] [%i fresh]", mrchat_get_type(chat)==MR_CHAT_TYPE_GROUP? "Groupchat" : "Chat",
|
||||
mrmailbox_log_info(mailbox, 0, "%s#%i: %s%s [%s] [%i fresh]",
|
||||
chat_type==MR_CHAT_TYPE_VERIFIED_GROUP? "VerifiedGroup" : (chat_type==MR_CHAT_TYPE_GROUP? "Group" : "Chat"),
|
||||
(int)mrchat_get_id(chat), temp_name, verified, temp_subtitle, (int)mrmailbox_get_fresh_msg_count(mailbox, mrchat_get_id(chat)));
|
||||
free(temp_subtitle);
|
||||
free(temp_name);
|
||||
|
|
|
@ -345,6 +345,7 @@ void stress_functions(mrmailbox_t* mailbox)
|
|||
assert( strcmp("undefined=" MR_STRINGIFY(MR_CHAT_TYPE_UNDEFINED), "undefined=0")==0 );
|
||||
assert( strcmp("single=" MR_STRINGIFY(MR_CHAT_TYPE_SINGLE), "single=100")==0 );
|
||||
assert( strcmp("group=" MR_STRINGIFY(MR_CHAT_TYPE_GROUP), "group=120")==0 );
|
||||
assert( strcmp("vgroup=" MR_STRINGIFY(MR_CHAT_TYPE_VERIFIED_GROUP), "vgroup=130")==0 );
|
||||
|
||||
assert( strcmp("deaddrop=" MR_STRINGIFY(MR_CHAT_ID_DEADDROP), "deaddrop=1")==0 );
|
||||
assert( strcmp("trash=" MR_STRINGIFY(MR_CHAT_ID_TRASH), "trash=3")==0 );
|
||||
|
|
|
@ -56,6 +56,10 @@ int mrchat_update_param__ (mrchat_t*);
|
|||
int mrchat_are_all_members_verified__ (mrchat_t*);
|
||||
|
||||
|
||||
#define MR_CHAT_TYPE_IS_MULTI(a) ((a)==MR_CHAT_TYPE_GROUP || (a)==MR_CHAT_TYPE_VERIFIED_GROUP)
|
||||
#define MR_CHAT_TYPE_CAN_SEND(a) ((a)==MR_CHAT_TYPE_SINGLE || (a)==MR_CHAT_TYPE_GROUP || (a)==MR_CHAT_TYPE_VERIFIED_GROUP)
|
||||
|
||||
|
||||
#define MR_CHAT_PREFIX "Chat:" /* you MUST NOT modify this or the following strings */
|
||||
#define MR_CHATS_FOLDER "Chats" /* if we want to support Gma'l-labels - "Chats" is a reserved word for Gma'l */
|
||||
|
||||
|
|
|
@ -157,6 +157,9 @@ uint32_t mrchat_get_id(mrchat_t* chat)
|
|||
* - MR_CHAT_TYPE_GROUP (120) - a group chat, chats_contacts conain all group
|
||||
* members, incl. MR_CONTACT_ID_SELF
|
||||
*
|
||||
* - MR_CHAT_TYPE_VERIFIED_GROUP (130) - a verified group chat. In verified groups,
|
||||
* all members are verified and encryption is always active and cannot be disabled.
|
||||
*
|
||||
* @memberof mrchat_t
|
||||
*
|
||||
* @param chat The chat object.
|
||||
|
@ -241,7 +244,7 @@ char* mrchat_get_subtitle(mrchat_t* chat)
|
|||
|
||||
mrsqlite3_unlock(chat->m_mailbox->m_sql);
|
||||
}
|
||||
else if( chat->m_type == MR_CHAT_TYPE_GROUP )
|
||||
else if( MR_CHAT_TYPE_IS_MULTI(chat->m_type) )
|
||||
{
|
||||
int cnt = 0;
|
||||
if( chat->m_id == MR_CHAT_ID_DEADDROP )
|
||||
|
|
|
@ -38,9 +38,10 @@ typedef struct _mrmailbox mrmailbox_t;
|
|||
#define MR_CHAT_ID_LAST_SPECIAL 9 /* larger chat IDs are "real" chats, their messages are "real" messages. */
|
||||
|
||||
|
||||
#define MR_CHAT_TYPE_UNDEFINED 0
|
||||
#define MR_CHAT_TYPE_SINGLE 100
|
||||
#define MR_CHAT_TYPE_GROUP 120
|
||||
#define MR_CHAT_TYPE_UNDEFINED 0
|
||||
#define MR_CHAT_TYPE_SINGLE 100
|
||||
#define MR_CHAT_TYPE_GROUP 120
|
||||
#define MR_CHAT_TYPE_VERIFIED_GROUP 130
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -231,7 +231,7 @@ mrlot_t* mrchatlist_get_summary(mrchatlist_t* chatlist, size_t index, mrchat_t*
|
|||
lastmsg = mrmsg_new();
|
||||
mrmsg_load_from_db__(lastmsg, chatlist->m_mailbox, lastmsg_id);
|
||||
|
||||
if( lastmsg->m_from_id != MR_CONTACT_ID_SELF && chat->m_type == MR_CHAT_TYPE_GROUP )
|
||||
if( lastmsg->m_from_id != MR_CONTACT_ID_SELF && MR_CHAT_TYPE_IS_MULTI(chat->m_type) )
|
||||
{
|
||||
lastcontact = mrcontact_new(chatlist->m_mailbox);
|
||||
mrcontact_load_from_db__(lastcontact, chatlist->m_mailbox->m_sql, lastmsg->m_from_id);
|
||||
|
|
|
@ -219,7 +219,7 @@ void mrlot_fill(mrlot_t* ths, const mrmsg_t* msg, const mrchat_t* chat, const mr
|
|||
ths->m_text1 = NULL;
|
||||
ths->m_text1_meaning = 0;
|
||||
}
|
||||
else if( chat->m_type==MR_CHAT_TYPE_GROUP )
|
||||
else if( MR_CHAT_TYPE_IS_MULTI(chat->m_type) )
|
||||
{
|
||||
if( contact==NULL ) {
|
||||
free(ths->m_text1);
|
||||
|
|
|
@ -2242,7 +2242,12 @@ static uint32_t mrmailbox_send_msg_i__(mrmailbox_t* mailbox, mrchat_t* chat, con
|
|||
sqlite3_stmt* stmt;
|
||||
uint32_t msg_id = 0, to_id = 0;
|
||||
|
||||
if( chat->m_type==MR_CHAT_TYPE_GROUP && !mrmailbox_is_contact_in_chat__(mailbox, chat->m_id, MR_CONTACT_ID_SELF) ) {
|
||||
if( !MR_CHAT_TYPE_CAN_SEND(chat->m_type) ) {
|
||||
mrmailbox_log_error(mailbox, 0, "Cannot send to chat type #%i.", chat->m_type);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( MR_CHAT_TYPE_IS_MULTI(chat->m_type) && !mrmailbox_is_contact_in_chat__(mailbox, chat->m_id, MR_CONTACT_ID_SELF) ) {
|
||||
mrmailbox_log_error(mailbox, MR_ERR_SELF_NOT_IN_GROUP, NULL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -2253,7 +2258,7 @@ static uint32_t mrmailbox_send_msg_i__(mrmailbox_t* mailbox, mrchat_t* chat, con
|
|||
mrmailbox_log_error(mailbox, 0, "Cannot send message, not configured successfully.");
|
||||
goto cleanup;
|
||||
}
|
||||
rfc724_mid = mr_create_outgoing_rfc724_mid(chat->m_type==MR_CHAT_TYPE_GROUP? chat->m_grpid : NULL, from);
|
||||
rfc724_mid = mr_create_outgoing_rfc724_mid(MR_CHAT_TYPE_IS_MULTI(chat->m_type)? chat->m_grpid : NULL, from);
|
||||
free(from);
|
||||
}
|
||||
|
||||
|
@ -2268,7 +2273,7 @@ static uint32_t mrmailbox_send_msg_i__(mrmailbox_t* mailbox, mrchat_t* chat, con
|
|||
}
|
||||
to_id = sqlite3_column_int(stmt, 0);
|
||||
}
|
||||
else if( chat->m_type == MR_CHAT_TYPE_GROUP )
|
||||
else if( MR_CHAT_TYPE_IS_MULTI(chat->m_type) )
|
||||
{
|
||||
if( mrparam_get_int(chat->m_param, MRP_UNPROMOTED, 0)==1 ) {
|
||||
/* mark group as being no longer unpromoted */
|
||||
|
@ -2913,6 +2918,7 @@ void mrmailbox_set_group_explicitly_left__(mrmailbox_t* mailbox, const char* grp
|
|||
|
||||
static int mrmailbox_real_group_exists__(mrmailbox_t* mailbox, uint32_t chat_id)
|
||||
{
|
||||
// check if a group or a verified group exists under the given ID
|
||||
sqlite3_stmt* stmt;
|
||||
int ret = 0;
|
||||
|
||||
|
@ -2922,9 +2928,10 @@ static int mrmailbox_real_group_exists__(mrmailbox_t* mailbox, uint32_t chat_id)
|
|||
}
|
||||
|
||||
stmt = mrsqlite3_predefine__(mailbox->m_sql, SELECT_id_FROM_chats_WHERE_id,
|
||||
"SELECT id FROM chats WHERE id=? AND type=?;");
|
||||
"SELECT id FROM chats "
|
||||
" WHERE id=? "
|
||||
" AND (type=" MR_STRINGIFY(MR_CHAT_TYPE_GROUP) " OR type=" MR_STRINGIFY(MR_CHAT_TYPE_VERIFIED_GROUP) ");");
|
||||
sqlite3_bind_int(stmt, 1, chat_id);
|
||||
sqlite3_bind_int(stmt, 2, MR_CHAT_TYPE_GROUP);
|
||||
|
||||
if( sqlite3_step(stmt) == SQLITE_ROW ) {
|
||||
ret = 1;
|
||||
|
@ -2989,7 +2996,7 @@ uint32_t mrmailbox_create_group_chat(mrmailbox_t* mailbox, int verified, const c
|
|||
|
||||
stmt = mrsqlite3_prepare_v2_(mailbox->m_sql,
|
||||
"INSERT INTO chats (type, name, draft_timestamp, draft_txt, grpid, param) VALUES(?, ?, ?, ?, ?, 'U=1');" /*U=MRP_UNPROMOTED*/ );
|
||||
sqlite3_bind_int (stmt, 1, MR_CHAT_TYPE_GROUP);
|
||||
sqlite3_bind_int (stmt, 1, verified? MR_CHAT_TYPE_VERIFIED_GROUP : MR_CHAT_TYPE_GROUP);
|
||||
sqlite3_bind_text (stmt, 2, chat_name, -1, SQLITE_STATIC);
|
||||
sqlite3_bind_int64(stmt, 3, time(NULL));
|
||||
sqlite3_bind_text (stmt, 4, draft_txt, -1, SQLITE_STATIC);
|
||||
|
|
|
@ -371,7 +371,7 @@ static mrarray_t* search_chat_ids_by_contact_ids(mrmailbox_t* mailbox, const mra
|
|||
" FROM chats_contacts cc "
|
||||
" LEFT JOIN chats c ON c.id=cc.chat_id "
|
||||
" WHERE cc.chat_id IN(SELECT chat_id FROM chats_contacts WHERE contact_id IN(%s))"
|
||||
" AND c.type=" MR_STRINGIFY(MR_CHAT_TYPE_GROUP) /* do not select normal chats which are equal to a group with a single member and without SELF */
|
||||
" AND c.type=" MR_STRINGIFY(MR_CHAT_TYPE_GROUP) /* no verified groups and no single chats (which are equal to a group with a single member and without SELF) */
|
||||
" AND cc.contact_id!=" MR_STRINGIFY(MR_CONTACT_ID_SELF) /* ignore SELF, we've also removed it above - if the user has left the group, it is still the same group */
|
||||
" ORDER BY cc.chat_id, cc.contact_id;",
|
||||
contact_ids_str);
|
||||
|
|
|
@ -418,7 +418,7 @@ static char* get_subject(const mrchat_t* chat, const mrmsg_t* msg, int afwd_emai
|
|||
{
|
||||
ret = mrstock_str(MR_STR_AC_SETUP_MSG_SUBJECT); /* do not add the "Chat:" prefix for setup messages */
|
||||
}
|
||||
else if( chat->m_type==MR_CHAT_TYPE_GROUP )
|
||||
else if( MR_CHAT_TYPE_IS_MULTI(chat->m_type) )
|
||||
{
|
||||
ret = mr_mprintf(MR_CHAT_PREFIX " %s: %s%s", chat->m_name, fwd, raw_subject);
|
||||
}
|
||||
|
@ -523,7 +523,7 @@ int mrmimefactory_render(mrmimefactory_t* factory)
|
|||
|
||||
/* build header etc. */
|
||||
int command = mrparam_get_int(msg->m_param, MRP_CMD, 0);
|
||||
if( chat->m_type==MR_CHAT_TYPE_GROUP )
|
||||
if( MR_CHAT_TYPE_IS_MULTI(chat->m_type) )
|
||||
{
|
||||
mailimf_fields_add(imf_fields, mailimf_field_new_custom(strdup("Chat-Group-ID"), safe_strdup(chat->m_grpid)));
|
||||
mailimf_fields_add(imf_fields, mailimf_field_new_custom(strdup("Chat-Group-Name"), mr_encode_header_string(chat->m_name)));
|
||||
|
|
|
@ -641,7 +641,7 @@ mrlot_t* mrmsg_get_summary(const mrmsg_t* msg, const mrchat_t* chat)
|
|||
chat = chat_to_delete;
|
||||
}
|
||||
|
||||
if( msg->m_from_id != MR_CONTACT_ID_SELF && chat->m_type == MR_CHAT_TYPE_GROUP ) {
|
||||
if( msg->m_from_id != MR_CONTACT_ID_SELF && MR_CHAT_TYPE_IS_MULTI(chat->m_type) ) {
|
||||
contact = mrmailbox_get_contact(chat->m_mailbox, msg->m_from_id);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue