ChatMessageModel.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //
  2. // ChatMessageModel.h
  3. // AIIM
  4. //
  5. // Created by qitewei on 2025/5/14.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #import <UIKit/UIKit.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. typedef NS_ENUM(NSUInteger, ChatMessageType) {
  11. ChatMessageTypeText=0, // 文字
  12. ChatMessageTypeImage=1, // 图片
  13. ChatMessageTypeFile=2, // 文件
  14. ChatMessageTypeVoice=3, // 语音
  15. ChatMessageTypeCallBack=4, // 撤回
  16. ChatMessageTypeVideo=5, // 视频
  17. ChatMessageTypeHistory=6, // 聊天记录
  18. ChatMessageTypeCall=7, // 通话记录
  19. ChatMessageTypeEvent = 9, //事件消息
  20. ChatMessageTypeCallBack2 = 11, // 撤回2
  21. ChatMessageTypeDel = 12, // 删除
  22. ChatMessageTypeDFBUSY = 13,// 对方正在忙
  23. };
  24. /// 消息状态
  25. typedef NS_ENUM(NSInteger, MessageSendStatus){
  26. MessageSending = 0, ///< 消息发送中
  27. MessageSent = 1, ///< 消息发送成功
  28. MessageSendFail = 2, ///< 消息发送失败
  29. };
  30. @interface ChatMessageModel : NSObject
  31. @property (nonatomic, assign) MessageSendStatus messageSendStatus;
  32. @property (nonatomic, assign) ChatMessageType messageType;
  33. @property (nonatomic, assign) NSInteger type; //0=友聊 1=群聊
  34. @property (nonatomic, assign) BOOL isSender; // 是否是发送方
  35. // 通用属性
  36. @property (nonatomic, copy) NSString * msgId;
  37. @property (nonatomic, copy) NSString * fromId;
  38. @property (nonatomic, copy) NSString * chatId;
  39. @property (nonatomic, copy) NSString *content;
  40. @property (nonatomic, strong) UIImage *placeholderImage;
  41. @property (nonatomic, assign) NSInteger timestamp;
  42. @property (nonatomic, assign) NSInteger localtime;
  43. @property (nonatomic, copy) NSString * formatterTime;
  44. @property (nonatomic, copy) NSString * avatar;
  45. @property (nonatomic, copy) NSString * nickName;
  46. // 已读状态
  47. @property (nonatomic, copy) NSString * readStatus;
  48. @property (nonatomic, assign) NSInteger readstate;
  49. //引用消息
  50. @property (nonatomic,strong) ChatMessageModel * quoteMessage;
  51. // 文件属性
  52. @property (nonatomic, copy) NSString * url;
  53. @property (nonatomic, copy) NSString * localurl;
  54. @property (nonatomic, copy) NSString *fileName;
  55. @property (nonatomic, assign) CGSize mediaSize;
  56. @property (nonatomic, copy) NSString *fileSize;
  57. @property (nonatomic, strong) UIImage *videoThumbnailImage; // 生成的缩略图缓存
  58. @property (nonatomic, assign) NSInteger voiceDuration;
  59. @property (nonatomic, assign) CGFloat voiceWidth;
  60. @property (nonatomic, assign) NSInteger fileError;//0 = 成功 1 = 失败
  61. @property (nonatomic, copy, nullable) NSString *customFileSize;
  62. // 通话记录属性
  63. @property (nonatomic, assign) NSInteger callDuration;
  64. @property (nonatomic, assign) BOOL isCallSuccess;
  65. ///是否是视频通话
  66. @property (nonatomic, assign) BOOL isVideo;
  67. //@相关
  68. @property (nonatomic, assign) BOOL atAll;
  69. @property (nonatomic, copy) NSArray * atUserIds;
  70. // 高度缓存
  71. @property (nonatomic, assign) CGFloat cellHeight;
  72. @property (nonatomic, assign) CGSize textLayoutSize;
  73. //合并转发
  74. @property (nonatomic, strong) NSArray * forwardMsgArray;
  75. @property (nonatomic, copy) NSDictionary * formerMessage;
  76. @property (nonatomic, assign, readonly) BOOL isUploadFile;
  77. // 从字典初始化方法
  78. + (instancetype)modelWithDictionary:(NSDictionary *)dict;
  79. // 从字典设置属性方法
  80. - (void)setupWithDictionary:(NSDictionary *)dict;
  81. // 从模型设置属性方法
  82. - (void)exchangeModelWithModel:(ChatMessageModel *)model;
  83. // 更新消息状态到 plist
  84. - (void)updateMessageStatus:(MessageSendStatus)status;
  85. // 从 plist 刷新消息状态
  86. - (void)refreshMessageStatus;
  87. // 生成缩略图的方法,同时判断是否开始下载视频
  88. - (void)generateThumbnailWithCompletion:(void(^)(UIImage *thumbnail))completion;
  89. //下载文件保存本地
  90. -(void)downloadFileIfNeed:(void(^)(NSInteger persent))loading;
  91. //上传文件
  92. @property (nonatomic,copy) void(^uploadPersentChange)(NSInteger index,NSInteger localtime);
  93. -(void)setuploadPersent:(NSInteger)persent localtime:(NSInteger)localtime;
  94. @end
  95. NS_ASSUME_NONNULL_END