Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
Helper functions to determine chat type. (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
pabzm authored Feb 21, 2020
1 parent 23c6c93 commit e8a5942
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,14 @@ Check if a chat is verified. Corresponds to `dc_chat_is_verified()`.

Check if a chat is a device talk. Corresponds to `dc_chat_is_device_talk()`.

#### `chat.isSingle()`

Check if a chat is a 1-on-1 chat (aka DM).

#### `chat.isGroup()`

Check if a chat is a group chat.

#### `chat.toJson()`

Returns the object state as a JavaScript serializable object.
Expand Down
9 changes: 9 additions & 0 deletions lib/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const binding = require('../binding')
const debug = require('debug')('deltachat:node:chat')
const { C } = require('./constants')

interface NativeChat {}
/**
Expand Down Expand Up @@ -56,6 +57,14 @@ export class Chat {
return Boolean(binding.dcn_chat_is_device_talk(this.dc_chat))
}

isSingle ():boolean {
return this.getType() === C.DC_CHAT_TYPE_SINGLE
}

isGroup ():boolean {
return this.getType() === C.DC_CHAT_TYPE_GROUP
}

toJson () {
debug('toJson')
return {
Expand Down

0 comments on commit e8a5942

Please sign in to comment.