text stringlengths 0 357 |
|---|
} |
} |
/* check if the sender is a member of the existing group - |
if not, we'll recreate the group list */ |
if (chat_id!=0 && !dc_is_contact_in_chat(context, chat_id, from_id)) { |
recreate_member_list = 1; |
} |
/* check if the group does not exist but should be created */ |
int group_explicitly_left = dc_is_group_explicitly_left(context, grpid); |
self_addr = dc_sqlite3_get_config(context->sql, "configured_addr", ""); |
if (chat_id==0 |
&& !dc_mimeparser_is_mailinglist_message(mime_parser) |
&& grpid |
&& grpname |
&& X_MrRemoveFromGrp==NULL /*otherwise, a pending "quit" message may pop up*/ |
&& (!group_explicitly_left || (X_MrAddToGrp&&dc_addr_cmp(self_addr,X_MrAddToGrp)==0)) /*re-create explicitly left groups only if ourself is re-added*/ |
) |
{ |
int create_verified = 0; |
if (dc_mimeparser_lookup_field(mime_parser, "Chat-Verified")) { |
create_verified = 1; |
if (!check_verified_properties(context, mime_parser, from_id, to_ids, &failure_reason)) { |
dc_mimeparser_repl_msg_by_error(mime_parser, failure_reason); |
} |
} |
if (!allow_creation) { |
goto cleanup; |
} |
chat_id = create_group_record(context, grpid, grpname, create_blocked, create_verified); |
chat_id_blocked = create_blocked; |
chat_id_verified = create_verified; |
recreate_member_list = 1; |
} |
/* again, check chat_id */ |
if (chat_id <= DC_CHAT_ID_LAST_SPECIAL) { |
chat_id = 0; |
if (group_explicitly_left) { |
chat_id = DC_CHAT_ID_TRASH; /* we got a message for a chat we've deleted - do not show this even as a normal chat */ |
} |
else { |
create_or_lookup_adhoc_group(context, mime_parser, |
allow_creation, create_blocked, |
from_id, to_ids, &chat_id, &chat_id_blocked); |
} |
goto cleanup; |
} |
/* execute group commands */ |
if (X_MrAddToGrp || X_MrRemoveFromGrp) |
{ |
recreate_member_list = 1; |
} |
else if (X_MrGrpNameChanged && grpname && strlen(grpname) < 200) |
{ |
stmt = dc_sqlite3_prepare(context->sql, "UPDATE chats SET name=? WHERE id=?;"); |
sqlite3_bind_text(stmt, 1, grpname, -1, SQLITE_STATIC); |
sqlite3_bind_int (stmt, 2, chat_id); |
sqlite3_step(stmt); |
sqlite3_finalize(stmt); |
context->cb(context, DC_EVENT_CHAT_MODIFIED, chat_id, 0); |
} |
if (X_MrGrpImageChanged) |
{ |
int ok = 0; |
char* grpimage = NULL; |
if( strcmp(X_MrGrpImageChanged, "0")==0 ) { |
ok = 1; // group image deleted |
} |
else { |
for (int i = 0; i < carray_count(mime_parser->parts); i++) { |
dc_mimepart_t* part = (dc_mimepart_t*)carray_get(mime_parser->parts, i); |
if (part->type==DC_MSG_IMAGE) { |
grpimage = dc_param_get(part->param, DC_PARAM_FILE, NULL); |
ok = 1; // new group image set |
} |
} |
} |
if (ok) { |
dc_chat_t* chat = dc_chat_new(context); |
dc_log_info(context, 0, "New group image set to %s.", grpimage? "DELETED" : grpimage); |
dc_chat_load_from_db(chat, chat_id); |
dc_param_set(chat->param, DC_PARAM_PROFILE_IMAGE, grpimage/*may be NULL*/); |
dc_chat_update_param(chat); |
dc_chat_unref(chat); |
free(grpimage); |
send_EVENT_CHAT_MODIFIED = 1; |
} |
} |
/* add members to group/check members |
for recreation: we should add a timestamp */ |
if (recreate_member_list) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.