Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
let messageType = CometChat.MESSAGE_TYPE.MEDIA;
if (fileType === MESSAGE_TYPE_IMAGE)
messageType = CometChat.MESSAGE_TYPE.IMAGE;
else if (fileType === MESSAGE_TYPE_VIDEO)
messageType = CometChat.MESSAGE_TYPE.VIDEO;
else if (fileType === MESSAGE_TYPE_AUDIO)
messageType = CometChat.MESSAGE_TYPE.AUDIO;
else if (fileType === MESSAGE_TYPE_FILE)
messageType = CometChat.MESSAGE_TYPE.FILE;
var file = document.getElementById("attachment-type-" + fileType).files[0];
var mediaMessage = new CometChat.MediaMessage(
otherUID,
file,
messageType,
receiverType
);
CometChat.sendMediaMessage(mediaMessage).then(
message => {
// Message sent successfully.
this.setState({
showAttachmentOptions: !this.state.showAttachmentOptions,
msghistory: [...this.state.msghistory, message]
});
this.scrollToBottom();
this.props.handleOnRecentMessageSent(message.id);
},
error => {
static getMediaMessage(uid, file, msgType,mediaType) {
if (msgType == "user") {
return new CometChat.MediaMessage(uid, file, mediaType, CometChat.RECEIVER_TYPE.USER);
} else {
return new CometChat.MediaMessage(uid, file, mediaType, CometChat.RECEIVER_TYPE.GROUP);
}
}
static getMediaMessage(uid, file, msgType,mediaType) {
if (msgType == "user") {
return new CometChat.MediaMessage(uid, file, mediaType, CometChat.RECEIVER_TYPE.USER);
} else {
return new CometChat.MediaMessage(uid, file, mediaType, CometChat.RECEIVER_TYPE.GROUP);
}
}