How to use deltachat-node - 10 common examples

To help you get started, weโ€™ve selected a few deltachat-node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github deltachat / deltachat-desktop / src / main / deltachat.js View on Github external
}

  if (!flags.length) return null

  return flags.reduce((flag, acc) => {
    return acc | flag
  }, 0)
}

if (!module.parent) {
  // TODO move this to unit tests
  console.log(serverFlags({
    mailSecurity: 'ssl',
    sendSecurity: 'ssl'
  }))
  console.log(C.DC_LP_IMAP_SOCKET_SSL | C.DC_LP_SMTP_SOCKET_SSL)
  console.log(serverFlags({
    mailSecurity: 'starttls',
    sendSecurity: 'starttls'
  }))
  console.log(C.DC_LP_IMAP_SOCKET_STARTTLS | C.DC_LP_SMTP_SOCKET_STARTTLS)
}

module.exports = DeltaChatController
github deltachat / deltachat-desktop / src / renderer / components / map / MapComponent.js View on Github external
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
github deltachat / deltachat-desktop / src / main / deltachat.js View on Github external
_chatList (showArchivedChats) {
    if (!this._dc) return []

    const listFlags = showArchivedChats ? C.DC_GCL_ARCHIVED_ONLY : 0
    const list = this._dc.getChatList(listFlags, this._query)
    const listCount = list.getCount()

    const chatList = []
    for (let i = 0; i < listCount; i++) {
      const chatId = list.getChatId(i)
      const chat = this._getChatById(chatId)

      if (!chat) continue

      if (chat.id === C.DC_CHAT_ID_DEADDROP) {
        const messageId = list.getMessageId(i)
        chat.deaddrop = this._deadDropMessage(messageId)
      }

      // This is NOT the Chat Oject, it's a smaller version for use as ChatListItem in the ChatList
      chatList.push({
        id: chat.id,
        summary: list.getSummary(i).toJson(),
        name: chat.name,
        deaddrop: chat.deaddrop,
        freshMessageCounter: chat.freshMessageCounter,
        profileImage: chat.profileImage,
        color: chat.color,
        isVerified: chat.isVerified,
        isGroup: chat.isGroup
      })
github deltachat / deltachat-desktop / src / main / deltachat / chatlist.js View on Github external
selectChat (chatId) {
    this._controller._selectedChatId = chatId
    const chat = this.getFullChatById(chatId, true)
    if (!chat) {
      log.debug(`Error: selected chat not found: ${chatId}`)
      return null
    }
    if (chat.id !== C.DC_CHAT_ID_DEADDROP && chat.freshMessageCounter > 0) {
      this._dc.markNoticedChat(chat.id)
      chat.freshMessageCounter = 0
      const messagIds = this._controller.messageList.getMessageIds(chatId)
      log.debug('markSeenMessages', messagIds)
      // TODO: move mark seen logic to frontend
      this._dc.markSeenMessages(messagIds)
      app.setBadgeCount(this._getGeneralFreshMessageCounter())
    }
    return chat
  }
github deltachat / deltachat-desktop / src / main / deltachat / chatlist.js View on Github external
function mapCoreMsgStatus2String (state) {
  switch (state) {
    case C.DC_STATE_OUT_FAILED:
      return 'error'
    case C.DC_STATE_OUT_PENDING:
      return 'sending'
    case C.DC_STATE_OUT_PREPARING:
      return 'sending'
    case C.DC_STATE_OUT_DRAFT:
      return 'draft'
    case C.DC_STATE_OUT_DELIVERED:
      return 'delivered'
    case C.DC_STATE_OUT_MDN_RCVD:
      return 'read'
    default:
      return '' // to display no icon on unknown state
  }
}
function isGroupChat (chat) {
github deltachat / deltachat-desktop / src / renderer / components / helpers / MapMsgStatus.js View on Github external
function mapCoreMsgStatus2String (state) {
  switch (state) {
    case C.DC_STATE_OUT_FAILED:
      return 'error'
    case C.DC_STATE_OUT_PENDING:
      return 'sending'
    case C.DC_STATE_OUT_PREPARING:
      return 'sending'
    case C.DC_STATE_OUT_DRAFT:
      return 'draft'
    case C.DC_STATE_OUT_DELIVERED:
      return 'delivered'
    case C.DC_STATE_OUT_MDN_RCVD:
      return 'read'
    case C.DC_STATE_IN_FRESH:
      return 'delivered'
    case C.DC_STATE_IN_SEEN:
      return 'delivered'
    case C.DC_STATE_IN_NOTICED:
      return 'read'
    default:
      return '' // to display no icon on unknown state
  }
}
github deltachat / deltachat-desktop / src / main / deltachat / chatlist.js View on Github external
function mapCoreMsgStatus2String (state) {
  switch (state) {
    case C.DC_STATE_OUT_FAILED:
      return 'error'
    case C.DC_STATE_OUT_PENDING:
      return 'sending'
    case C.DC_STATE_OUT_PREPARING:
      return 'sending'
    case C.DC_STATE_OUT_DRAFT:
      return 'draft'
    case C.DC_STATE_OUT_DELIVERED:
      return 'delivered'
    case C.DC_STATE_OUT_MDN_RCVD:
      return 'read'
    default:
      return '' // to display no icon on unknown state
  }
}
function isGroupChat (chat) {
github deltachat / deltachat-desktop / src / main / deltachat / chatlist.js View on Github external
function mapCoreMsgStatus2String (state) {
  switch (state) {
    case C.DC_STATE_OUT_FAILED:
      return 'error'
    case C.DC_STATE_OUT_PENDING:
      return 'sending'
    case C.DC_STATE_OUT_PREPARING:
      return 'sending'
    case C.DC_STATE_OUT_DRAFT:
      return 'draft'
    case C.DC_STATE_OUT_DELIVERED:
      return 'delivered'
    case C.DC_STATE_OUT_MDN_RCVD:
      return 'read'
    default:
      return '' // to display no icon on unknown state
  }
}
function isGroupChat (chat) {
github deltachat / deltachat-desktop / src / renderer / components / helpers / MapMsgStatus.js View on Github external
function mapCoreMsgStatus2String (state) {
  switch (state) {
    case C.DC_STATE_OUT_FAILED:
      return 'error'
    case C.DC_STATE_OUT_PENDING:
      return 'sending'
    case C.DC_STATE_OUT_PREPARING:
      return 'sending'
    case C.DC_STATE_OUT_DRAFT:
      return 'draft'
    case C.DC_STATE_OUT_DELIVERED:
      return 'delivered'
    case C.DC_STATE_OUT_MDN_RCVD:
      return 'read'
    case C.DC_STATE_IN_FRESH:
      return 'delivered'
    case C.DC_STATE_IN_SEEN:
      return 'delivered'
    case C.DC_STATE_IN_NOTICED:
      return 'read'
    default:
      return '' // to display no icon on unknown state
  }
}
github deltachat / deltachat-desktop / src / main / deltachat / chatlist.js View on Github external
function mapCoreMsgStatus2String (state) {
  switch (state) {
    case C.DC_STATE_OUT_FAILED:
      return 'error'
    case C.DC_STATE_OUT_PENDING:
      return 'sending'
    case C.DC_STATE_OUT_PREPARING:
      return 'sending'
    case C.DC_STATE_OUT_DRAFT:
      return 'draft'
    case C.DC_STATE_OUT_DELIVERED:
      return 'delivered'
    case C.DC_STATE_OUT_MDN_RCVD:
      return 'read'
    default:
      return '' // to display no icon on unknown state
  }
}
function isGroupChat (chat) {