Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { selectedChat } = this.props
if (!this.poiLocation) {
return
}
const latLng = Object.assign({}, this.poiLocation)
callDcMethod(
'messageList.sendMessage',
[selectedChat.id, message, null, latLng]
)
if (this.contextMenuPopup) {
this.contextMenuPopup.remove()
this.contextMenuPopup = null
}
let contact = selectedChat.contacts.find(contact => contact.address === this.currentUserAddress)
if (!contact) {
contact = { id: C.DC_CONTACT_ID_SELF, firstName: window.translate('self'), color: 1212112 } // fallback since current user is not in contact list in non group chats
}
const location = {
longitude: latLng.lng,
latitude: latLng.lat,
contact: contact,
timestamp: new Date().getUTCMilliseconds(),
isIndependent: true,
message: message
}
const mapData = this.mapDataStore.get(contact.id)
if (mapData) {
this.map.getSource(mapData.pointsLayerId).setData(MapLayerFactory.getGeoJSONPointsLayerSourceData([location], contact, true))
} else {
this.renderContactLayer(contact, [location])
}
this.poiLocation = null
messageIdToJson (id) {
const msg = this._dc.getMessage(id)
const filemime = msg.getFilemime()
const filename = msg.getFilename()
const filesize = msg.getFilebytes()
const fromId = msg.getFromId()
const isMe = fromId === C.DC_CONTACT_ID_SELF
const setupCodeBegin = msg.getSetupcodebegin()
const contact = fromId ? this._dc.getContact(fromId).toJson() : {}
if (contact.color) {
contact.color = this._integerToHexColor(contact.color)
}
return {
id,
msg: msg.toJson(),
filemime,
filename,
filesize,
fromId,
isMe,
contact,
isInfo: msg.isInfo(),
.filter(id => id !== C.DC_CONTACT_ID_SELF)
.map(id => Number(id))
leaveGroup (chatId) {
log.debug(`action - leaving chat ${chatId}`)
this._dc.removeContactFromChat(chatId, C.DC_CONTACT_ID_SELF)
}
function convertContactProps (contact) {
return {
name: contact.name,
phoneNumber: contact.address,
avatarPath: contact.profileImage,
profileName: contact.displayName,
isMe: contact.id === DCConstants.DC_CONTACT_ID_SELF,
verified: contact.isVerified
}
}
const advancedSettings = {
mail_user: settings['configured_mail_user'],
mail_server: settings['configured_mail_server'],
mail_port: settings['configured_mail_port'],
mail_security: settings['configured_mail_security'],
imap_certificate_checks: settings['configured_imap_certificate_checks'],
send_user: settings['configured_send_user'],
send_pw: settings['configured_send_pw'],
send_server: settings['configured_send_server'],
send_port: settings['configured_send_port'],
send_security: settings['configured_send_security'],
smtp_certificate_checks: settings['configured_smtp_certificate_checks'],
e2ee_enabled: settings['configured_e2ee_enabled']
}
const selfContact = await callDcMethodAsync('getContact', [C.DC_CONTACT_ID_SELF])
this.setState({ settings, advancedSettings, selfContact })
}
messageToJson (msg) {
const filemime = msg.getFilemime()
const filename = msg.getFilename()
const filesize = msg.getFilebytes()
const viewType = msg.getViewType()
const fromId = msg.getFromId()
const isMe = fromId === C.DC_CONTACT_ID_SELF
const setupCodeBegin = msg.getSetupcodebegin()
const contact = fromId ? this._dc.getContact(fromId).toJson() : {}
if (contact.color) {
contact.color = integerToHexColor(contact.color)
}
return convert({
id: msg.id,
msg: msg.toJson(),
filemime,
filename,
filesize,
viewType,
fromId,
isMe,
contact,
isInfo: msg.isInfo(),
getProfilePicture () {
return this._dc.getContact(C.DC_CONTACT_ID_SELF).getProfileImage()
}
color: integerToHexColor(chat.color),
lastUpdated: lastUpdated,
summary: {
text1: summary.text1,
text2: summary.text2,
status: mapCoreMsgStatus2String(summary.state)
},
deaddrop: chat.deaddrop,
isVerified: chat.isVerified,
isGroup: isGroup,
freshMessageCounter: this._dc.getFreshMessageCount(chatId),
isArchiveLink: chat.id === C.DC_CHAT_ID_ARCHIVED_LINK,
contactIds,
isSelfTalk: chat.isSelfTalk,
isDeviceTalk: chat.isDeviceTalk,
selfInGroup: isGroup && contactIds.indexOf(C.DC_CONTACT_ID_SELF) !== -1
}
}