ChatMessageModel.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. @interface ChatMessageModel : NSObject
  25. @property (nonatomic, assign) ChatMessageType messageType;
  26. @property (nonatomic, assign) NSInteger type; //0=友聊 1=群聊
  27. @property (nonatomic, assign) BOOL isSender; // 是否是发送方
  28. // 通用属性
  29. @property (nonatomic, copy) NSString * msgId;
  30. @property (nonatomic, copy) NSString * fromId;
  31. @property (nonatomic, copy) NSString * chatId;
  32. @property (nonatomic, copy) NSString *content;
  33. @property (nonatomic, strong) UIImage *placeholderImage;
  34. @property (nonatomic, assign) NSInteger timestamp;
  35. @property (nonatomic, assign) NSInteger localtime;
  36. @property (nonatomic, copy) NSString * formatterTime;
  37. @property (nonatomic, copy) NSString * avatar;
  38. @property (nonatomic, copy) NSString * nickName;
  39. // 已读状态
  40. @property (nonatomic, copy) NSString * readStatus;
  41. //引用消息
  42. @property (nonatomic,strong) ChatMessageModel * quoteMessage;
  43. // 文件属性
  44. @property (nonatomic, copy) NSString * url;
  45. @property (nonatomic, copy) NSString * localurl;
  46. @property (nonatomic, copy) NSString *fileName;
  47. @property (nonatomic, assign) CGSize mediaSize;
  48. @property (nonatomic, copy) NSString *fileSize;
  49. @property (nonatomic, strong) UIImage *videoThumbnailImage; // 生成的缩略图缓存
  50. @property (nonatomic, assign) NSInteger voiceDuration;
  51. @property (nonatomic, assign) CGFloat voiceWidth;
  52. @property (nonatomic, assign) NSInteger fileError;//0 = 成功 1 = 失败
  53. @property (nonatomic, copy, nullable) NSString *customFileSize;
  54. // 通话记录属性
  55. @property (nonatomic, assign) NSInteger callDuration;
  56. @property (nonatomic, assign) BOOL isCallSuccess;
  57. ///是否是视频通话
  58. @property (nonatomic, assign) BOOL isVideo;
  59. //@相关
  60. @property (nonatomic, assign) BOOL atAll;
  61. @property (nonatomic, copy) NSArray * atUserIds;
  62. // 高度缓存
  63. @property (nonatomic, assign) CGFloat cellHeight;
  64. @property (nonatomic, assign) CGSize textLayoutSize;
  65. //合并转发
  66. @property (nonatomic, strong) NSArray * forwardMsgArray;
  67. @property (nonatomic, copy) NSDictionary * formerMessage;
  68. @property (nonatomic, assign, readonly) BOOL isUploadFile;
  69. @property (nonatomic, assign) CGFloat uploadProgress;
  70. /// 是否发送成功
  71. @property (nonatomic, assign, readonly) BOOL isSent;
  72. // 从字典初始化方法
  73. + (instancetype)modelWithDictionary:(NSDictionary *)dict;
  74. // 从字典设置属性方法
  75. - (void)setupWithDictionary:(NSDictionary *)dict;
  76. // 从模型设置属性方法
  77. - (void)exchangeModelWithModel:(ChatMessageModel *)model;
  78. // 生成缩略图的方法,同时判断是否开始下载视频
  79. - (void)generateThumbnailWithCompletion:(void(^)(UIImage *thumbnail))completion;
  80. //下载文件保存本地
  81. -(void)downloadFileIfNeed:(void(^)(NSInteger persent))loading;
  82. - (BOOL)checkIsSendFail;
  83. @end
  84. NS_ASSUME_NONNULL_END