Commit 498b28ee authored by Ronan's avatar Ronan

Revert "Revert "fix(ChatMessage): chat message state must be independent of imdn""

This reverts commit f319f5cf.
parent f319f5cf
......@@ -62,7 +62,11 @@ public:
void setDirection (ChatMessage::Direction dir);
void setParticipantState (const IdentityAddress &participantAddress, ChatMessage::State newState, time_t stateChangeTime);
virtual void setState (ChatMessage::State newState, bool force = false);
virtual void setState (ChatMessage::State newState);
void forceState (ChatMessage::State newState) {
state = newState;
}
void setTime (time_t time);
......@@ -97,9 +101,6 @@ public:
belle_http_request_t *getHttpRequest () const;
void setHttpRequest (belle_http_request_t *request);
SalOp *getSalOp () const;
void setSalOp (SalOp *op);
bool getDisplayNotificationRequired () const { return displayNotificationRequired; }
bool getNegativeDeliveryNotificationRequired () const { return negativeDeliveryNotificationRequired; }
bool getPositiveDeliveryNotificationRequired () const { return positiveDeliveryNotificationRequired; }
......@@ -107,6 +108,12 @@ public:
virtual void setNegativeDeliveryNotificationRequired (bool value) { negativeDeliveryNotificationRequired = value; }
virtual void setPositiveDeliveryNotificationRequired (bool value) { positiveDeliveryNotificationRequired = value; }
SalOp *getSalOp () const;
void setSalOp (SalOp *op);
void disableDeliveryNotificationRequiredInDatabase ();
void disableDisplayNotificationRequiredInDatabase ();
SalCustomHeader *getSalCustomHeaders () const;
void setSalCustomHeaders (SalCustomHeader *headers);
......
......@@ -133,15 +133,14 @@ void ChatMessagePrivate::setParticipantState (const IdentityAddress &participant
setState(ChatMessage::State::DeliveredToUser);
}
void ChatMessagePrivate::setState (ChatMessage::State newState, bool force) {
void ChatMessagePrivate::setState (ChatMessage::State newState) {
L_Q();
if (force)
state = newState;
// 1. Check valid transition.
if (!isValidStateTransition(state, newState))
return;
// 2. Update state and notify changes.
lInfo() << "Chat message " << this << ": moving from " << Utils::toString(state) <<
" to " << Utils::toString(newState);
state = newState;
......@@ -150,7 +149,7 @@ void ChatMessagePrivate::setState (ChatMessage::State newState, bool force) {
if (linphone_chat_message_get_message_state_changed_cb(msg))
linphone_chat_message_get_message_state_changed_cb(msg)(
msg,
(LinphoneChatMessageState)state,
LinphoneChatMessageState(state),
linphone_chat_message_get_message_state_changed_cb_user_data(msg)
);
......@@ -158,17 +157,22 @@ void ChatMessagePrivate::setState (ChatMessage::State newState, bool force) {
if (cbs && linphone_chat_message_cbs_get_msg_state_changed(cbs))
linphone_chat_message_cbs_get_msg_state_changed(cbs)(msg, (LinphoneChatMessageState)state);
// 3. Specific case, change to displayed after transfer.
if (state == ChatMessage::State::FileTransferDone) {
if (!hasFileTransferContent()) {
// We wait until the file has been downloaded to send the displayed IMDN
bool doNotStoreInDb = static_cast<ChatRoomPrivate *>(q->getChatRoom()->getPrivate())->sendDisplayNotification(q->getSharedFromThis());
// Force the state so it is stored directly in DB, but when the IMDN has successfully been delivered
setState(ChatMessage::State::Displayed, doNotStoreInDb);
}
} else if (state != ChatMessage::State::FileTransferError && state != ChatMessage::State::InProgress)
setState(ChatMessage::State::Displayed);
return;
}
// 4. Send notification and update in database if necessary.
if (state != ChatMessage::State::FileTransferError && state != ChatMessage::State::InProgress) {
if (state == ChatMessage::State::Displayed)
static_cast<ChatRoomPrivate *>(q->getChatRoom()->getPrivate())->sendDisplayNotification(q->getSharedFromThis());
updateInDb();
}
}
// -----------------------------------------------------------------------------
belle_http_request_t *ChatMessagePrivate::getHttpRequest () const {
return fileTransferChatMessageModifier.getHttpRequest();
}
......@@ -177,6 +181,24 @@ void ChatMessagePrivate::setHttpRequest (belle_http_request_t *request) {
fileTransferChatMessageModifier.setHttpRequest(request);
}
// -----------------------------------------------------------------------------
void ChatMessagePrivate::disableDeliveryNotificationRequiredInDatabase () {
L_Q();
unique_ptr<MainDb> &mainDb = q->getChatRoom()->getCore()->getPrivate()->mainDb;
if (dbKey.isValid())
mainDb->disableDeliveryNotificationRequired(mainDb->getEventFromKey(dbKey));
}
void ChatMessagePrivate::disableDisplayNotificationRequiredInDatabase () {
L_Q();
unique_ptr<MainDb> &mainDb = q->getChatRoom()->getCore()->getPrivate()->mainDb;
if (dbKey.isValid())
mainDb->disableDisplayNotificationRequired(mainDb->getEventFromKey(dbKey));
}
// -----------------------------------------------------------------------------
SalOp *ChatMessagePrivate::getSalOp () const {
return salOp;
}
......@@ -469,11 +491,11 @@ void ChatMessagePrivate::notifyReceiving () {
::time(nullptr), q->getSharedFromThis()
);
_linphone_chat_room_notify_chat_message_received(chatRoom, L_GET_C_BACK_PTR(event));
// Legacy
q->getChatRoom()->getPrivate()->notifyChatMessageReceived(q->getSharedFromThis());
if (getPositiveDeliveryNotificationRequired())
static_cast<ChatRoomPrivate *>(q->getChatRoom()->getPrivate())->sendDeliveryNotification(q->getSharedFromThis());
// Legacy.
AbstractChatRoomPrivate *dChatRoom = q->getChatRoom()->getPrivate();
dChatRoom->notifyChatMessageReceived(q->getSharedFromThis());
static_cast<ChatRoomPrivate *>(dChatRoom)->sendDeliveryNotification(q->getSharedFromThis());
}
LinphoneReason ChatMessagePrivate::receive () {
......@@ -497,14 +519,14 @@ LinphoneReason ChatMessagePrivate::receive () {
/* Unable to decrypt message */
chatRoom->getPrivate()->notifyUndecryptableChatMessageReceived(q->getSharedFromThis());
reason = linphone_error_code_to_reason(errorCode);
if (getNegativeDeliveryNotificationRequired()) {
static_cast<ChatRoomPrivate *>(q->getChatRoom()->getPrivate())->sendDeliveryErrorNotification(
q->getSharedFromThis(),
reason
);
}
static_cast<ChatRoomPrivate *>(q->getChatRoom()->getPrivate())->sendDeliveryErrorNotification(
q->getSharedFromThis(),
reason
);
return reason;
} else if (result == ChatMessageModifier::Result::Suspended) {
}
if (result == ChatMessageModifier::Result::Suspended) {
currentRecvStep |= ChatMessagePrivate::Step::Encryption;
return LinphoneReasonNone;
}
......@@ -576,7 +598,10 @@ LinphoneReason ChatMessagePrivate::receive () {
}
// Check if this is in fact an outgoing message (case where this is a message sent by us from an other device).
if (Address(chatRoom->getLocalAddress()).weakEqual(fromAddress))
if (
(chatRoom->getCapabilities() & ChatRoom::Capabilities::Conference) &&
Address(chatRoom->getLocalAddress()).weakEqual(fromAddress)
)
setDirection(ChatMessage::Direction::Outgoing);
// Check if this is a duplicate message.
......@@ -585,12 +610,10 @@ LinphoneReason ChatMessagePrivate::receive () {
if (errorCode > 0) {
reason = linphone_error_code_to_reason(errorCode);
if (getNegativeDeliveryNotificationRequired()) {
static_cast<ChatRoomPrivate *>(q->getChatRoom()->getPrivate())->sendDeliveryErrorNotification(
q->getSharedFromThis(),
reason
);
}
static_cast<ChatRoomPrivate *>(q->getChatRoom()->getPrivate())->sendDeliveryErrorNotification(
q->getSharedFromThis(),
reason
);
return reason;
}
......@@ -620,7 +643,8 @@ void ChatMessagePrivate::send () {
if (result == ChatMessageModifier::Result::Error) {
setState(ChatMessage::State::NotDelivered);
return;
} else if (result == ChatMessageModifier::Result::Suspended) {
}
if (result == ChatMessageModifier::Result::Suspended) {
setState(ChatMessage::State::InProgress);
return;
}
......
......@@ -35,7 +35,7 @@ private:
ImdnMessagePrivate (const ImdnMessage::Context &context)
: NotificationMessagePrivate(context.chatRoom, ChatMessage::Direction::Outgoing), context(context) {}
void setState (ChatMessage::State newState, bool force = false) override;
void setState (ChatMessage::State newState) override;
ImdnMessage::Context context;
......
......@@ -31,7 +31,7 @@ LINPHONE_BEGIN_NAMESPACE
// -----------------------------------------------------------------------------
void ImdnMessagePrivate::setState (ChatMessage::State newState, bool force) {
void ImdnMessagePrivate::setState (ChatMessage::State newState) {
L_Q();
if (newState == ChatMessage::State::Delivered) {
......
......@@ -35,7 +35,7 @@ protected:
NotificationMessagePrivate(const std::shared_ptr<AbstractChatRoom> &cr, ChatMessage::Direction dir)
: ChatMessagePrivate(cr, dir) {}
void setState (ChatMessage::State newState, bool force = false) override {};
void setState (ChatMessage::State newState) override {};
private:
void setDisplayNotificationRequired (bool value) override {}
......
......@@ -38,7 +38,7 @@ public:
virtual void setCreationTime (time_t creationTime) = 0;
virtual void setLastUpdateTime (time_t lastUpdateTime) = 0;
virtual void setState (AbstractChatRoom::State state) = 0;
virtual void setState (AbstractChatRoom::State newState) = 0;
virtual void sendChatMessage (const std::shared_ptr<ChatMessage> &chatMessage) = 0;
......
......@@ -47,7 +47,7 @@ public:
this->lastUpdateTime = lastUpdateTime;
}
void setState (ChatRoom::State state) override;
void setState (ChatRoom::State newState) override;
void sendChatMessage (const std::shared_ptr<ChatMessage> &chatMessage) override;
void sendIsComposingNotification ();
......@@ -67,10 +67,10 @@ public:
std::shared_ptr<IsComposingMessage> createIsComposingMessage ();
std::list<std::shared_ptr<ChatMessage>> findChatMessages (const std::string &messageId) const;
void sendDeliveryErrorNotification (const std::shared_ptr<ChatMessage> &message, LinphoneReason reason);
void sendDeliveryNotification (const std::shared_ptr<ChatMessage> &message);
void sendDeliveryErrorNotification (const std::shared_ptr<ChatMessage> &chatMessage, LinphoneReason reason);
void sendDeliveryNotification (const std::shared_ptr<ChatMessage> &chatMessage);
void sendDeliveryNotifications () override;
bool sendDisplayNotification (const std::shared_ptr<ChatMessage> &message);
void sendDisplayNotification (const std::shared_ptr<ChatMessage> &chatMessage);
void notifyChatMessageReceived (const std::shared_ptr<ChatMessage> &chatMessage) override;
void notifyIsComposingReceived (const Address &remoteAddress, bool isComposing);
......
......@@ -38,9 +38,9 @@ LINPHONE_BEGIN_NAMESPACE
// -----------------------------------------------------------------------------
void ChatRoomPrivate::setState (ChatRoom::State state) {
if (this->state != state) {
this->state = state;
void ChatRoomPrivate::setState (ChatRoom::State newState) {
if (state != newState) {
state = newState;
notifyStateChanged();
}
}
......@@ -139,38 +139,57 @@ list<shared_ptr<ChatMessage>> ChatRoomPrivate::findChatMessages (const string &m
// -----------------------------------------------------------------------------
void ChatRoomPrivate::sendDeliveryErrorNotification (const shared_ptr<ChatMessage> &message, LinphoneReason reason) {
L_Q();
LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(q->getCore()->getCCore());
if (linphone_im_notif_policy_get_send_imdn_delivered(policy))
imdnHandler->notifyDeliveryError(message, reason);
void ChatRoomPrivate::sendDeliveryErrorNotification (const shared_ptr<ChatMessage> &chatMessage, LinphoneReason reason) {
LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(chatMessage->getCore()->getCCore());
ChatMessagePrivate *dChatMessage = chatMessage->getPrivate();
if (
linphone_im_notif_policy_get_send_imdn_delivered(policy) &&
chatMessage->getPrivate()->getNegativeDeliveryNotificationRequired()
) {
dChatMessage->setNegativeDeliveryNotificationRequired(false);
imdnHandler->notifyDeliveryError(chatMessage, reason);
}
}
void ChatRoomPrivate::sendDeliveryNotification (const shared_ptr<ChatMessage> &message) {
L_Q();
LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(q->getCore()->getCCore());
if (linphone_im_notif_policy_get_send_imdn_delivered(policy))
imdnHandler->notifyDelivery(message);
void ChatRoomPrivate::sendDeliveryNotification (const shared_ptr<ChatMessage> &chatMessage) {
LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(chatMessage->getCore()->getCCore());
ChatMessagePrivate *dChatMessage = chatMessage->getPrivate();
if (
linphone_im_notif_policy_get_send_imdn_delivered(policy) &&
dChatMessage->getPositiveDeliveryNotificationRequired()
) {
dChatMessage->setPositiveDeliveryNotificationRequired(false);
imdnHandler->notifyDelivery(chatMessage);
}
}
void ChatRoomPrivate::sendDeliveryNotifications () {
L_Q();
LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(q->getCore()->getCCore());
if (linphone_im_notif_policy_get_send_imdn_delivered(policy)) {
auto messages = q->getCore()->getPrivate()->mainDb->findChatMessagesToBeNotifiedAsDelivered(q->getChatRoomId());
for (const auto message : messages)
imdnHandler->notifyDelivery(message);
auto chatMessages = q->getCore()->getPrivate()->mainDb->findChatMessagesToBeNotifiedAsDelivered(q->getChatRoomId());
for (const auto &chatMessage : chatMessages) {
ChatMessagePrivate *dChatMessage = chatMessage->getPrivate();
if (dChatMessage->getPositiveDeliveryNotificationRequired()) {
dChatMessage->setPositiveDeliveryNotificationRequired(false);
imdnHandler->notifyDelivery(chatMessage);
}
}
}
}
bool ChatRoomPrivate::sendDisplayNotification (const shared_ptr<ChatMessage> &message) {
void ChatRoomPrivate::sendDisplayNotification (const shared_ptr<ChatMessage> &chatMessage) {
L_Q();
LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(q->getCore()->getCCore());
if (linphone_im_notif_policy_get_send_imdn_displayed(policy)) {
imdnHandler->notifyDisplay(message);
return imdnHandler->aggregationEnabled();
ChatMessagePrivate *dChatMessage = chatMessage->getPrivate();
if (
linphone_im_notif_policy_get_send_imdn_displayed(policy) &&
chatMessage->getPrivate()->getDisplayNotificationRequired()
) {
dChatMessage->setPositiveDeliveryNotificationRequired(false);
dChatMessage->setDisplayNotificationRequired(false);
imdnHandler->notifyDisplay(chatMessage);
}
return false;
}
// -----------------------------------------------------------------------------
......@@ -429,11 +448,7 @@ int ChatRoom::getChatMessageCount () const {
}
int ChatRoom::getUnreadChatMessageCount () const {
L_D();
int dbUnreadCount = getCore()->getPrivate()->mainDb->getUnreadChatMessageCount(getChatRoomId());
int notifiedCount = d->imdnHandler->getDisplayNotificationCount();
L_ASSERT(dbUnreadCount >= notifiedCount);
return dbUnreadCount - notifiedCount;
return getCore()->getPrivate()->mainDb->getUnreadChatMessageCount(getChatRoomId());
}
// -----------------------------------------------------------------------------
......@@ -499,21 +514,11 @@ shared_ptr<ChatMessage> ChatRoom::findChatMessage (const string &messageId, Chat
void ChatRoom::markAsRead () {
L_D();
bool globallyMarkAsReadInDb = true;
CorePrivate *dCore = getCore()->getPrivate();
for (auto &chatMessage : dCore->mainDb->getUnreadChatMessages(d->chatRoomId)) {
// Do not send display notification for file transfer until it has been downloaded (it won't have a file transfer content anymore)
if (!chatMessage->getPrivate()->hasFileTransferContent()) {
bool doNotStoreInDb = d->sendDisplayNotification(chatMessage);
// Force the state so it is stored directly in DB, but when the IMDN has successfully been delivered
chatMessage->getPrivate()->setState(ChatMessage::State::Displayed, doNotStoreInDb);
if (doNotStoreInDb)
globallyMarkAsReadInDb = false;
}
}
for (auto &chatMessage : dCore->mainDb->getUnreadChatMessages(d->chatRoomId))
chatMessage->getPrivate()->setState(ChatMessage::State::Displayed);
if (globallyMarkAsReadInDb)
dCore->mainDb->markChatMessagesAsRead(d->chatRoomId);
dCore->mainDb->markChatMessagesAsRead(d->chatRoomId);
}
LINPHONE_END_NAMESPACE
......@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <algorithm>
#include "linphone/utils/algorithm.h"
#include "chat/chat-message/imdn-message-p.h"
#include "chat/chat-room/chat-room-p.h"
......@@ -47,24 +47,19 @@ Imdn::~Imdn () {
// -----------------------------------------------------------------------------
int Imdn::getDisplayNotificationCount () const {
return static_cast<int>(displayedMessages.size());
}
// -----------------------------------------------------------------------------
void Imdn::notifyDelivery (const shared_ptr<ChatMessage> &message) {
if (find(deliveredMessages.begin(), deliveredMessages.end(), message) == deliveredMessages.end()) {
if (find(deliveredMessages, message) == deliveredMessages.end()) {
deliveredMessages.push_back(message);
startTimer();
}
}
void Imdn::notifyDeliveryError (const shared_ptr<ChatMessage> &message, LinphoneReason reason) {
auto it = find_if(nonDeliveredMessages.begin(), nonDeliveredMessages.end(), [message](const MessageReason mr) {
return message == mr.message;
});
if (it == nonDeliveredMessages.end()) {
if (
findIf(nonDeliveredMessages, [message](const MessageReason &mr) {
return message == mr.message;
}) == nonDeliveredMessages.end()
) {
nonDeliveredMessages.emplace_back(message, reason);
startTimer();
}
......@@ -87,14 +82,18 @@ void Imdn::onImdnMessageDelivered (const std::shared_ptr<ImdnMessage> &message)
// If an IMDN has been successfully delivered, remove it from the list so that
// it does not get sent again
auto context = message->getPrivate()->getContext();
for (const auto &deliveredMsg : context.deliveredMessages)
deliveredMessages.remove(deliveredMsg);
for (const auto &chatMessage : context.deliveredMessages) {
chatMessage->getPrivate()->disableDeliveryNotificationRequiredInDatabase();
deliveredMessages.remove(chatMessage);
}
for (const auto &displayedMsg : context.displayedMessages)
displayedMessages.remove(displayedMsg);
for (const auto &chatMessage : context.displayedMessages) {
chatMessage->getPrivate()->disableDisplayNotificationRequiredInDatabase();
displayedMessages.remove(chatMessage);
}
for (const auto &nonDeliveredMsg : context.nonDeliveredMessages)
nonDeliveredMessages.remove(nonDeliveredMsg);
for (const auto &chatMessage : context.nonDeliveredMessages)
nonDeliveredMessages.remove(chatMessage);
sentImdnMessages.remove(message);
}
......
......@@ -57,8 +57,6 @@ public:
Imdn (ChatRoom *chatRoom);
~Imdn ();
int getDisplayNotificationCount () const;
void notifyDelivery (const std::shared_ptr<ChatMessage> &message);
void notifyDeliveryError (const std::shared_ptr<ChatMessage> &message, LinphoneReason reason);
void notifyDisplay (const std::shared_ptr<ChatMessage> &message);
......
......@@ -618,7 +618,7 @@ shared_ptr<EventLog> MainDbPrivate::selectConferenceChatMessageEvent (
// This is necessary if linphone has crashed while sending a message. It will set the correct state so the user can resend it.
if (messageState == ChatMessage::State::Idle || messageState == ChatMessage::State::InProgress)
messageState = ChatMessage::State::NotDelivered;
dChatMessage->setState(messageState, true);
dChatMessage->forceState(messageState);
dChatMessage->forceFromAddress(IdentityAddress(row.get<string>(3)));
dChatMessage->forceToAddress(IdentityAddress(row.get<string>(4)));
......@@ -2179,7 +2179,7 @@ list<shared_ptr<ChatMessage>> MainDb::findChatMessagesToBeNotifiedAsDelivered (
const ChatRoomId &chatRoomId
) const {
static const string query = Statements::get(Statements::SelectConferenceEvents) +
string(" AND direction = :direction AND state = :state AND delivery_notification_required <> 0");
string(" AND direction = :direction AND delivery_notification_required <> 0");
DurationLogger durationLogger(
"Find chat messages to be notified as delivered: (peer=" + chatRoomId.getPeerAddress().asString() +
......@@ -2195,10 +2195,9 @@ list<shared_ptr<ChatMessage>> MainDb::findChatMessagesToBeNotifiedAsDelivered (
return chatMessages;
const long long &dbChatRoomId = d->selectChatRoomId(chatRoomId);
const int &state = int(ChatMessage::State::Delivered);
const int &direction = int(ChatMessage::Direction::Incoming);
soci::rowset<soci::row> rows = (
d->dbSession.getBackendSession()->prepare << query, soci::use(dbChatRoomId), soci::use(direction), soci::use(state)
d->dbSession.getBackendSession()->prepare << query, soci::use(dbChatRoomId), soci::use(direction)
);
for (const auto &row : rows) {
shared_ptr<EventLog> event = d->selectGenericConferenceEvent(chatRoom, row);
......@@ -2289,6 +2288,36 @@ int MainDb::getHistorySize (const ChatRoomId &chatRoomId, FilterMask mask) const
};
}
void MainDb::cleanHistory (const ChatRoomId &chatRoomId, FilterMask mask) {
const string query = "SELECT event_id FROM conference_event WHERE chat_room_id = :chatRoomId" +
buildSqlEventFilter({
ConferenceCallFilter, ConferenceChatMessageFilter, ConferenceInfoFilter, ConferenceInfoNoDeviceFilter
}, mask);
DurationLogger durationLogger(
"Clean history of: (peer=" + chatRoomId.getPeerAddress().asString() +
", local=" + chatRoomId.getLocalAddress().asString() +
", mask=" + Utils::toString(mask) + ")."
);
L_DB_TRANSACTION {
L_D();
const long long &dbChatRoomId = d->selectChatRoomId(chatRoomId);
d->invalidConferenceEventsFromQuery(query, dbChatRoomId);
*d->dbSession.getBackendSession() << "DELETE FROM event WHERE id IN (" + query + ")", soci::use(dbChatRoomId);
tr.commit();
if (!mask || (mask & ConferenceChatMessageFilter))
d->unreadChatMessageCountCache.insert(chatRoomId, 0);
};
}
// -----------------------------------------------------------------------------
template<typename T>
static void fetchContentAppData (soci::session *session, Content &content, long long contentId, T &data) {
static const string query = "SELECT name, data FROM chat_message_content_app_data"
......@@ -2365,30 +2394,30 @@ void MainDb::loadChatMessageContents (const shared_ptr<ChatMessage> &chatMessage
};
}
void MainDb::cleanHistory (const ChatRoomId &chatRoomId, FilterMask mask) {
const string query = "SELECT event_id FROM conference_event WHERE chat_room_id = :chatRoomId" +
buildSqlEventFilter({
ConferenceCallFilter, ConferenceChatMessageFilter, ConferenceInfoFilter, ConferenceInfoNoDeviceFilter
}, mask);
// -----------------------------------------------------------------------------
DurationLogger durationLogger(
"Clean history of: (peer=" + chatRoomId.getPeerAddress().asString() +
", local=" + chatRoomId.getLocalAddress().asString() +
", mask=" + Utils::toString(mask) + ")."
);
void MainDb::disableDeliveryNotificationRequired (const std::shared_ptr<const EventLog> &eventLog) {
shared_ptr<ChatMessage> chatMessage(static_pointer_cast<const ConferenceChatMessageEvent>(eventLog)->getChatMessage());
const long long &eventId = static_cast<MainDbKey &>(eventLog->getPrivate()->dbKey).getPrivate()->storageId;
L_DB_TRANSACTION {
L_D();
*d->dbSession.getBackendSession() << "UPDATE conference_chat_message_event SET delivery_notification_required = 0"
" WHERE event_id = :eventId", soci::use(eventId);
tr.commit();
};
}
const long long &dbChatRoomId = d->selectChatRoomId(chatRoomId);
d->invalidConferenceEventsFromQuery(query, dbChatRoomId);
*d->dbSession.getBackendSession() << "DELETE FROM event WHERE id IN (" + query + ")", soci::use(dbChatRoomId);
void MainDb::disableDisplayNotificationRequired (const std::shared_ptr<const EventLog> &eventLog) {
shared_ptr<ChatMessage> chatMessage(static_pointer_cast<const ConferenceChatMessageEvent>(eventLog)->getChatMessage());
const long long &eventId = static_cast<MainDbKey &>(eventLog->getPrivate()->dbKey).getPrivate()->storageId;
L_DB_TRANSACTION {
L_D();
*d->dbSession.getBackendSession() << "UPDATE conference_chat_message_event"
" SET delivery_notification_required = 0, display_notification_required = 0"
" WHERE event_id = :eventId", soci::use(eventId);
tr.commit();
if (!mask || (mask & ConferenceChatMessageFilter))
d->unreadChatMessageCountCache.insert(chatRoomId, 0);
};
}
......
......@@ -156,6 +156,9 @@ public:
void loadChatMessageContents (const std::shared_ptr<ChatMessage> &chatMessage);
void disableDeliveryNotificationRequired (const std::shared_ptr<const EventLog> &eventLog);
void disableDisplayNotificationRequired (const std::shared_ptr<const EventLog> &eventLog);
// ---------------------------------------------------------------------------
// Chat rooms.
// ---------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment