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

Commit

Permalink
Make options in bindings 1-1 with options in core
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphtheninja committed Jun 4, 2019
1 parent 5818362 commit 21ad3f2
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 53 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,22 @@ Configure and connect a context. Corresponds to `dc_configure()`.
The `options` object takes the following properties:

- `options.addr` _(string, required)_: Email address of the chat user.
- `options.mailServer` _(string, optional)_: IMAP-server, guessed if left out.
- `options.mailUser` _(string, optional)_: IMAP-username, guessed if left out.
- `options.mailPw` _(string, required)_: IMAP-password of the chat user.
- `options.mailPort` _(string | integer, optional)_: IMAP-port, guessed if left out.
- `options.sendServer` _(string, optional)_: SMTP-server, guessed if left out.
- `options.sendUser` _(string, optional)_: SMTP-user, guessed if left out.
- `options.sendPw` _(string, optional)_: SMTP-password, guessed if left out.
- `options.sendPort` _(string | integer, optional)_: SMTP-port, guessed if left out.
- `options.serverFlags` _(integer, optional)_: IMAP-/SMTP-flags as a combination of DC_LP flags, guessed if left out.
- `options.imapFolder` _(string, optional)_: IMAP folder to use, defaults to `'INBOX'`.
- `options.displayName` _(string, optional)_: Own name to use when sending messages. MUAs are allowed to spread this way e.g. using CC, defaults to empty.
- `options.selfStatus` _(string, optional)_: Own status to display e.g. in email footers, defaults to a standard text.
- `options.selfAvatar` _(string, optional)_: File containing avatar.
- `options.e2eeEnabled` _(boolean, optional)_: Enable E2EE. Defaults to `true`.
- `options.mdnsEnabled` _(boolean, optional)_: Send and request read receipts. Defaults to `true`.
- `options.saveMimeHeaders` _(boolean, optional)_: Set to `true` if you want to use <a href="#getmimeheaders">`dc.getMimeHeaders()`</a> later.
- `options.mail_server` _(string, optional)_: IMAP-server, guessed if left out.
- `options.mail_user` _(string, optional)_: IMAP-username, guessed if left out.
- `options.mail_pw` _(string, required)_: IMAP-password of the chat user.
- `options.mail_port` _(string | integer, optional)_: IMAP-port, guessed if left out.
- `options.send_server` _(string, optional)_: SMTP-server, guessed if left out.
- `options.send_user` _(string, optional)_: SMTP-user, guessed if left out.
- `options.send_pw` _(string, optional)_: SMTP-password, guessed if left out.
- `options.send_port` _(string | integer, optional)_: SMTP-port, guessed if left out.
- `options.server_flags` _(integer, optional)_: IMAP-/SMTP-flags as a combination of DC_LP flags, guessed if left out.
- `options.imap_folder` _(string, optional)_: IMAP folder to use, defaults to `'INBOX'`.
- `options.displayname` _(string, optional)_: Own name to use when sending messages. MUAs are allowed to spread this way e.g. using CC, defaults to empty.
- `options.selfstatus` _(string, optional)_: Own status to display e.g. in email footers, defaults to a standard text.
- `options.selfavatar` _(string, optional)_: File containing avatar.
- `options.e2ee_enabled` _(boolean, optional)_: Enable E2EE. Defaults to `true`.
- `options.mdns_enabled` _(boolean, optional)_: Send and request read receipts. Defaults to `true`.
- `options.save_mime_headers` _(boolean, optional)_: Set to `true` if you want to use <a href="#getmimeheaders">`dc.getMimeHeaders()`</a> later.

#### `dc.continueKeyTransfer(messageId, setupCode, callback)`

Expand Down
42 changes: 21 additions & 21 deletions lib/deltachat.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,34 +98,34 @@ class DeltaChat extends EventEmitter {
throw new Error('Missing .addr')
}

