NIMMessageSearchOption.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. //
  2. // NIMMessageSearchOption.h
  3. // NIMLib
  4. //
  5. // Created by Netease.
  6. // Copyright (c) 2015 Netease. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "NIMGlobalDefs.h"
  10. NS_ASSUME_NONNULL_BEGIN
  11. @class NIMMessage;
  12. /**
  13. * 搜索顺序
  14. */
  15. typedef NS_ENUM(NSInteger,NIMMessageSearchOrder) {
  16. /**
  17. * 从新消息往旧消息查询
  18. */
  19. NIMMessageSearchOrderDesc = 0,
  20. /**
  21. * 从旧消息往新消息查询
  22. */
  23. NIMMessageSearchOrderAsc = 1,
  24. };
  25. /**
  26. * 本地搜索选项
  27. * @discussion 搜索条件: 时间在(startTime,endTime) 内(不包含),类型为 messageTypes (或全类型) ,且匹配 searchContent 或 fromIds 的一定数量 (limit) 消息
  28. */
  29. @interface NIMMessageSearchOption : NSObject
  30. /**
  31. * 起始时间,默认为0
  32. */
  33. @property (nonatomic,assign) NSTimeInterval startTime;
  34. /**
  35. * 结束时间,默认为0
  36. * @discussion 搜索的结束时间,0 表示最大时间戳
  37. */
  38. @property (nonatomic,assign) NSTimeInterval endTime;
  39. /**
  40. * 检索条数
  41. * @discussion 默认100条,设置为0表示无条数限制
  42. */
  43. @property (nonatomic,assign) NSUInteger limit;
  44. /**
  45. * 检索顺序
  46. */
  47. @property (nonatomic,assign) NIMMessageSearchOrder order;
  48. /**
  49. * 查询的消息类型
  50. * @discusssion 消息类型组合,默认只搜索文本类型, 只有在 allMessageTypes 为 NO 时有效,取值范围为: NIMMessageType 枚举类型
  51. */
  52. @property (nonatomic,copy) NSArray<NSNumber *> *messageTypes;
  53. /**
  54. * 全部消息类型
  55. * @discussion 默认为 NO
  56. */
  57. @property (nonatomic,assign) BOOL allMessageTypes;
  58. /**
  59. * 检索文本
  60. */
  61. @property (nullable,nonatomic,copy) NSString *searchContent;
  62. /**
  63. * 消息发出者帐号列表
  64. */
  65. @property (nullable,nonatomic,copy) NSArray<NSString *> *fromIds;
  66. /**
  67. * 将搜索文本中的正则特殊字符转义,默认 YES
  68. */
  69. @property (nonatomic,assign) BOOL enableContentTransfer;
  70. @end
  71. /**
  72. * 检索服务器历史消息选项 (服务器)
  73. */
  74. @interface NIMHistoryMessageSearchOption : NSObject
  75. /**
  76. * 检索消息起始时间
  77. * @discussion 需要检索的起始时间,没有则传入0。
  78. */
  79. @property (nonatomic,assign) NSTimeInterval startTime;
  80. /**
  81. * 检索条数
  82. * @discussion 最大限制100条
  83. */
  84. @property (nonatomic,assign) NSUInteger limit;
  85. /**
  86. * 检索消息终止时间,此参数对聊天室会话无效。
  87. * @discussion 当前最早的时间,没有则传入 0。
  88. */
  89. @property (nonatomic,assign) NSTimeInterval endTime;
  90. /**
  91. * 检索消息的当前参考消息,返回的消息结果集里不会包含这条消息,此参数对聊天室会话无效。
  92. * @discussion 传入最早时间,没有则传入nil。
  93. */
  94. @property (nullable,nonatomic,strong) NIMMessage *currentMessage;
  95. /**
  96. * 检索顺序。
  97. */
  98. @property (nonatomic,assign) NIMMessageSearchOrder order;
  99. /**
  100. * 是否需要同步到 db,此参数对聊天室会话无效。
  101. * @discussion SDK 删除消息分为两种模式:标记删除和彻底删除(参见 NIMDeleteMessagesOption)。
  102. * 若消息集在本地被标记删除,则意味着消息仍存在本地,但被打上了特殊的记号,同步后写入 db 会失败。
  103. * 只有不存在本地的消息才可以通过 sync 标记进行 db 存储
  104. */
  105. @property (nonatomic,assign) BOOL sync;
  106. /**
  107. * 查询的消息类型
  108. * @discusssion 消息类型组合,默认为 nil ,搜索全类型。一旦设置了这个字段,则 sync 字段失效,查询结果不会写入 db,需要通过设置syncMessageTypes来同步 。
  109. */
  110. @property (nonatomic,copy) NSArray<NSNumber *> *messageTypes;
  111. /**
  112. * 是否需要同步特定类型到 db,此参数对聊天室会话无效。
  113. * @discussion SDK 删除消息分为两种模式:标记删除和彻底删除(参见 NIMDeleteMessagesOption)。
  114. * 若消息集在本地被标记删除,则意味着消息仍存在本地,但被打上了特殊的记号,同步后写入 db 会失败。
  115. * 只有不存在本地的消息才可以通过 syncMessageTypes 标记进行 db 存储
  116. */
  117. @property (nonatomic,assign) BOOL syncMessageTypes;
  118. @end
  119. /**
  120. * 服务端消息关键字检索选项
  121. * @discussion 搜索条件: 时间在(startTime,endTime) 内(不包含),类型为 messageTypes (或全类型) ,且匹配 searchContent 或 fromIds 的一定数量 (limit) 消息
  122. */
  123. @interface NIMMessageServerRetrieveOption : NSObject
  124. /**
  125. * 起始时间,默认为0
  126. */
  127. @property (nonatomic,assign) NSTimeInterval startTime;
  128. /**
  129. * 结束时间,默认为0
  130. * @discussion 搜索的结束时间,0 表示最大时间戳
  131. */
  132. @property (nonatomic,assign) NSTimeInterval endTime;
  133. /**
  134. * 检索条数
  135. * @discussion 默认100条,设置为0表示无条数限制,最多100条
  136. */
  137. @property (nonatomic,assign) NSUInteger limit;
  138. /**
  139. * 检索顺序
  140. */
  141. @property (nonatomic,assign) NIMMessageSearchOrder order;
  142. /**
  143. * 关键字
  144. */
  145. @property (nullable,nonatomic,copy) NSString *keyword;
  146. @end
  147. NS_ASSUME_NONNULL_END