w
This commit is contained in:
+9
-10
@@ -91,9 +91,7 @@ export class EwsClient {
|
||||
return this.config.domain ?? "corp";
|
||||
}
|
||||
|
||||
private async soapRequest(body: string, soapAction: string): Promise<any> {
|
||||
const envelope = buildSoapEnvelope(body);
|
||||
|
||||
private async soapRequest(body: string, soapAction: string): Promise<any> {
|
||||
const res = await postAsync({
|
||||
url: this.ewsUrl,
|
||||
username: this.config.username,
|
||||
@@ -104,14 +102,15 @@ export class EwsClient {
|
||||
"Content-Type": "text/xml; charset=utf-8",
|
||||
SOAPAction: soapAction,
|
||||
},
|
||||
body: envelope,
|
||||
body,
|
||||
});
|
||||
|
||||
if (typeof res.body !== "string") {
|
||||
throw new Error(`NTLM request failed, status=${res.statusCode}`);
|
||||
}
|
||||
|
||||
return PARSER.parse(res.body);
|
||||
const parsed = PARSER.parse(res.body);
|
||||
return parsed;
|
||||
}
|
||||
|
||||
private extractResponseMessages(data: any): any[] {
|
||||
@@ -131,12 +130,12 @@ export class EwsClient {
|
||||
return Array.isArray(msgs) ? msgs : [msgs];
|
||||
}
|
||||
|
||||
async verifyConnection(): Promise<boolean> {
|
||||
async verifyConnection(): Promise<{ ok: boolean; error?: string }> {
|
||||
try {
|
||||
await this.getFolderId("inbox");
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
return { ok: true };
|
||||
} catch (error: any) {
|
||||
return { ok: false, error: error.message ?? String(error) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +154,7 @@ export class EwsClient {
|
||||
</m:FolderIds>
|
||||
</m:GetFolder>`);
|
||||
|
||||
const data = await this.soapRequest(
|
||||
const data = await this.soapRequest(
|
||||
soap,
|
||||
"http://schemas.microsoft.com/exchange/services/2006/messages/GetFolder",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user