diff --git a/CHANGELOG.md b/CHANGELOG.md index 0de5db7..445cc42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [master] +## [0.0.25] - 2017-10-10 +### Added +- Add 'namespace' and 'sharedWith' property to Mailbox. Fixes #69 + +## [0.0.24] - 2017-26-09 +### Added +- add required property blobId to Message. Fixes #65 + ## [0.0.23] - 2017-03-20 ### Fixed - The Message model was not creating EMailer instances for To, CC and BCC fields. #63 diff --git a/lib/models/Mailbox.js b/lib/models/Mailbox.js index ca1adbc..5ee8861 100644 --- a/lib/models/Mailbox.js +++ b/lib/models/Mailbox.js @@ -15,8 +15,10 @@ export default class Mailbox extends Model { * @param id {String} The unique identifier of this _Mailbox_. * @param name {String} The user-visible name (i.e.: display name) of this _Mailbox_. * @param [opts] {Object} The optional properties of this _Mailbox_. + * @param [opts.namespace={}] {Object} The namespace give information about mailbox type and owner. * @param [opts.parentId=null] {String} The _Mailbox_ id for the parent of this mailbox, or _null_ if this mailbox is at the top level. * @param [opts.role=null] {String} The role of this mailbox, if it is a system mailbox. See the specification for the possible values. + * @param [opts.sharedWith={}] {Object} The sharedWith give information about mailbox shared and rights. * @param [opts.sortOrder=0] {String} Defines the sort order of mailboxes when presented in the UI. * @param [opts.mustBeOnlyMailbox=false] {Boolean} If _true_, messages in this mailbox may not also be in any other mailbox. * @param [opts.mayReadItems=false] {Boolean} If _true_, may use this mailbox as part of a filter in a {@link Client#getMessageList} call. @@ -42,8 +44,10 @@ export default class Mailbox extends Model { this.id = id; this.name = name; + this.namespace = opts.namespace || {}; this.parentId = opts.parentId || null; this.role = MailboxRole.fromRole(opts.role); + this.sharedWith = opts.sharedWith || {}; this.sortOrder = opts.sortOrder || 0; this.mustBeOnlyMailbox = opts.mustBeOnlyMailbox || false; this.mayReadItems = opts.mayReadItems || false; diff --git a/test/common/models/Mailbox.js b/test/common/models/Mailbox.js index 7ff8eb7..4667fc8 100644 --- a/test/common/models/Mailbox.js +++ b/test/common/models/Mailbox.js @@ -22,8 +22,10 @@ describe('The Mailbox class', function() { it('should use default values for all other fields if not defined', function() { var mailbox = new jmap.Mailbox({}, 'id', 'name'); + expect(mailbox.namespace).to.deep.equal({}); expect(mailbox.parentId).to.equal(null); expect(mailbox.role).to.equal(jmap.MailboxRole.UNKNOWN); + expect(mailbox.sharedWith).to.deep.equal({}); expect(mailbox.sortOrder).to.equal(0); expect(mailbox.mustBeOnlyMailbox).to.equal(false); expect(mailbox.mayReadItems).to.equal(false); @@ -41,8 +43,10 @@ describe('The Mailbox class', function() { it('should use default values for all other fields if an empty opts object is given', function() { var mailbox = new jmap.Mailbox({}, 'id', 'name', {}); + expect(mailbox.namespace).to.deep.equal({}); expect(mailbox.parentId).to.equal(null); expect(mailbox.role).to.equal(jmap.MailboxRole.UNKNOWN); + expect(mailbox.sharedWith).to.deep.equal({}); expect(mailbox.sortOrder).to.equal(0); expect(mailbox.mustBeOnlyMailbox).to.equal(false); expect(mailbox.mayReadItems).to.equal(false); @@ -124,8 +128,10 @@ describe('The Mailbox class', function() { it('should use default values for for all other fields if not defined', function() { var mailbox = jmap.Mailbox.fromJSONObject({}, { id: 'id', name: 'name' }); + expect(mailbox.namespace).to.deep.equal({}); expect(mailbox.parentId).to.equal(null); expect(mailbox.role).to.equal(jmap.MailboxRole.UNKNOWN); + expect(mailbox.sharedWith).to.deep.equal({}); expect(mailbox.sortOrder).to.equal(0); expect(mailbox.mustBeOnlyMailbox).to.equal(false); expect(mailbox.mayReadItems).to.equal(false); @@ -144,8 +150,12 @@ describe('The Mailbox class', function() { var mailbox = jmap.Mailbox.fromJSONObject({}, { id: 'id', name: 'name', + namespace: { + type: 'Personal' + }, parentId: 'parentId', role: 'inbox', + sharedWith: {}, sortOrder: 1, mustBeOnlyMailbox: true, mayReadItems: true, @@ -162,8 +172,10 @@ describe('The Mailbox class', function() { expect(mailbox.id).to.equal('id'); expect(mailbox.name).to.equal('name'); + expect(mailbox.namespace.type).to.equal('Personal'); expect(mailbox.parentId).to.equal('parentId'); expect(mailbox.role).to.equal(jmap.MailboxRole.INBOX); + expect(mailbox.sharedWith).to.deep.equal({}); expect(mailbox.sortOrder).to.equal(1); expect(mailbox.mustBeOnlyMailbox).to.equal(true); expect(mailbox.mayReadItems).to.equal(true);