Skip to content

Commit

Permalink
Merge pull request linagora#70 from fabienmoyon/linagora#69
Browse files Browse the repository at this point in the history
add 'namespace' and 'sharedWith' property to Mailbox. Fixes linagora#69
  • Loading branch information
dbenchi authored Oct 13, 2017
2 parents 3c52fa0 + 5630daf commit fe2cb79
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/models/Mailbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions test/common/models/Mailbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand All @@ -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);
Expand Down

0 comments on commit fe2cb79

Please sign in to comment.