TIMComm+FriendshipExt.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. //
  2. // TIMComm+FriendshipExt.h
  3. // IMFriendshipExt
  4. //
  5. // Created by tomzhu on 2017/1/19.
  6. //
  7. //
  8. #ifndef TIMComm_FriendshipExt_h
  9. #define TIMComm_FriendshipExt_h
  10. #import <ImSDK/ImSDK.h>
  11. @class TIMFriendMetaInfo;
  12. @class TIMFriendPendencyMeta;
  13. @class TIMFriendFutureMeta;
  14. #pragma mark - 枚举类型
  15. /**
  16. * 好友操作状态
  17. */
  18. typedef NS_ENUM(NSInteger, TIMFriendStatus) {
  19. /**
  20. * 操作成功
  21. */
  22. TIM_FRIEND_STATUS_SUCC = 0,
  23. /**
  24. * 加好友时有效:被加好友在自己的黑名单中
  25. */
  26. TIM_ADD_FRIEND_STATUS_IN_SELF_BLACK_LIST = 30515,
  27. /**
  28. * 加好友时有效:被加好友设置为禁止加好友
  29. */
  30. TIM_ADD_FRIEND_STATUS_FRIEND_SIDE_FORBID_ADD = 30516,
  31. /**
  32. * 加好友时有效:好友数量已满
  33. */
  34. TIM_ADD_FRIEND_STATUS_SELF_FRIEND_FULL = 30519,
  35. /**
  36. * 加好友时有效:已经是好友
  37. */
  38. TIM_ADD_FRIEND_STATUS_ALREADY_FRIEND = 30520,
  39. /**
  40. * 加好友时有效:已被被添加好友设置为黑名单
  41. */
  42. TIM_ADD_FRIEND_STATUS_IN_OTHER_SIDE_BLACK_LIST = 30525,
  43. /**
  44. * 加好友时有效:对方好友列表已满
  45. */
  46. TIM_ADD_FRIEND_STATUS_OTHER_SIDE_FRIEND_LIST_FULL = 30535,
  47. /**
  48. * 加好友时有效:等待好友审核同意
  49. */
  50. TIM_ADD_FRIEND_STATUS_PENDING = 30539,
  51. /**
  52. * 删除好友时有效:删除好友时对方不是好友
  53. */
  54. TIM_DEL_FRIEND_STATUS_NO_FRIEND = 31704,
  55. /**
  56. * 响应好友申请时有效:对方没有申请过好友
  57. */
  58. TIM_RESPONSE_FRIEND_STATUS_NO_REQ = 30614,
  59. /**
  60. * 响应好友申请时有效:自己的好友满
  61. */
  62. TIM_RESPONSE_FRIEND_STATUS_SELF_FRIEND_FULL = 30615,
  63. /**
  64. * 响应好友申请时有效:好友已经存在
  65. */
  66. TIM_RESPONSE_FRIEND_STATUS_FRIEND_EXIST = 30617,
  67. /**
  68. * 响应好友申请时有效:对方好友满
  69. */
  70. TIM_RESPONSE_FRIEND_STATUS_OTHER_SIDE_FRIEND_FULL = 30630,
  71. /**
  72. * 添加黑名单有效:已经在黑名单了
  73. */
  74. TIM_ADD_BLACKLIST_FRIEND_STATUS_IN_BLACK_LIST = 31307,
  75. /**
  76. * 删除黑名单有效:用户不在黑名单里
  77. */
  78. TIM_DEL_BLACKLIST_FRIEND_STATUS_NOT_IN_BLACK_LIST = 31503,
  79. /**
  80. * 创建好友分组时有效:没有拉到SDKAppId
  81. */
  82. TIM_ADD_FRIEND_GROUP_STATUS_GET_SDKAPPID_FAILED = 32207,
  83. /**
  84. * 创建好友分组时有效:要加入到好友分组中的用户不是好友
  85. */
  86. TIM_ADD_FRIEND_GROUP_STATUS_NOT_FRIEND = 32216,
  87. /**
  88. * 更新好友分组时有效:没有拉到SDKAppId
  89. */
  90. TIM_UPDATE_FRIEND_GROUP_STATUS_GET_SDKAPPID_FAILED = 32511,
  91. /**
  92. * 更新好友分组时有效:要加入到好友分组中的用户不是好友
  93. */
  94. TIM_UPDATE_FRIEND_GROUP_STATUS_ADD_NOT_FRIEND = 32518,
  95. /**
  96. * 更新好友分组时有效:要加入到好友分组中的好友已经在分组中
  97. */
  98. TIM_UPDATE_FRIEND_GROUP_STATUS_ADD_ALREADY_IN_GROUP = 32519,
  99. /**
  100. * 更新好友分组时有效:要从好友分组中删除的好友不在好友分组中
  101. */
  102. TIM_UPDATE_FRIEND_GROUP_STATUS_DEL_NOT_IN_GROUP = 32520,
  103. /**
  104. * 更新好友分组时有效:该好友加入的好友分组个数超过了限制,每个好友最多只能加入32个好友分组
  105. */
  106. TIM_UPDATE_FRIEND_GROUP_STATUS_MAX_GROUPS_EXCEED = 32521,
  107. };
  108. typedef NS_ENUM(NSInteger, TIMDelFriendType) {
  109. /**
  110. * 删除单向好友
  111. */
  112. TIM_FRIEND_DEL_SINGLE = 1,
  113. /**
  114. * 删除双向好友
  115. */
  116. TIM_FRIEND_DEL_BOTH = 2,
  117. };
  118. typedef NS_ENUM(NSInteger, TIMPendencyGetType) {
  119. /**
  120. * 别人发给我的
  121. */
  122. TIM_PENDENCY_GET_COME_IN = 1,
  123. /**
  124. * 我发给别人的
  125. */
  126. TIM_PENDENCY_GET_SEND_OUT = 2,
  127. /**
  128. * 别人发给我的 和 我发给别人的
  129. */
  130. TIM_PENDENCY_GET_BOTH = 3,
  131. };
  132. /**
  133. * 推荐好友类型
  134. */
  135. typedef NS_ENUM(NSInteger, TIMFutureFriendType) {
  136. /**
  137. * 收到的未决请求
  138. */
  139. TIM_FUTURE_FRIEND_PENDENCY_IN_TYPE = 0x1,
  140. /**
  141. * 发出去的未决请求
  142. */
  143. TIM_FUTURE_FRIEND_PENDENCY_OUT_TYPE = 0x2,
  144. /**
  145. * 推荐好友
  146. */
  147. TIM_FUTURE_FRIEND_RECOMMEND_TYPE = 0x4,
  148. /**
  149. * 已决好友
  150. */
  151. TIM_FUTURE_FRIEND_DECIDE_TYPE = 0x8,
  152. };
  153. /**
  154. * 翻页选项
  155. */
  156. typedef NS_ENUM(NSInteger, TIMPageDirectionType) {
  157. /**
  158. * 向上翻页
  159. */
  160. TIM_PAGE_DIRECTION_UP_TYPE = 1,
  161. /**
  162. * 向下翻页
  163. */
  164. TIM_PAGE_DIRECTION_DOWN_TYPE = 2,
  165. };
  166. /**
  167. * 好友检查类型
  168. */
  169. typedef NS_ENUM(NSInteger,TIMFriendCheckType) {
  170. /**
  171. * 单向好友
  172. */
  173. TIM_FRIEND_CHECK_TYPE_UNIDIRECTION = 0x1,
  174. /**
  175. * 互为好友
  176. */
  177. TIM_FRIEND_CHECK_TYPE_BIDIRECTION = 0x2,
  178. };
  179. /**
  180. * 好友关系类型
  181. */
  182. typedef NS_ENUM(NSInteger,TIMFriendRelationType) {
  183. /**
  184. * 不是好友
  185. */
  186. TIM_FRIEND_RELATION_TYPE_NONE = 0x0,
  187. /**
  188. * 对方在我的好友列表中
  189. */
  190. TIM_FRIEND_RELATION_TYPE_MY_UNI = 0x1,
  191. /**
  192. * 我在对方的好友列表中
  193. */
  194. TIM_FRIEND_RELATION_TYPE_OTHER_UNI = 0x2,
  195. /**
  196. * 互为好友
  197. */
  198. TIM_FRIEND_RELATION_TYPE_BOTH = 0x3,
  199. };
  200. typedef NS_ENUM(NSInteger, TIMFriendResponseType) {
  201. /**
  202. * 同意加好友(建立单向好友)
  203. */
  204. TIM_FRIEND_RESPONSE_AGREE = 0,
  205. /**
  206. * 同意加好友并加对方为好友(建立双向好友)
  207. */
  208. TIM_FRIEND_RESPONSE_AGREE_AND_ADD = 1,
  209. /**
  210. * 拒绝对方好友请求
  211. */
  212. TIM_FRIEND_RESPONSE_REJECT = 2,
  213. };
  214. #pragma mark - block回调
  215. /**
  216. * 获取好友列表回调
  217. *
  218. * @param meta 好友元信息
  219. * @param friends 好友列表 TIMUserProfile* 数组,只包含需要的字段
  220. */
  221. typedef void (^TIMGetFriendListByPageSucc)(TIMFriendMetaInfo * meta, NSArray * friends);
  222. /**
  223. * 获取未决请求列表成功
  224. *
  225. * @param meta 未决请求元信息
  226. * @param pendencies 未决请求列表(TIMFriendPendencyItem*)数组
  227. */
  228. typedef void (^TIMGetFriendPendencyListSucc)(TIMFriendPendencyMeta * meta, NSArray * pendencies);
  229. /**
  230. * 获取推荐好友和未决列表成功
  231. *
  232. * @param meta 下次拉取时填入信息
  233. * @param items 列表(TIMFriendFutureItem*)数组
  234. */
  235. typedef void (^TIMGetFriendFutureListSucc)(TIMFriendFutureMeta * meta, NSArray * items);
  236. /**
  237. * 群搜索回调
  238. *
  239. * @param totalNum 搜索结果的总数
  240. * @param users 请求的用户列表片段
  241. */
  242. typedef void (^TIMUserSearchSucc)(uint64_t totalNum, NSArray * users);
  243. /**
  244. * 好友分组列表
  245. *
  246. * @param arr 好友分组(TIMFriendGroup*)列表
  247. */
  248. typedef void (^TIMFriendGroupSucc)(NSArray * arr);
  249. /**
  250. * 好友关系检查回调
  251. *
  252. * @param results TIMCheckFriendResult列表
  253. */
  254. typedef void (^TIMFriendCheckSucc)(NSArray* results);
  255. #pragma mark - 基本类型
  256. /**
  257. * 加好友请求
  258. */
  259. @interface TIMAddFriendRequest : TIMCodingModel
  260. /**
  261. * 用户identifier
  262. */
  263. @property(nonatomic,strong) NSString* identifier;
  264. /**
  265. * 用户备注(备注最大96字节)
  266. */
  267. @property(nonatomic,strong) NSString* remark;
  268. /**
  269. * 请求说明(最大120字节)
  270. */
  271. @property(nonatomic,strong) NSString* addWording;
  272. /**
  273. * 添加来源
  274. */
  275. @property(nonatomic,strong) NSString* addSource;
  276. /**
  277. * 预分组名
  278. */
  279. @property(nonatomic,strong) NSString* friendGroup;
  280. @end
  281. /**
  282. * 未决请求
  283. */
  284. @interface TIMFriendPendencyItem : TIMCodingModel
  285. /**
  286. * 用户标识
  287. */
  288. @property(nonatomic,strong) NSString* identifier;
  289. /**
  290. * 增加时间
  291. */
  292. @property(nonatomic,assign) uint64_t addTime;
  293. /**
  294. * 来源
  295. */
  296. @property(nonatomic,strong) NSString* addSource;
  297. /**
  298. * 加好友附言
  299. */
  300. @property(nonatomic,strong) NSString* addWording;
  301. /**
  302. * 加好友昵称
  303. */
  304. @property(nonatomic,strong) NSString* nickname;
  305. /**
  306. * 未决请求类型
  307. */
  308. @property(nonatomic,assign) TIMPendencyGetType type;
  309. @end
  310. /**
  311. * 未决请求元信息
  312. */
  313. @interface TIMFriendPendencyMeta : TIMCodingModel
  314. /**
  315. * 序列号,未决列表序列号
  316. * 建议客户端保存seq和未决列表,请求时填入server返回的seq
  317. * 如果seq是server最新的,则不返回数据
  318. */
  319. @property(nonatomic,assign) uint64_t seq;
  320. /**
  321. * 翻页时间戳,只用来翻页,server返回0时表示没有更多数据,第一次请求填0
  322. * 特别注意的是,如果server返回的seq跟填入的seq不同,翻页过程中,需要使用客户端原始seq请求,直到数据请求完毕,才能更新本地seq
  323. */
  324. @property(nonatomic,assign) uint64_t timestamp;
  325. /**
  326. * 每页的数量,请求时有效(建议值,server可根据需要返回或多或少,不能作为完成与否的标志)
  327. */
  328. @property(nonatomic,assign) uint64_t numPerPage;
  329. /**
  330. * 未决请求未读数量(仅在server返回时有效)
  331. */
  332. @property(nonatomic,assign) uint64_t unReadCnt;
  333. @end
  334. /**
  335. * 推荐好友元信息
  336. */
  337. @interface TIMFriendFutureMeta : TIMCodingModel
  338. /**
  339. * 翻页类型
  340. */
  341. @property(nonatomic,assign) TIMPageDirectionType directionType;
  342. /**
  343. * 获取数量
  344. */
  345. @property(nonatomic,assign) uint64_t reqNum;
  346. /**
  347. * 时间戳:只做分页之用,第一次请求填0,分页时下次请求传入返回的时间戳,直到返回的时间戳为0,表示数据已经拉完,此时更新pendencySeq和recommendSeq(分页过程中不能更新pendencySeq和recommendSeq)
  348. */
  349. @property(nonatomic,assign) uint64_t timestamp;
  350. /**
  351. * 未决序列号
  352. */
  353. @property(nonatomic,assign) uint64_t pendencySeq;
  354. /**
  355. * 推荐序列号
  356. */
  357. @property(nonatomic,assign) uint64_t recommendSeq;
  358. /**
  359. * 已决序列号
  360. */
  361. @property(nonatomic,assign) uint64_t decideSeq;
  362. /**
  363. * 未决未读数量
  364. */
  365. @property(nonatomic,assign) uint64_t pendencyUnReadCnt;
  366. /**
  367. * 推荐未读数量
  368. */
  369. @property(nonatomic,assign) uint64_t recommendUnReadCnt;
  370. /**
  371. * 已决未读数量
  372. */
  373. @property(nonatomic,assign) uint64_t decideUnReadCnt;
  374. /**
  375. * 未决最新时间戳
  376. */
  377. @property(nonatomic,assign) uint64_t currentPendencyTimestamp;
  378. /**
  379. * 推荐最新时间戳
  380. */
  381. @property(nonatomic,assign) uint64_t currentRecommendTimestamp;
  382. /**
  383. * 已决最新时间戳
  384. */
  385. @property(nonatomic,assign) uint64_t currentDecideTimestamp;
  386. @end
  387. /**
  388. * 好友元信息
  389. */
  390. @interface TIMFriendMetaInfo : TIMCodingModel
  391. /**
  392. * 时间戳,需要保存,下次拉取时传入,增量更新使用
  393. */
  394. @property(nonatomic,assign) uint64_t timestamp;
  395. /**
  396. * 序列号,需要保存,下次拉取时传入,增量更新使用
  397. */
  398. @property(nonatomic,assign) uint64_t infoSeq;
  399. /**
  400. * 分页信息,无需保存,返回为0时结束,非0时传入再次拉取,第一次拉取时传0
  401. */
  402. @property(nonatomic,assign) uint64_t nextSeq;
  403. /**
  404. * 覆盖:为TRUE时需要重设timestamp, infoSeq, nextSeq为0,清除客户端存储,重新拉取资料
  405. */
  406. @property(nonatomic,assign) BOOL recover;
  407. @end
  408. /**
  409. * 好友分组信息
  410. */
  411. @interface TIMFriendGroup : TIMCodingModel
  412. /**
  413. * 好友分组名称
  414. */
  415. @property(nonatomic,strong) NSString* name;
  416. /**
  417. * 分组成员数量
  418. */
  419. @property(nonatomic,assign) uint64_t userCnt;
  420. /**
  421. * 分组成员identifier列表
  422. */
  423. @property(nonatomic,strong) NSArray* friends;
  424. @end
  425. /**
  426. * 好友关系检查
  427. */
  428. @interface TIMFriendCheckInfo : NSObject
  429. /**
  430. * 检查用户的id列表(NSString*)
  431. */
  432. @property(nonatomic,strong) NSArray* users;
  433. /**
  434. * 检查类型
  435. */
  436. @property(nonatomic,assign) TIMFriendCheckType checkType;
  437. @end
  438. @interface TIMCheckFriendResult : NSObject
  439. /**
  440. * 用户id
  441. */
  442. @property(nonatomic,strong) NSString* identifier;
  443. /**
  444. * 返回状态
  445. */
  446. @property(nonatomic,assign) TIMFriendStatus status;
  447. /**
  448. * 检查结果
  449. */
  450. @property(nonatomic,assign) TIMFriendRelationType resultType;
  451. @end
  452. @interface TIMFriendResult : NSObject
  453. /**
  454. * 用户Id
  455. */
  456. @property(nonatomic,strong) NSString* identifier;
  457. /**
  458. * 返回状态
  459. */
  460. @property(nonatomic,assign) TIMFriendStatus status;
  461. @end
  462. @interface TIMFriendResponse : NSObject
  463. /**
  464. * 响应类型
  465. */
  466. @property(nonatomic,assign) TIMFriendResponseType responseType;
  467. /**
  468. * 用户identifier
  469. */
  470. @property(nonatomic,strong) NSString* identifier;
  471. /**
  472. * (可选)如果要加对方为好友,表示备注,其他type无效,备注最大96字节
  473. */
  474. @property(nonatomic,strong) NSString* remark;
  475. @end
  476. /**
  477. * 推荐好友
  478. */
  479. @interface TIMFriendFutureItem : TIMCodingModel
  480. /**
  481. * 推荐好友类型
  482. */
  483. @property(nonatomic,assign) TIMFutureFriendType type;
  484. /**
  485. * 好友标识
  486. */
  487. @property(nonatomic,strong) NSString* identifier;
  488. /**
  489. * 好友资料
  490. */
  491. @property(nonatomic,strong) TIMUserProfile* profile;
  492. /**
  493. * 添加时间
  494. */
  495. @property(nonatomic,assign) uint64_t addTime;
  496. /**
  497. * 来源(仅未决好友有效)
  498. */
  499. @property(nonatomic,strong) NSString* addSource;
  500. /**
  501. * 加好友附言(仅未决好友有效)
  502. */
  503. @property(nonatomic,strong) NSString* addWording;
  504. /**
  505. * 推荐理由(server端写入,仅推荐好友有效)
  506. */
  507. @property(nonatomic,strong) NSDictionary* recommendTags;
  508. @end
  509. /**
  510. * 好友分组信息扩展
  511. */
  512. @interface TIMFriendGroupWithProfiles : TIMFriendGroup
  513. /**
  514. * 好友资料(TIMUserProfile*)列表
  515. */
  516. @property(nonatomic,strong) NSArray* profiles;
  517. @end
  518. #endif /* TIMComm_FriendshipExt_h */