Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PREAPPS-7390: Remove "/@zimbra" dependency from dev proxy #594

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/batch-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ import {

import { CASTING_PREFS } from './constants';
import { Notifier } from './notifier';

const DEBUG = false;

function normalizeMessage(
Expand Down Expand Up @@ -286,8 +285,10 @@ export class ZimbraBatchClient {
public localStoreClient: any;
public notifier: Notifier;
public origin: string;
public serverUrl: string;
public sessionId: any;
public soapPathname: string;
private agent?: any;
private authToken?: string;
private batchDataLoader: DataLoader<RequestOptions, RequestBody>;
private csrfToken?: string;
Expand All @@ -298,6 +299,7 @@ export class ZimbraBatchClient {
private userAgent?: {};

constructor(options: ZimbraClientOptions = {}) {
this.serverUrl = options.serverUrl !== undefined ? options.serverUrl : '';
this.sessionHandler = options.sessionHandler;
this.userAgent = options.userAgent;
this.jwtToken = options.jwtToken;
Expand All @@ -307,6 +309,7 @@ export class ZimbraBatchClient {
this.soapPathname = options.soapPathname || DEFAULT_SOAP_PATHNAME;
this.localStoreClient = options.localStoreClient;
this.customFetch = options.customFetch;
this.agent = options.agent;

this.notifier = new Notifier();

Expand Down Expand Up @@ -1895,7 +1898,7 @@ export class ZimbraBatchClient {
singleRequest: true
}).then(res => mapValuesDeep(get(res, `${accountType}.0`), coerceStringToBoolean));

public uploadMessage = (message: string): any => {
public uploadMessage = (message: string, agent: any = null): any => {
const contentDisposition = 'attachment';
const filename = 'message.eml';
const contentType = 'message/rfc822';
Expand All @@ -1913,6 +1916,7 @@ export class ZimbraBatchClient {
'X-Zimbra-Csrf-Token': this.csrfToken
})
},
...(agent && { agent }),
credentials: 'include'
}).then((response: any) => {
if (response.ok) {
Expand Down Expand Up @@ -2038,7 +2042,8 @@ export class ZimbraBatchClient {
userAgent: this.userAgent,
...(typeof this.notifier.getSequenceNumber() !== 'undefined' && {
sessionSeq: this.notifier.getSequenceNumber()
})
}),
agent: this.agent
});

private normalizeConversation = (conversation: { [key: string]: any }) => {
Expand Down
2 changes: 2 additions & 0 deletions src/batch-client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ export type SessionHandler = {
};

export interface ZimbraClientOptions {
agent?: any;
authToken?: string;
csrfToken?: string;
customFetch?: any;
jwtToken?: string;
localStoreClient?: any;
notificationHandler?: NotificationHandler;
serverUrl?: string;
sessionHandler?: SessionHandler;
soapPathname?: string;
userAgent?: UserAgent;
Expand Down
7 changes: 5 additions & 2 deletions src/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
SingleBatchRequestResponse,
SOAPHeader
} from './types';
export const DEFAULT_HOSTNAME = '/@zimbra';
export const DEFAULT_HOSTNAME = '';
export const DEFAULT_SOAP_PATHNAME = '/service/soap';

let customFetch: any;
Expand Down Expand Up @@ -263,7 +263,10 @@ export function jsonRequest(requestOptions: JsonRequestOptions): Promise<Request
Header: header
}),
headers: options.headers,
...(fetchOptions && fetchOptions)
...(fetchOptions && fetchOptions),
...(requestOptions.agent && {
agent: requestOptions.agent
})
})
.then(parseJSON)
.then((response: any) => {
Expand Down
1 change: 1 addition & 0 deletions src/request/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface UserAgent {
export interface BaseRequestOptions {
accountId?: string;
accountName?: string | null;
agent?: any;
authToken?: string;
credentials?: RequestCredentials;
csrfToken?: string | null;
Expand Down