Skip to content

Commit

Permalink
Merge branch 'jb42099-sms-sent-status' into 'master'
Browse files Browse the repository at this point in the history
[commhistoryd] Don't use getEventById() result if no events are found. Contributes to JB#42099

See merge request mer-core/commhistory-daemon!26
  • Loading branch information
blam committed Jan 7, 2019
2 parents 8007dfa + e91fb66 commit 9fd71e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/mmshandler.cpp
Expand Up @@ -635,6 +635,10 @@ void MmsHandler::readReportSendStatus(const QString &recId, int status)
SingleEventModel model;
if (model.getEventById(recId.toInt())) {
Event event(model.event());
if (!event.isValid()) {
qWarning() << "Failed to find sent MMS by id";
return;
}
event.removeExtraProperty(MMS_PROPERTY_UNREAD);
if (!model.modifyEvent(event)) {
qWarning() << "Failed to update MMS event" << event.id();
Expand Down Expand Up @@ -817,8 +821,12 @@ void MmsHandler::onSendMessageFinished(QDBusPendingCallWatcher *call)
model.modifyEvent(event);
NotificationManager::instance()->showNotification(event, event.recipients().value(0).remoteUid(), Group::ChatTypeP2P);
} else {
event.setSubscriberIdentity(reply.value());
model.modifyEvent(event);
if (event.isValid()) {
event.setSubscriberIdentity(reply.value());
model.modifyEvent(event);
} else {
qWarning() << "Cannot find sent message by id" << eventId;
}
}
}
call->deleteLater();
Expand Down
2 changes: 1 addition & 1 deletion src/textchannellistener.cpp
Expand Up @@ -1281,7 +1281,7 @@ void TextChannelListener::slotMessageSent(const Tp::Message &message,
DEBUG() << "Handling sent message: " << m_Account->objectPath() << "->" << remoteUid << messageText;

CommHistory::Event event;
if (existingEventId >= 0 && getEventById(existingEventId, event)) {
if (existingEventId >= 0 && getEventById(existingEventId, event) && event.isValid()) {
DEBUG() << "Sent message has an existing event" << existingEventId;
} else {
fillEventFromMessage(message, event);
Expand Down

0 comments on commit 9fd71e1

Please sign in to comment.