Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
receiverType = CometChat.RECEIVER_TYPE.GROUP;
} else if (this.props.activeConversation.uid !== undefined) {
otherUID = this.props.activeConversation.uid;
receiverType = CometChat.RECEIVER_TYPE.USER;
}
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]
});
return dispatch => {
let messageType = CometChat.MESSAGE_TYPE.TEXT;
let receiverType = CometChat.RECEIVER_TYPE.USER;
let textMessage = new CometChat.TextMessage(
receiverID,
messageText,
messageType,
receiverType
);
textMessage.setId(messageId);
CometChat.editMessage(textMessage).then(
message => {
dispatch(editMessage(message));
},
error => {
console.log("Message editing failed with error:", error);
}
);
getFileGallery = e => {
var ele = document.getElementById("ccMessageInputGallery");
var files = ele.files;
for (let i = 0; i < files.length; i++) {
const file = files[i];
this.sendMediaMessage(file,CometChat.MESSAGE_TYPE.IMAGE);
}
this.toggleAttachMenu();
};
getFile = e => {
var ele = document.getElementById("ccMessageInputFile");
var files = ele.files;
for (let i = 0; i < files.length; i++) {
const file = files[i];
this.sendMediaMessage(file,CometChat.MESSAGE_TYPE.FILE);
}
this.toggleAttachMenu();
}
getFileAudio=e=>{
var ele = document.getElementById("ccMessageInputAudio");
var files = ele.files;
for (let i = 0; i < files.length; i++) {
const file = files[i];
this.sendMediaMessage(file,CometChat.MESSAGE_TYPE.AUDIO);
}
this.toggleAttachMenu();
}
handleAttachment = (fileType = MESSAGE_TYPE_MEDIA) => {
let otherUID;
let receiverType;
if (this.props.activeConversation.guid !== undefined) {
otherUID = this.props.activeConversation.guid;
receiverType = CometChat.RECEIVER_TYPE.GROUP;
} else if (this.props.activeConversation.uid !== undefined) {
otherUID = this.props.activeConversation.uid;
receiverType = CometChat.RECEIVER_TYPE.USER;
}
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,
recieveCaptureImage = (data) =>{
let fileObject = utils.dataURLtoFile(data, 'a.png')
this.closeModalHandler();
this.toggleAttachMenu();
this.sendMediaMessage(fileObject,CometChat.MESSAGE_TYPE.IMAGE);
}
let messageStatus=null;
if(props.msgData.receiverType != "group"){
if(props.msgData.readAt != undefined){
messageStatus = (<span></span>);
}else{
if(props.msgData.deliveredAt != undefined){
messageStatus = (<span></span>);
}else{
if(props.msgData.sentAt != undefined){
messageStatus = (<span></span>);
}
}
}
}
switch(props.msg.msgType){
case CometChat.MESSAGE_TYPE.IMAGE : {
return (
<div>
<div>
<div>
<span>{util.convertStringToDate(props.msg.sendAt)}</span>
<img src="{props.msg.data.url}/" class="">
{messageStatus}
</div>
</div>
</div>
);
} break;
case CometChat.MESSAGE_TYPE.VIDEO : {
return (