UNPKG

@asteriskzuo/react-native-easemob

Version:
970 lines (753 loc) 30.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChatDownloadStatus = exports.ChatCustomMessageBody = exports.ChatCmdMessageBody = void 0; exports.ChatDownloadStatusFromNumber = ChatDownloadStatusFromNumber; exports.ChatDownloadStatusToString = ChatDownloadStatusToString; exports.ChatFileMessageBody = void 0; exports.ChatGroupPermissionTypeToString = ChatGroupPermissionTypeToString; exports.ChatMessageBodyType = exports.ChatMessageBody = exports.ChatMessage = exports.ChatLocationMessageBody = exports.ChatImageMessageBody = void 0; exports.ChatMessageBodyTypeFromString = ChatMessageBodyTypeFromString; exports.ChatMessageChatType = void 0; exports.ChatMessageChatTypeFromNumber = ChatMessageChatTypeFromNumber; exports.ChatMessageDirection = void 0; exports.ChatMessageDirectionFromString = ChatMessageDirectionFromString; exports.ChatMessageStatus = void 0; exports.ChatMessageStatusFromNumber = ChatMessageStatusFromNumber; exports.ChatMessageStatusToString = ChatMessageStatusToString; exports.ChatVoiceMessageBody = exports.ChatVideoMessageBody = exports.ChatTextMessageBody = void 0; var _Utils = require("../_internal/Utils"); var _ChatClient = require("../ChatClient"); function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /** * The conversation types. */ let ChatMessageChatType; /** * The enumeration of the message MessageDirection. */ exports.ChatMessageChatType = ChatMessageChatType; (function (ChatMessageChatType) { ChatMessageChatType[ChatMessageChatType["PeerChat"] = 0] = "PeerChat"; ChatMessageChatType[ChatMessageChatType["GroupChat"] = 1] = "GroupChat"; ChatMessageChatType[ChatMessageChatType["ChatRoom"] = 2] = "ChatRoom"; })(ChatMessageChatType || (exports.ChatMessageChatType = ChatMessageChatType = {})); let ChatMessageDirection; /** * The enumeration of the message sending/reception status. * * The states include success, failure, being sent/being received, and created to be sent. */ exports.ChatMessageDirection = ChatMessageDirection; (function (ChatMessageDirection) { ChatMessageDirection["SEND"] = "send"; ChatMessageDirection["RECEIVE"] = "rec"; })(ChatMessageDirection || (exports.ChatMessageDirection = ChatMessageDirection = {})); let ChatMessageStatus; /** * The download status of the attachment file . */ exports.ChatMessageStatus = ChatMessageStatus; (function (ChatMessageStatus) { ChatMessageStatus[ChatMessageStatus["CREATE"] = 0] = "CREATE"; ChatMessageStatus[ChatMessageStatus["PROGRESS"] = 1] = "PROGRESS"; ChatMessageStatus[ChatMessageStatus["SUCCESS"] = 2] = "SUCCESS"; ChatMessageStatus[ChatMessageStatus["FAIL"] = 3] = "FAIL"; })(ChatMessageStatus || (exports.ChatMessageStatus = ChatMessageStatus = {})); let ChatDownloadStatus; /** * The enumeration of the message type. */ exports.ChatDownloadStatus = ChatDownloadStatus; (function (ChatDownloadStatus) { ChatDownloadStatus[ChatDownloadStatus["PENDING"] = -1] = "PENDING"; ChatDownloadStatus[ChatDownloadStatus["DOWNLOADING"] = 0] = "DOWNLOADING"; ChatDownloadStatus[ChatDownloadStatus["SUCCESS"] = 1] = "SUCCESS"; ChatDownloadStatus[ChatDownloadStatus["FAILED"] = 2] = "FAILED"; })(ChatDownloadStatus || (exports.ChatDownloadStatus = ChatDownloadStatus = {})); let ChatMessageBodyType; exports.ChatMessageBodyType = ChatMessageBodyType; (function (ChatMessageBodyType) { ChatMessageBodyType["TXT"] = "txt"; ChatMessageBodyType["IMAGE"] = "img"; ChatMessageBodyType["VIDEO"] = "video"; ChatMessageBodyType["LOCATION"] = "loc"; ChatMessageBodyType["VOICE"] = "voice"; ChatMessageBodyType["FILE"] = "file"; ChatMessageBodyType["CMD"] = "cmd"; ChatMessageBodyType["CUSTOM"] = "custom"; })(ChatMessageBodyType || (exports.ChatMessageBodyType = ChatMessageBodyType = {})); function ChatMessageChatTypeFromNumber(params) { switch (params) { case 2: return ChatMessageChatType.ChatRoom; case 1: return ChatMessageChatType.GroupChat; default: return ChatMessageChatType.PeerChat; } } function ChatGroupPermissionTypeToString(params) { return ChatMessageChatType[params]; } function ChatMessageDirectionFromString(params) { switch (params) { case 'send': return ChatMessageDirection.SEND; default: return ChatMessageDirection.RECEIVE; } } function ChatMessageStatusFromNumber(params) { switch (params) { case 3: return ChatMessageStatus.FAIL; case 2: return ChatMessageStatus.SUCCESS; case 1: return ChatMessageStatus.PROGRESS; default: return ChatMessageStatus.CREATE; } } function ChatMessageStatusToString(params) { return ChatMessageStatus[params]; } function ChatDownloadStatusFromNumber(params) { switch (params) { case 0: return ChatDownloadStatus.DOWNLOADING; case 1: return ChatDownloadStatus.SUCCESS; case 2: return ChatDownloadStatus.FAILED; default: return ChatDownloadStatus.PENDING; } } function ChatDownloadStatusToString(params) { return ChatDownloadStatus[params]; } function ChatMessageBodyTypeFromString(params) { switch (params) { case 'txt': return ChatMessageBodyType.TXT; case 'loc': return ChatMessageBodyType.LOCATION; case 'cmd': return ChatMessageBodyType.CMD; case 'custom': return ChatMessageBodyType.CUSTOM; case 'file': return ChatMessageBodyType.FILE; case 'img': return ChatMessageBodyType.IMAGE; case 'video': return ChatMessageBodyType.VIDEO; case 'voice': return ChatMessageBodyType.VOICE; default: throw new Error(`not exist this type: ${params}`); } } /** * Message status listener. */ /** * The message instance, which represents a sent/received message. * * For example: * * Constructs a text message to send: * * ```typescript * let msg = ChatMessage.createTextMessage( * 'asteriskhx2', * Date.now().toString(), * ChatMessageChatType.PeerChat * ); * ``` */ class ChatMessage { /** * Gets the message ID. */ /** * Gets the local message ID. */ /** * The conversation ID. */ /** * The user ID of the message sender. */ /** * The user ID of the message recipient. */ /** * The local timestamp of the message. */ /** * The server timestamp of the message. */ /** * The delivery receipt, which is to check whether the other party has received the message. * * Whether the other party has received the message. * `true`:the message has been delivered to the other party. */ /** * Whether the message has been read. * * Whether the other party has read the message. * `true`: The message has been read by the other party. */ /** * Sets whether read receipts are required for group messages. * * `true`: Read receipts are required; * `false`: Read receipts are NOT required. */ /** * Gets the number of members that have read the group message. */ /** * Checks whether the message is read. * * `true`: The message is read. * `false`: The message is unread. */ /** * The enumeration of the chat type. * * There are three chat types: one-to-one chat, group chat, and chat room. */ /** * The message direction. see {@link ChatMessageDirection} */ /** * Gets the message sending/reception status. see {@link ChatMessageStatus} */ /** * Message's extension attribute. */ /** * Message body. We recommend you use {@link ChatMessageBody)}. */ constructor(params) { var _params$msgId, _params$conversationI, _params$from, _params$to, _params$localTime, _params$serverTime, _params$hasDeliverAck, _params$hasReadAck, _params$needGroupAck, _params$groupAckCount, _params$hasRead, _params$chatType, _params$direction, _params$status, _params$attributes; _defineProperty(this, "msgId", (0, _Utils.generateMessageId)()); _defineProperty(this, "localMsgId", ''); _defineProperty(this, "conversationId", ''); _defineProperty(this, "from", ''); _defineProperty(this, "to", ''); _defineProperty(this, "localTime", (0, _Utils.getNowTimestamp)()); _defineProperty(this, "serverTime", (0, _Utils.getNowTimestamp)()); _defineProperty(this, "hasDeliverAck", false); _defineProperty(this, "hasReadAck", false); _defineProperty(this, "needGroupAck", false); _defineProperty(this, "groupAckCount", 0); _defineProperty(this, "hasRead", false); _defineProperty(this, "chatType", ChatMessageChatType.ChatRoom); _defineProperty(this, "direction", ChatMessageDirection.SEND); _defineProperty(this, "status", ChatMessageStatus.CREATE); _defineProperty(this, "attributes", {}); _defineProperty(this, "body", void 0); this.msgId = (_params$msgId = params.msgId) !== null && _params$msgId !== void 0 ? _params$msgId : (0, _Utils.generateMessageId)(); this.conversationId = (_params$conversationI = params.conversationId) !== null && _params$conversationI !== void 0 ? _params$conversationI : ''; this.from = (_params$from = params.from) !== null && _params$from !== void 0 ? _params$from : ''; this.to = (_params$to = params.to) !== null && _params$to !== void 0 ? _params$to : ''; this.localTime = (_params$localTime = params.localTime) !== null && _params$localTime !== void 0 ? _params$localTime : (0, _Utils.getNowTimestamp)(); this.serverTime = (_params$serverTime = params.serverTime) !== null && _params$serverTime !== void 0 ? _params$serverTime : (0, _Utils.getNowTimestamp)(); this.hasDeliverAck = (_params$hasDeliverAck = params.hasDeliverAck) !== null && _params$hasDeliverAck !== void 0 ? _params$hasDeliverAck : false; this.hasReadAck = (_params$hasReadAck = params.hasReadAck) !== null && _params$hasReadAck !== void 0 ? _params$hasReadAck : false; this.needGroupAck = (_params$needGroupAck = params.needGroupAck) !== null && _params$needGroupAck !== void 0 ? _params$needGroupAck : false; this.groupAckCount = (_params$groupAckCount = params.groupAckCount) !== null && _params$groupAckCount !== void 0 ? _params$groupAckCount : 0; this.hasRead = (_params$hasRead = params.hasRead) !== null && _params$hasRead !== void 0 ? _params$hasRead : false; this.chatType = ChatMessageChatTypeFromNumber((_params$chatType = params.chatType) !== null && _params$chatType !== void 0 ? _params$chatType : 0); this.direction = ChatMessageDirectionFromString((_params$direction = params.direction) !== null && _params$direction !== void 0 ? _params$direction : 'send'); this.status = ChatMessageStatusFromNumber((_params$status = params.status) !== null && _params$status !== void 0 ? _params$status : 0); this.attributes = (_params$attributes = params.attributes) !== null && _params$attributes !== void 0 ? _params$attributes : {}; this.body = ChatMessage.getBody(params.body); this.localMsgId = this.localTime.toString(); } static getBody(params) { let type = ChatMessageBodyTypeFromString(params.type); switch (type) { case ChatMessageBodyType.TXT: return new ChatTextMessageBody(params); case ChatMessageBodyType.LOCATION: return new ChatLocationMessageBody(params); case ChatMessageBodyType.CMD: return new ChatCmdMessageBody(params); case ChatMessageBodyType.CUSTOM: return new ChatCustomMessageBody(params); case ChatMessageBodyType.FILE: return new ChatFileMessageBody(params); case ChatMessageBodyType.IMAGE: return new ChatImageMessageBody(params); case ChatMessageBodyType.VIDEO: return new ChatVideoMessageBody(params); case ChatMessageBodyType.VOICE: return new ChatVoiceMessageBody(params); default: throw new Error(`not exist this type: ${type}`); } } static createSendMessage(body, targetId, chatType) { var _ChatClient$getInstan; let r = new ChatMessage({ from: (_ChatClient$getInstan = _ChatClient.ChatClient.getInstance().currentUserName) !== null && _ChatClient$getInstan !== void 0 ? _ChatClient$getInstan : '', body: body, direction: 'send', to: targetId, hasRead: true, chatType: chatType }); return r; } /** * Creates a text message for sending. * * @param targetId The ID of the message recipient(user or group). * @param content The text content. * @param chatType The Conversation type. * @returns The message instance. */ static createTextMessage(targetId, content) { let chatType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ChatMessageChatType.PeerChat; let s = ChatMessageBodyType.TXT.valueOf(); return ChatMessage.createSendMessage(new ChatTextMessageBody({ type: s, content: content }), targetId, chatType); } /** * Creates a file message for sending. * * @param targetId The ID of the message recipient(user or group). * @param filePath The file path. * @param chatType The Conversation type. * @param opt The file name. like 'readme.doc' * @returns The message instance. */ static createFileMessage(targetId, filePath) { var _opt$displayName; let chatType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ChatMessageChatType.PeerChat; let opt = arguments.length > 3 ? arguments[3] : undefined; return ChatMessage.createSendMessage(new ChatFileMessageBody({ type: ChatMessageBodyType.FILE.valueOf(), localPath: filePath, displayName: (_opt$displayName = opt === null || opt === void 0 ? void 0 : opt.displayName) !== null && _opt$displayName !== void 0 ? _opt$displayName : '' }), targetId, chatType); } /** * Creates a image message for sending. * * @param targetId The ID of the message recipient(user or group). * @param filePath The image path. * @param chatType The Conversation type. * @param opt * @{#displayName} The image name. like 'image.jpeg' * @{#thumbnailLocalPath} The image thumbnail path. * @{#sendOriginalImage} Whether to send the original image. * `true`: Send the original image. * `false`: (default) For an image greater than 100 KB, the SDK will compress it. * @{#width} The image width. * @{#height} The image height. * @returns The message instance. */ static createImageMessage(targetId, filePath) { var _opt$displayName2, _opt$sendOriginalImag; let chatType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ChatMessageChatType.PeerChat; let opt = arguments.length > 3 ? arguments[3] : undefined; return ChatMessage.createSendMessage(new ChatImageMessageBody({ type: ChatMessageBodyType.IMAGE.valueOf(), localPath: filePath, displayName: (_opt$displayName2 = opt === null || opt === void 0 ? void 0 : opt.displayName) !== null && _opt$displayName2 !== void 0 ? _opt$displayName2 : filePath, thumbnailLocalPath: opt === null || opt === void 0 ? void 0 : opt.thumbnailLocalPath, sendOriginalImage: (_opt$sendOriginalImag = opt === null || opt === void 0 ? void 0 : opt.sendOriginalImage) !== null && _opt$sendOriginalImag !== void 0 ? _opt$sendOriginalImag : false, width: opt === null || opt === void 0 ? void 0 : opt.width, height: opt === null || opt === void 0 ? void 0 : opt.height }), targetId, chatType); } /** * Creates a video message for sending. * * @param targetId The ID of the message recipient(user or group). * @param filePath The path of the video file. * @param chatType The Conversation type. * @param opt * @{#displayName} The video name. like 'video.mp4' * @{#thumbnailLocalPath} The path of the thumbnail of the first frame of video. * @{#duration} The video duration in seconds. * @{#width} The video thumbnail image width. * @{#height} The video thumbnail image height. * @returns The message instance. */ static createVideoMessage(targetId, filePath) { var _opt$displayName3; let chatType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ChatMessageChatType.PeerChat; let opt = arguments.length > 3 ? arguments[3] : undefined; return ChatMessage.createSendMessage(new ChatVideoMessageBody({ type: ChatMessageBodyType.VIDEO.valueOf(), localPath: filePath, displayName: (_opt$displayName3 = opt === null || opt === void 0 ? void 0 : opt.displayName) !== null && _opt$displayName3 !== void 0 ? _opt$displayName3 : '', thumbnailLocalPath: opt === null || opt === void 0 ? void 0 : opt.thumbnailLocalPath, duration: opt === null || opt === void 0 ? void 0 : opt.duration, width: opt === null || opt === void 0 ? void 0 : opt.width, height: opt === null || opt === void 0 ? void 0 : opt.height }), targetId, chatType); } /** * Creates a video message for sending. * * @param targetId The ID of the message recipient(user or group). * @param filePath The path of the voice file. * @param chatType The Conversation type. * @param opt * @{#displayName} The voice name. like 'voice.mp3' * @{#duration} The voice duration in seconds. * @returns The message instance. */ static createVoiceMessage(targetId, filePath) { var _opt$displayName4; let chatType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ChatMessageChatType.PeerChat; let opt = arguments.length > 3 ? arguments[3] : undefined; return ChatMessage.createSendMessage(new ChatVoiceMessageBody({ type: ChatMessageBodyType.VOICE.valueOf(), localPath: filePath, displayName: (_opt$displayName4 = opt === null || opt === void 0 ? void 0 : opt.displayName) !== null && _opt$displayName4 !== void 0 ? _opt$displayName4 : '', duration: opt === null || opt === void 0 ? void 0 : opt.duration }), targetId, chatType); } /** * Creates a location message for sending. * * @param targetId The ID of the message recipient(user or group). * @param latitude The latitude. * @param longitude The longitude. * @param chatType The Conversation type. * @param opt * @{#address} Place names. like `beijing`. * @returns The message instance. */ static createLocationMessage(targetId, latitude, longitude) { var _opt$address; let chatType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ChatMessageChatType.PeerChat; let opt = arguments.length > 4 ? arguments[4] : undefined; return ChatMessage.createSendMessage(new ChatLocationMessageBody({ type: ChatMessageBodyType.LOCATION.valueOf(), latitude: latitude, longitude: longitude, address: (_opt$address = opt === null || opt === void 0 ? void 0 : opt.address) !== null && _opt$address !== void 0 ? _opt$address : '' }), targetId, chatType); } /** * Creates a cmd message for sending. * * @param targetId The ID of the message recipient(user or group). * @param action Action behavior. * @param chatType The Conversation type. * @returns The message instance. */ static createCmdMessage(targetId, action) { let chatType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ChatMessageChatType.PeerChat; return ChatMessage.createSendMessage(new ChatCmdMessageBody({ action: action }), targetId, chatType); } /** * Creates a custom message for sending. * * @param targetId The ID of the message recipient(user or group). * @param event * @param chatType The Conversation type. * @param opt * @{#params} Custom parameters. Key/value pair. It can be nested. * @returns The message instance. */ static createCustomMessage(targetId, event) { let chatType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ChatMessageChatType.PeerChat; let opt = arguments.length > 3 ? arguments[3] : undefined; return ChatMessage.createSendMessage(new ChatCustomMessageBody({ event: event, params: opt === null || opt === void 0 ? void 0 : opt.params }), targetId, chatType); } static createReceiveMessage(params) { return new ChatMessage(params); } } /** * The content part of the message. * * The base class for the concrete message type. */ exports.ChatMessage = ChatMessage; _defineProperty(ChatMessage, "TAG", 'ChatMessage'); class ChatMessageBody { /** * Message type. see {@link ChatMessageBodyType} */ constructor(type) { _defineProperty(this, "type", void 0); this.type = ChatMessageBodyTypeFromString(type); } } /** * Text message body. */ exports.ChatMessageBody = ChatMessageBody; class ChatTextMessageBody extends ChatMessageBody { /** * Text message content. */ constructor(params) { super(params.type); _defineProperty(this, "content", void 0); this.content = params.content; } } /** * The location message body. */ exports.ChatTextMessageBody = ChatTextMessageBody; class ChatLocationMessageBody extends ChatMessageBody { /** * The address. */ /** * The latitude. */ /** * The longitude. */ constructor(params) { super(params.type); _defineProperty(this, "address", void 0); _defineProperty(this, "latitude", void 0); _defineProperty(this, "longitude", void 0); this.address = params.address; this.latitude = params.latitude; this.longitude = params.longitude; } } /** * File message body. */ exports.ChatLocationMessageBody = ChatLocationMessageBody; class ChatFileMessageBody extends ChatMessageBody { /** * The path of the image file. */ /** * The file's token. */ /** * The path of the attachment file in the server. */ /** * The download status of the attachment file . see {@link ChatDownloadStatus} */ /** * The size of the file in bytes. */ /** * The file name. like "file.doc" */ constructor(params) { var _params$secret, _params$remotePath, _params$fileStatus, _params$fileSize; super(params.type); _defineProperty(this, "localPath", ''); _defineProperty(this, "secret", void 0); _defineProperty(this, "remotePath", void 0); _defineProperty(this, "fileStatus", void 0); _defineProperty(this, "fileSize", void 0); _defineProperty(this, "displayName", void 0); this.localPath = params.localPath; this.secret = (_params$secret = params.secret) !== null && _params$secret !== void 0 ? _params$secret : ''; this.remotePath = (_params$remotePath = params.remotePath) !== null && _params$remotePath !== void 0 ? _params$remotePath : ''; this.fileStatus = ChatDownloadStatusFromNumber((_params$fileStatus = params.fileStatus) !== null && _params$fileStatus !== void 0 ? _params$fileStatus : -1); this.fileSize = (_params$fileSize = params.fileSize) !== null && _params$fileSize !== void 0 ? _params$fileSize : 0; this.displayName = params.displayName; } } /** * The image message body class. */ exports.ChatFileMessageBody = ChatFileMessageBody; class ChatImageMessageBody extends ChatFileMessageBody { /** * Sets whether to send the original image when sending an image. * * false`: (default) Send the thumbnail(image with size larger than 100k will be compressed); * `true`: Send the original image. */ /** * The local path or the URI of the thumbnail as a string. */ /** * The URL of the thumbnail on the server. */ /** * The secret to access the thumbnail. A secret is required for verification for thumbnail download. */ /** * The download status of the thumbnail. see {@link ChatDownloadStatus} */ /** * The image width. */ /** * The image height. */ constructor(params) { var _params$sendOriginalI, _params$thumbnailLoca, _params$thumbnailRemo, _params$thumbnailSecr, _params$thumbnailStat, _params$width, _params$height; super({ type: params.type, localPath: params.localPath, secret: params.secret, remotePath: params.remotePath, fileStatus: params.fileStatus, fileSize: params.fileSize, displayName: params.displayName }); _defineProperty(this, "sendOriginalImage", void 0); _defineProperty(this, "thumbnailLocalPath", void 0); _defineProperty(this, "thumbnailRemotePath", void 0); _defineProperty(this, "thumbnailSecret", void 0); _defineProperty(this, "thumbnailStatus", void 0); _defineProperty(this, "width", void 0); _defineProperty(this, "height", void 0); this.sendOriginalImage = (_params$sendOriginalI = params.sendOriginalImage) !== null && _params$sendOriginalI !== void 0 ? _params$sendOriginalI : false; this.thumbnailLocalPath = (_params$thumbnailLoca = params.thumbnailLocalPath) !== null && _params$thumbnailLoca !== void 0 ? _params$thumbnailLoca : ''; this.thumbnailRemotePath = (_params$thumbnailRemo = params.thumbnailRemotePath) !== null && _params$thumbnailRemo !== void 0 ? _params$thumbnailRemo : ''; this.thumbnailSecret = (_params$thumbnailSecr = params.thumbnailSecret) !== null && _params$thumbnailSecr !== void 0 ? _params$thumbnailSecr : ''; this.thumbnailStatus = ChatDownloadStatusFromNumber((_params$thumbnailStat = params.thumbnailStatus) !== null && _params$thumbnailStat !== void 0 ? _params$thumbnailStat : -1); this.width = (_params$width = params.width) !== null && _params$width !== void 0 ? _params$width : 0; this.height = (_params$height = params.height) !== null && _params$height !== void 0 ? _params$height : 0; } } /** * The video message body. */ exports.ChatImageMessageBody = ChatImageMessageBody; class ChatVideoMessageBody extends ChatFileMessageBody { /** * The video duration in seconds. */ /** * The local path of the video thumbnail. */ /** * The URL of the thumbnail on the server. */ /** * The secret key of the video thumbnail. */ /** * The download status of the video thumbnail. see {@link ChatDownloadStatus} */ /** * The video width. */ /** * The video height. */ constructor(params) { var _params$duration, _params$thumbnailLoca2, _params$thumbnailRemo2, _params$thumbnailSecr2, _params$thumbnailStat2, _params$width2, _params$height2; super({ type: params.type, localPath: params.localPath, secret: params.secret, remotePath: params.remotePath, fileStatus: params.fileStatus, fileSize: params.fileSize, displayName: params.displayName }); _defineProperty(this, "duration", void 0); _defineProperty(this, "thumbnailLocalPath", void 0); _defineProperty(this, "thumbnailRemotePath", void 0); _defineProperty(this, "thumbnailSecret", void 0); _defineProperty(this, "thumbnailStatus", void 0); _defineProperty(this, "width", void 0); _defineProperty(this, "height", void 0); this.duration = (_params$duration = params.duration) !== null && _params$duration !== void 0 ? _params$duration : 0; this.thumbnailLocalPath = (_params$thumbnailLoca2 = params.thumbnailLocalPath) !== null && _params$thumbnailLoca2 !== void 0 ? _params$thumbnailLoca2 : ''; this.thumbnailRemotePath = (_params$thumbnailRemo2 = params.thumbnailRemotePath) !== null && _params$thumbnailRemo2 !== void 0 ? _params$thumbnailRemo2 : ''; this.thumbnailSecret = (_params$thumbnailSecr2 = params.thumbnailSecret) !== null && _params$thumbnailSecr2 !== void 0 ? _params$thumbnailSecr2 : ''; this.thumbnailStatus = ChatDownloadStatusFromNumber((_params$thumbnailStat2 = params.thumbnailStatus) !== null && _params$thumbnailStat2 !== void 0 ? _params$thumbnailStat2 : -1); this.width = (_params$width2 = params.width) !== null && _params$width2 !== void 0 ? _params$width2 : 0; this.height = (_params$height2 = params.height) !== null && _params$height2 !== void 0 ? _params$height2 : 0; } } /** * The voice message body. */ exports.ChatVideoMessageBody = ChatVideoMessageBody; class ChatVoiceMessageBody extends ChatFileMessageBody { /** * The voice duration in seconds. */ constructor(params) { var _params$duration2; super({ type: params.type, localPath: params.localPath, secret: params.secret, remotePath: params.remotePath, fileStatus: params.fileStatus, fileSize: params.fileSize, displayName: params.displayName }); _defineProperty(this, "duration", void 0); this.duration = (_params$duration2 = params.duration) !== null && _params$duration2 !== void 0 ? _params$duration2 : 0; } } /** * The command message body. */ exports.ChatVoiceMessageBody = ChatVoiceMessageBody; class ChatCmdMessageBody extends ChatMessageBody { /** * The command action content. */ /** * Checks whether this cmd message is only delivered to online users. * * `true`: Only delivers to online users. * `false`: Delivers to all users. */ constructor(params) { var _params$deliverOnline; super(ChatMessageBodyType.CMD); _defineProperty(this, "action", void 0); _defineProperty(this, "deliverOnlineOnly", void 0); this.action = params.action; this.deliverOnlineOnly = (_params$deliverOnline = params.deliverOnlineOnly) !== null && _params$deliverOnline !== void 0 ? _params$deliverOnline : false; } } /** * The custom message body. */ exports.ChatCmdMessageBody = ChatCmdMessageBody; class ChatCustomMessageBody extends ChatMessageBody { /** * The event. */ /** * The params map. */ constructor(params) { var _params$params; super(ChatMessageBodyType.CUSTOM); _defineProperty(this, "event", void 0); _defineProperty(this, "params", void 0); this.event = params.event; this.params = (_params$params = params.params) !== null && _params$params !== void 0 ? _params$params : {}; } } exports.ChatCustomMessageBody = ChatCustomMessageBody; //# sourceMappingURL=ChatMessage.js.map