floo2
bmx_conversation.h
1 //-------------------------------------------------------------------------------------------------
2 // File : bmx_conversation.h
3 // Author : Eric Liang <eric@bmxlabs.com>
4 // Purpose : bmx conversation define file.
5 // Created : 12 Nov 2018 by Eric Liang <eric@bmxlabs.com>
6 //-------------------------------------------------------------------------------------------------
7 //
8 // Copyright (C) 2018-2019 MaxIM.Top
9 //
10 // You may obtain a copy of the licence at http://www.maxim.top/LICENCE-MAXIM.md
11 //
12 //-------------------------------------------------------------------------------------------------
13 
14 #ifndef bmx_conversation_h__
15 #define bmx_conversation_h__
16 
17 #include "bmx_base_object.h"
18 #include "bmx_message.h"
19 #include "bmx_result_page.h"
20 #include "bmx_error.h"
21 
22 namespace floo {
23 
24 typedef BMXResultPage<std::shared_ptr<BMXMessage>> BMXMessagePage;
25 
30 public:
34  enum class Type {
36  Single,
38  Group,
40  System,
41  };
42 
46  enum class Direction {
48  Up,
50  Down
51  };
52 
56  virtual ~BMXConversation() {}
57 
62  virtual int64_t conversationId() = 0;
63 
68  virtual Type type() = 0;
69 
74  virtual BMXMessagePtr lastMsg() = 0;
75 
80  virtual int32_t unreadNumber() = 0;
81 
86  virtual int32_t messageCount() = 0;
87 
92  virtual bool isMuteNotification() = 0;
93 
98  virtual const JSON& extension() = 0;
99 
105  virtual BMXErrorCode setExtension(const std::string& ext) = 0;
106 
111  virtual const std::string& editMessage() = 0;
112 
118  virtual BMXErrorCode setEditMessage(const std::string& editMessage) = 0;
119 
126  virtual BMXErrorCode setMessagePlayedStatus(BMXMessagePtr msg, bool status) = 0;
127 
134  virtual BMXErrorCode setMessageReadStatus(BMXMessagePtr msg, bool status) = 0;
135 
140  virtual BMXErrorCode setAllMessagesRead() = 0;
141 
147  virtual BMXErrorCode updateMessageExtension(BMXMessagePtr msg) = 0;
148 
154  virtual BMXErrorCode insertMessage(BMXMessagePtr msg) = 0;
155 
161  virtual BMXMessagePtr loadMessage(int64_t msgId) = 0;
162 
167  virtual BMXErrorCode removeAllMessages() = 0;
168 
177  virtual BMXErrorCode loadMessages(int64_t refMsgId, size_t size, BMXMessageList& result, Direction = Direction::Up) = 0;
178 
188  virtual BMXErrorCode searchMessagesByKeyWords(const std::string& keywords, int64_t refTime, size_t size, BMXMessageList& result, Direction = Direction::Up) = 0;
189 
200  virtual BMXErrorCode searchMessages(const std::string& keywords, int64_t refTime, size_t size, BMXMessageList& result, Direction = Direction::Up) = 0;
201 
211  virtual BMXErrorCode searchMessagesByType(BMXMessage::ContentType type, int64_t refTime, size_t size, BMXMessageList& result, Direction = Direction::Up) = 0;
212 
223  virtual BMXErrorCode searchMessages(BMXMessage::ContentType type, int64_t refTime, size_t size, BMXMessageList& result, Direction = Direction::Up) = 0;
224 
229  virtual BMXErrorCode refreshConversation() = 0;
230 
231 protected:
232  BMXConversation() {}
233 
234 private:
235  BMXConversation(const BMXConversation&);
236  BMXConversation& operator=(const BMXConversation&);
237 };
238 
239 typedef std::shared_ptr<BMXConversation> BMXConversationPtr;
240 typedef std::vector<BMXConversationPtr> BMXConversationList;
241 }
242 
243 #endif /* bmx_conversation_h__ */
virtual BMXErrorCode removeAllMessages()=0
删除会话中的所有消息
virtual BMXErrorCode setMessagePlayedStatus(BMXMessagePtr msg, bool status)=0
设置消息播放状态(只对语音/视频消息有效)
virtual BMXErrorCode setMessageReadStatus(BMXMessagePtr msg, bool status)=0
设置消息未读状态,更新未读消息数
virtual ~BMXConversation()
析构函数
Definition: bmx_conversation.h:56
virtual Type type()=0
会话类型
virtual const JSON & extension()=0
扩展信息
virtual BMXErrorCode searchMessagesByType(BMXMessage::ContentType type, int64_t refTime, size_t size, BMXMessageList &result, Direction=Direction::Up)=0
按照类型搜索消息,如果不指定则从最新消息开始
virtual BMXErrorCode setAllMessagesRead()=0
把所有消息设置为已读,更新未读消息数
Type
会话类型
Definition: bmx_conversation.h:34
virtual int32_t unreadNumber()=0
未读消息数
virtual BMXErrorCode updateMessageExtension(BMXMessagePtr msg)=0
更新一条数据库存储消息的扩展字段信息
virtual BMXErrorCode loadMessages(int64_t refMsgId, size_t size, BMXMessageList &result, Direction=Direction::Up)=0
加载消息,如果不指定则从最新消息开始
virtual BMXErrorCode setEditMessage(const std::string &editMessage)=0
设置编辑消息
virtual BMXErrorCode refreshConversation()=0
读取数据库当前会话所有消息数量,强制更新conversation的消息总数和未读消息数。
virtual int32_t messageCount()=0
会话中所有消息的数量
virtual const std::string & editMessage()=0
编辑消息
virtual BMXErrorCode setExtension(const std::string &ext)=0
设置扩展信息
Direction
消息搜索方向
Definition: bmx_conversation.h:46
ContentType
消息内容类型
Definition: bmx_message.h:67
virtual BMXErrorCode searchMessagesByKeyWords(const std::string &keywords, int64_t refTime, size_t size, BMXMessageList &result, Direction=Direction::Up)=0
搜索消息,如果不指定则从最新消息开始
virtual BMXErrorCode insertMessage(BMXMessagePtr msg)=0
插入一条消息
virtual BMXMessagePtr loadMessage(int64_t msgId)=0
读取一条消息
virtual BMXErrorCode searchMessages(const std::string &keywords, int64_t refTime, size_t size, BMXMessageList &result, Direction=Direction::Up)=0
搜索消息,如果不指定则从最新消息开始
Definition: bmx_base_object.h:26
virtual int64_t conversationId()=0
会话Id
会话
Definition: bmx_conversation.h:29
virtual BMXMessagePtr lastMsg()=0
最新消息
virtual bool isMuteNotification()=0
是否提醒用户消息,不提醒的情况下会话总未读数不会统计该会话计数。