ChatMessageModel.h 3.7 KB

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