diff --git a/coreapi/chat.c b/coreapi/chat.c index 005dea819..4379e3f6b 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -176,9 +176,6 @@ static void linphone_chat_message_process_response_from_post_file(void *data, co } body = belle_sip_message_get_body((belle_sip_message_t *)event->response); msg->message = ms_strdup(body); - linphone_content_uninit(msg->file_transfer_information); - ms_free(msg->file_transfer_information); - msg->file_transfer_information = NULL; msg->content_type = ms_strdup("application/vnd.gsma.rcs-ft-http+xml"); _linphone_chat_room_send_message(msg->chat_room, msg); } @@ -424,7 +421,7 @@ static void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatM time_t t=time(NULL); linphone_chat_message_ref(msg); /* Check if we shall upload a file to a server */ - if (msg->file_transfer_information != NULL) { + if (msg->file_transfer_information != NULL && msg->content_type == NULL) { /* open a transaction with the server and send an empty request(RCS5.1 section 3.5.4.8.3.1) */ belle_http_request_listener_callbacks_t cbs={0}; belle_http_request_listener_t *l; @@ -481,6 +478,9 @@ static void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatM sal_text_send(op, identity, cr->peer,msg->message); } else { sal_message_send(op, identity, cr->peer, msg->content_type, msg->message); + // Remove the message to prevent the xml from the file uplaod to be stored in the database + ms_free(msg->message); + msg->message = NULL; } } msg->dir=LinphoneChatMessageOutgoing; diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 8089722e8..c87891a34 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -250,8 +250,8 @@ unsigned int linphone_chat_message_store(LinphoneChatMessage *msg){ void linphone_chat_message_store_state(LinphoneChatMessage *msg){ LinphoneCore *lc=msg->chat_room->lc; if (lc->db){ - char *buf=sqlite3_mprintf("UPDATE history SET status=%i WHERE (message = %Q OR url = %Q) AND utc = %i;", - msg->state,msg->message,msg->external_body_url,msg->time); + char *buf=sqlite3_mprintf("UPDATE history SET status=%i WHERE (id = %i) AND utc = %i;", + msg->state,msg->storage_id,msg->time); linphone_sql_request(lc->db,buf); sqlite3_free(buf); }