// // ChatMessageModel.h // AIIM // // Created by qitewei on 2025/5/14. // #import #import NS_ASSUME_NONNULL_BEGIN typedef enum : NSUInteger { FileUploadCompleted = 0, FileUploading = 1, FileUploadFail = 2, } FileUploadStatus; typedef NS_ENUM(NSUInteger, ChatMessageType) { ChatMessageTypeText=0, // 文字 ChatMessageTypeImage=1, // 图片 ChatMessageTypeFile=2, // 文件 ChatMessageTypeVoice=3, // 语音 ChatMessageTypeCallBack=4, // 撤回 ChatMessageTypeVideo=5, // 视频 ChatMessageTypeHistory=6, // 聊天记录 ChatMessageTypeCall=7, // 通话记录 ChatMessageTypeEvent = 9, //事件消息 ChatMessageTypeCallBack2 = 11, // 撤回2 ChatMessageTypeDel = 12, // 删除 ChatMessageTypeDFBUSY = 13,// 对方正在忙 }; @interface ChatMessageModel : NSObject @property (nonatomic, assign, readonly) FileUploadStatus fileUploadStatus; @property (nonatomic, assign) ChatMessageType messageType; @property (nonatomic, assign) NSInteger type; //0=友聊 1=群聊 @property (nonatomic, assign) BOOL isSender; // 是否是发送方 // 通用属性 @property (nonatomic, copy) NSString * msgId; @property (nonatomic, copy) NSString * fromId; @property (nonatomic, copy) NSString * chatId; @property (nonatomic, copy) NSString *content; @property (nonatomic, strong) UIImage *placeholderImage; @property (nonatomic, assign) NSInteger timestamp; @property (nonatomic, assign) NSInteger localtime; @property (nonatomic, copy) NSString * formatterTime; @property (nonatomic, copy) NSString * avatar; @property (nonatomic, copy) NSString * nickName; // 已读状态 @property (nonatomic, copy) NSString * readStatus; //引用消息 @property (nonatomic,strong) ChatMessageModel * quoteMessage; // 文件属性 @property (nonatomic, copy) NSString * url; @property (nonatomic, copy) NSString * localurl; @property (nonatomic, copy) NSString *fileName; @property (nonatomic, assign) CGSize mediaSize; @property (nonatomic, copy) NSString *fileSize; @property (nonatomic, strong) UIImage *videoThumbnailImage; // 生成的缩略图缓存 @property (nonatomic, assign) NSInteger voiceDuration; @property (nonatomic, assign) CGFloat voiceWidth; @property (nonatomic, assign) NSInteger fileError;//0 = 成功 1 = 失败 @property (nonatomic, copy, nullable) NSString *customFileSize; // 通话记录属性 @property (nonatomic, assign) NSInteger callDuration; @property (nonatomic, assign) BOOL isCallSuccess; ///是否是视频通话 @property (nonatomic, assign) BOOL isVideo; //@相关 @property (nonatomic, assign) BOOL atAll; @property (nonatomic, copy) NSArray * atUserIds; // 高度缓存 @property (nonatomic, assign) CGFloat cellHeight; @property (nonatomic, assign) CGSize textLayoutSize; //合并转发 @property (nonatomic, strong) NSArray * forwardMsgArray; @property (nonatomic, copy) NSDictionary * formerMessage; @property (nonatomic, assign, readonly) BOOL isUploadFile; @property (nonatomic, assign) CGFloat uploadProgress; /// 是否发送成功 @property (nonatomic, assign, readonly) BOOL isSent; // 从字典初始化方法 + (instancetype)modelWithDictionary:(NSDictionary *)dict; // 从字典设置属性方法 - (void)setupWithDictionary:(NSDictionary *)dict; // 从模型设置属性方法 - (void)exchangeModelWithModel:(ChatMessageModel *)model; // 生成缩略图的方法,同时判断是否开始下载视频 - (void)generateThumbnailWithCompletion:(void(^)(UIImage *thumbnail))completion; //下载文件保存本地 -(void)downloadFileIfNeed:(void(^)(NSInteger persent))loading; - (BOOL)checkIsSendFail; - (void)updateFileStatusToUploading; @end NS_ASSUME_NONNULL_END