fix index issue in data base

This commit is contained in:
Benjamin Reis 2017-11-27 11:55:51 +01:00
parent a6b6b7aeb4
commit 81ff3c8813
3 changed files with 10 additions and 10 deletions

View file

@ -218,7 +218,10 @@ bctbx_list_t *linphone_chat_room_get_history_range_events (LinphoneChatRoom *cr,
} }
LinphoneChatMessage *linphone_chat_room_get_last_message_in_history(LinphoneChatRoom *cr) { LinphoneChatMessage *linphone_chat_room_get_last_message_in_history(LinphoneChatRoom *cr) {
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getLastMessageInHistory()); shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getLastMessageInHistory();
LinphoneChatMessage *object = L_INIT(ChatMessage);
L_SET_CPP_PTR_FROM_C_OBJECT(object, cppPtr);
return object;
} }
LinphoneChatMessage *linphone_chat_room_find_message (LinphoneChatRoom *cr, const char *message_id) { LinphoneChatMessage *linphone_chat_room_find_message (LinphoneChatRoom *cr, const char *message_id) {

View file

@ -1393,17 +1393,14 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
shared_ptr<ChatMessage> MainDb::getLastChatMessage (const ChatRoomId &chatRoomId) const { shared_ptr<ChatMessage> MainDb::getLastChatMessage (const ChatRoomId &chatRoomId) const {
list<shared_ptr<EventLog>> chatList = getHistory(chatRoomId, 1, Filter::ConferenceChatMessageFilter); list<shared_ptr<EventLog>> chatList = getHistory(chatRoomId, 1, Filter::ConferenceChatMessageFilter);
if (chatList.size() == 0) if (chatList.empty())
return nullptr; return nullptr;
L_ASSERT(chatList.size() == 1); return static_pointer_cast<ConferenceChatMessageEvent>(chatList.front())->getChatMessage();
shared_ptr<EventLog> chatEvent = chatList.front();
L_ASSERT(chatEvent->getType() == EventLog::Type::ConferenceChatMessage);
return static_pointer_cast<ConferenceChatMessageEvent>(chatEvent)->getChatMessage();
} }
list<shared_ptr<EventLog>> MainDb::getHistory (const ChatRoomId &chatRoomId, int nLast, FilterMask mask) const { list<shared_ptr<EventLog>> MainDb::getHistory (const ChatRoomId &chatRoomId, int nLast, FilterMask mask) const {
return getHistoryRange(chatRoomId, 0, nLast - 1, mask); return getHistoryRange(chatRoomId, 0, nLast, mask);
} }
list<shared_ptr<EventLog>> MainDb::getHistoryRange ( list<shared_ptr<EventLog>> MainDb::getHistoryRange (