if (typeof opts.mailPw !== 'string') {
throw new Error('Missing .mailPw')
if (typeof opts.mail_pw !== 'string') {
throw new Error('Missing .mail_pw')
}

this.once('_configured', ready)

if (typeof opts.e2eeEnabled === 'undefined') opts.e2eeEnabled = 1
if (typeof opts.e2ee_enabled === 'undefined') opts.e2ee_enabled = 1

this.setConfig('addr', opts.addr)

this.setConfig('mail_server', opts.mailServer)
this.setConfig('mail_user', opts.mailUser)
this.setConfig('mail_pw', opts.mailPw)
this.setConfig('mail_port', String(opts.mailPort))

this.setConfig('send_server', opts.sendServer)
this.setConfig('send_user', opts.sendUser)
this.setConfig('send_pw', opts.sendPw)
this.setConfig('send_port', String(opts.sendPort))

this.setConfig('server_flags', String(opts.serverFlags))
this.setConfig('imap_folder', opts.imapFolder)
this.setConfig('displayname', opts.displayName)
this.setConfig('selfstatus', opts.selfStatus)
this.setConfig('selfavatar', opts.selfAvatar)
this.setConfig('e2ee_enabled', String(opts.e2eeEnabled ? 1 : 0))
this.setConfig('mdns_enabled', String(opts.mdnsEnabled ? 1 : 0))
this.setConfig('save_mime_headers', String(opts.saveMimeHeaders ? 1 : 0))
this.setConfig('mail_server', opts.mail_server)
this.setConfig('mail_user', opts.mail_user)
this.setConfig('mail_pw', opts.mail_pw)
this.setConfig('mail_port', String(opts.mail_port))

this.setConfig('send_server', opts.send_server)
this.setConfig('send_user', opts.send_user)
this.setConfig('send_pw', opts.send_pw)
this.setConfig('send_port', String(opts.send_port))

this.setConfig('server_flags', String(opts.server_flags))
this.setConfig('imap_folder', opts.imap_folder)
this.setConfig('displayname', opts.displayname)
this.setConfig('selfstatus', opts.selfstatus)
this.setConfig('selfavatar', opts.selfavatar)
this.setConfig('e2ee_enabled', String(opts.e2ee_enabled ? 1 : 0))
this.setConfig('mdns_enabled', String(opts.mdns_enabled ? 1 : 0))
this.setConfig('save_mime_headers', String(opts.save_mime_headers ? 1 : 0))

binding.dcn_configure(this.dcn_context)
}
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ tape('invalid input to configure throws', t => {
const dc = new DeltaChat()
t.throws(function () {
dc.configure({ addr: 'delta1@delta.localhost' })
}, /Missing \.mailPw/, 'missing mailPw throws')
}, /Missing \.mail_pw/, 'missing mail_pw throws')
t.throws(function () {
dc.configure({ mailPw: 'delta1' })
dc.configure({ mail_pw: 'delta1' })
}, /Missing \.addr/, 'missing addr throws')
dc.close()
t.end()
Expand Down
28 changes: 14 additions & 14 deletions test/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ function configureDefaultDC (dc) {
dc.configure({
addr: ADDR,

mailServer: SERVER,
mailUser: ADDR,
mailPw: process.env.DC_MAIL_PW,
mail_server: SERVER,
mail_user: ADDR,
mail_pw: process.env.DC_MAIL_PW,

sendServer: SERVER,
sendUser: ADDR,
sendPw: process.env.DC_MAIL_PW,
send_server: SERVER,
send_user: ADDR,
send_pw: process.env.DC_MAIL_PW,

displayName: 'Delta One',
selfStatus: 'From Delta One with <3',
selfAvatar: path.join(__dirname, 'fixtures', 'avatar.png'),
displayname: 'Delta One',
selfstatus: 'From Delta One with <3',
selfavatar: path.join(__dirname, 'fixtures', 'avatar.png'),

e2eeEnabled: true,
saveMimeHeaders: true
e2ee_enabled: true,
save_mime_headers: true
})
}

Expand Down Expand Up @@ -65,10 +65,10 @@ test('setUp dc context', t => {
// path.join(cwd,
// 'db.sqlite-blobs',
// 'avatar.png'),
// 'selfAvatar correct'
// 'selfavatar correct'
// )
t.is(dc.getConfig('e2ee_enabled'), '1', 'e2eeEnabled correct')
t.is(dc.getConfig('save_mime_headers'), '1', 'saveMimeHeaders correct')
t.is(dc.getConfig('e2ee_enabled'), '1', 'e2ee_enabled correct')
t.is(dc.getConfig('save_mime_headers'), '1', 'save_mime_headers correct')
t.is(
dc.getBlobdir(),
path.join(cwd, 'db.sqlite-blobs'),
Expand Down

0 comments on commit 21ad3f2

Please sign in to comment.