Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sendMessage (chatId, text, filename, opts) {
const viewType = filename ? C.DC_MSG_FILE : C.DC_MSG_TEXT
const msg = this._dc.messageNew(viewType)
if (filename) msg.setFile(filename)
if (text) msg.setText(text)
this._dc.sendMessage(chatId, msg)
}
function convertContentType (message) {
const filemime = message.filemime
if (!filemime) return 'application/octet-stream'
if (filemime !== 'application/octet-stream') return filemime
switch (message.msg.viewType) {
case C.DC_MSG_IMAGE:
return 'image/jpg'
case C.DC_MSG_VOICE:
return 'audio/ogg'
case C.DC_MSG_FILE:
const type = mime.lookup(message.msg.file)
if (type) return type
else return 'application/octet-stream'
default:
return 'application/octet-stream'
}
}
sendMessage (chatId, text, filename, location) {
const viewType = filename ? C.DC_MSG_FILE : C.DC_MSG_TEXT
const msg = this._dc.messageNew(viewType)
if (filename) msg.setFile(filename)
if (text) msg.setText(text)
if (location) msg.setLocation(location.lat, location.lng)
const messageId = this._dc.sendMessage(chatId, msg)
return [messageId, this.getMessage(messageId)]
}
`
const GROUPS = {
images: {
values: [C.DC_MSG_GIF, C.DC_MSG_IMAGE]
},
video: {
values: [C.DC_MSG_VIDEO]
},
audio: {
values: [C.DC_MSG_AUDIO, C.DC_MSG_VOICE]
},
documents: {
values: [C.DC_MSG_FILE]
}
}
const DEFAULT_STATE = {
id: 'images',
msgTypes: GROUPS.images.values,
medias: []
}
export default class Media extends React.Component {
constructor (props) {
super(props)
this.state = DEFAULT_STATE
}
componentDidMount () {