From 9be36921247b6a65bd4c02b34a14827eecdefb34 Mon Sep 17 00:00:00 2001 From: Santosh Shetty Date: Fri, 22 Nov 2019 14:49:31 +0530 Subject: [PATCH 1/3] ZAPPD-45: Local Folder Epic Branch From ca5f75dc95896f079963c993751bd19028a145e6 Mon Sep 17 00:00:00 2001 From: Santosh Shetty Date: Fri, 22 Nov 2019 16:05:46 +0530 Subject: [PATCH 2/3] PREAPPS-3714: Local Search | Search by email Metadata - Part 2 --- src/batch-client/index.ts | 30 ++++++++++++++++++---------- src/schema/generated-schema-types.ts | 1 + src/schema/schema.graphql | 1 + 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/batch-client/index.ts b/src/batch-client/index.ts index c514d83b6..b59f9c259 100644 --- a/src/batch-client/index.ts +++ b/src/batch-client/index.ts @@ -214,16 +214,26 @@ export class ZimbraBatchClient { body: { sections: 'mbox,attrs,zimlets' } - }).then(res => ({ - ...res, - attrs: mapValuesDeep(res.attrs._attrs, coerceStringToBoolean), - ...(get(res, 'license.attr') && { - license: { - status: res.license.status, - attr: mapValuesDeep(res.license.attr, coerceStringToBoolean) - } - }) - })); + }).then(res => { + const { attrs: { _attrs } } = res; + + if (typeof _attrs.zimbraMailAlias === 'string') { + // Server returns `zimbraMailAlias` as `string` if only one alias is present, else returns as `array`. + // But Graphql can have only one type (using unions was not an option). + _attrs.zimbraMailAlias = [_attrs.zimbraMailAlias]; + } + + return { + ...res, + attrs: mapValuesDeep(_attrs, coerceStringToBoolean), + ...(get(res, 'license.attr') && { + license: { + status: res.license.status, + attr: mapValuesDeep(res.license.attr, coerceStringToBoolean) + } + }) + }; + }); public action = (type: ActionType, options: ActionOptions) => { const { ids, id, ...rest } = options; diff --git a/src/schema/generated-schema-types.ts b/src/schema/generated-schema-types.ts index 1279e679d..c06832a0a 100644 --- a/src/schema/generated-schema-types.ts +++ b/src/schema/generated-schema-types.ts @@ -73,6 +73,7 @@ export type AccountInfoAttrs = { zimbraFeatureTrustedDevicesEnabled?: Maybe; zimbraFeatureAppSpecificPasswordsEnabled?: Maybe; zimbraFeatureMailPriorityEnabled?: Maybe; + zimbraMailAlias?: Maybe>>; }; export enum AccountType { diff --git a/src/schema/schema.graphql b/src/schema/schema.graphql index 455fce936..cb139016c 100644 --- a/src/schema/schema.graphql +++ b/src/schema/schema.graphql @@ -1155,6 +1155,7 @@ type AccountInfoAttrs { zimbraFeatureTrustedDevicesEnabled: Boolean zimbraFeatureAppSpecificPasswordsEnabled: Boolean zimbraFeatureMailPriorityEnabled: Boolean + zimbraMailAlias: [String] } type Identities { From 1f16e8c5e0d24506f0a80dd09c5bef8956d48d8f Mon Sep 17 00:00:00 2001 From: Santosh Shetty Date: Fri, 22 Nov 2019 16:07:21 +0530 Subject: [PATCH 3/3] PREAPPS-3714: Lint fix --- src/batch-client/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/batch-client/index.ts b/src/batch-client/index.ts index b59f9c259..d11bbeba9 100644 --- a/src/batch-client/index.ts +++ b/src/batch-client/index.ts @@ -215,7 +215,9 @@ export class ZimbraBatchClient { sections: 'mbox,attrs,zimlets' } }).then(res => { - const { attrs: { _attrs } } = res; + const { + attrs: { _attrs } + } = res; if (typeof _attrs.zimbraMailAlias === 'string') { // Server returns `zimbraMailAlias` as `string` if only one alias is present, else returns as `array`.