1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-06 03:50:08 +02:00

Merge pull request #513 from deltachat/addtogroup

do not show group-member-added-messages as images
This commit is contained in:
björn petersen 2019-01-09 21:48:32 +01:00 committed by GitHub
commit f4c300fd17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 16 deletions

View file

@ -1499,6 +1499,20 @@ void dc_mimeparser_parse(dc_mimeparser_t* mimeparser, const char* body_not_termi
mimeparser->is_send_by_messenger = 0; /* do not treat a setup message as a messenger message (eg. do not move setup messages to the Chats-folder; there may be a 3rd device that wants to handle it) */ mimeparser->is_send_by_messenger = 0; /* do not treat a setup message as a messenger message (eg. do not move setup messages to the Chats-folder; there may be a 3rd device that wants to handle it) */
} }
/* some special system message? */
if (dc_mimeparser_lookup_field(mimeparser, "Chat-Group-Image")
&& carray_count(mimeparser->parts)>=1) {
dc_mimepart_t* textpart = (dc_mimepart_t*)carray_get(mimeparser->parts, 0);
if (textpart->type==DC_MSG_TEXT) {
if (carray_count(mimeparser->parts)>=2) {
dc_mimepart_t* imgpart = (dc_mimepart_t*)carray_get(mimeparser->parts, 1);
if (imgpart->type==DC_MSG_IMAGE) {
imgpart->is_meta = 1;
}
}
}
}
// create compound messages // create compound messages
if (mimeparser->is_send_by_messenger if (mimeparser->is_send_by_messenger
&& s_generate_compound_msgs && s_generate_compound_msgs
@ -1507,7 +1521,9 @@ void dc_mimeparser_parse(dc_mimeparser_t* mimeparser, const char* body_not_termi
dc_mimepart_t* textpart = (dc_mimepart_t*)carray_get(mimeparser->parts, 0); dc_mimepart_t* textpart = (dc_mimepart_t*)carray_get(mimeparser->parts, 0);
dc_mimepart_t* filepart = (dc_mimepart_t*)carray_get(mimeparser->parts, 1); dc_mimepart_t* filepart = (dc_mimepart_t*)carray_get(mimeparser->parts, 1);
if (textpart->type==DC_MSG_TEXT && DC_MSG_NEEDS_ATTACHMENT(filepart->type)) if (textpart->type==DC_MSG_TEXT
&& DC_MSG_NEEDS_ATTACHMENT(filepart->type)
&& !filepart->is_meta)
{ {
free(filepart->msg); free(filepart->msg);
filepart->msg = textpart->msg; filepart->msg = textpart->msg;
@ -1588,21 +1604,6 @@ void dc_mimeparser_parse(dc_mimeparser_t* mimeparser, const char* body_not_termi
} }
} }
/* some special system message? */
if (dc_mimeparser_lookup_field(mimeparser, "Chat-Group-Image")
&& carray_count(mimeparser->parts)>=1) {
dc_mimepart_t* textpart = (dc_mimepart_t*)carray_get(mimeparser->parts, 0);
if (textpart->type==DC_MSG_TEXT) {
dc_param_set_int(textpart->param, DC_PARAM_CMD, DC_CMD_GROUPIMAGE_CHANGED);
if (carray_count(mimeparser->parts)>=2) {
dc_mimepart_t* imgpart = (dc_mimepart_t*)carray_get(mimeparser->parts, 1);
if (imgpart->type==DC_MSG_IMAGE) {
imgpart->is_meta = 1;
}
}
}
}
/* check, if the message asks for a MDN */ /* check, if the message asks for a MDN */
if (!mimeparser->decrypting_failed) if (!mimeparser->decrypting_failed)
{ {

View file

@ -661,6 +661,9 @@ static void create_or_lookup_group(dc_context_t* context, dc_mimeparser_t* mime_
else if ((optional_field=dc_mimeparser_lookup_optional_field(mime_parser, "Chat-Group-Member-Added"))!=NULL) { else if ((optional_field=dc_mimeparser_lookup_optional_field(mime_parser, "Chat-Group-Member-Added"))!=NULL) {
X_MrAddToGrp = optional_field->fld_value; X_MrAddToGrp = optional_field->fld_value;
mime_parser->is_system_message = DC_CMD_MEMBER_ADDED_TO_GROUP; mime_parser->is_system_message = DC_CMD_MEMBER_ADDED_TO_GROUP;
if ((optional_field=dc_mimeparser_lookup_optional_field(mime_parser, "Chat-Group-Image"))!=NULL) {
X_MrGrpImageChanged = optional_field->fld_value;
}
} }
else if ((optional_field=dc_mimeparser_lookup_optional_field(mime_parser, "Chat-Group-Name-Changed"))!=NULL) { else if ((optional_field=dc_mimeparser_lookup_optional_field(mime_parser, "Chat-Group-Name-Changed"))!=NULL) {
X_MrGrpNameChanged = 1; X_MrGrpNameChanged = 1;