gmail-api-parse-message-ts
Advanced tools
Comparing version 2.2.28 to 2.2.29
# Versions | ||
## 2.2.29 | ||
reversal on 2.2.28. Emails are by default checked for validity, however optional parameter checkIfEmailIsValid can be set to false, whereby emails are not checked, and isValid is set to true. ParseGmailApi.parseMessage() always set isValid=true (without checking). | ||
## 2.2.28 | ||
@@ -4,0 +7,0 @@ @IReceiver.isValid is now required (was optional). Set is as true as default by ParseGmailApi.parseMessage(). Validation appears to be redundant, as emails from the gmail api, should be correct |
@@ -34,6 +34,10 @@ import { IEmail } from './iface/iemail'; | ||
private parseHeaders; | ||
/** converts are string container emails, and returns them as IReceivers[] */ | ||
parseReceivers(receiverStr?: string): IReceiver[]; | ||
/** converts are string container emails, and returns them as IReceivers[] | ||
* Emails are by default checked for validity, however optional parameter | ||
* checkIfEmailIsValid can be set to false, whereby emails are not checked, | ||
* and isValid is set to true. ParseGmailApi.parseMessage() always set isValid=true | ||
* without checking */ | ||
parseReceivers(receiverStr?: string, checkIfEmailIsValid?: boolean): IReceiver[]; | ||
private removeUnwantedCharsFromName; | ||
isEmailUnread(labels: string[]): boolean; | ||
} |
@@ -139,6 +139,6 @@ "use strict"; | ||
parseHeaders(email) { | ||
email.from = this.parseReceivers(email.headers.get('from'))[0] || []; // should be ok? | ||
email.to = this.parseReceivers(email.headers.get('to')); | ||
email.cc = this.parseReceivers(email.headers.get('cc')); | ||
email.bcc = this.parseReceivers(email.headers.get('bcc')); | ||
email.from = this.parseReceivers(email.headers.get('from'), false)[0] || []; // should be ok? | ||
email.to = this.parseReceivers(email.headers.get('to'), false); | ||
email.cc = this.parseReceivers(email.headers.get('cc'), false); | ||
email.bcc = this.parseReceivers(email.headers.get('bcc'), false); | ||
email.sentDate = parseInt(email.headers.get('date') || ''); | ||
@@ -158,4 +158,8 @@ if (!email.sentDate) { | ||
} | ||
/** converts are string container emails, and returns them as IReceivers[] */ | ||
parseReceivers(receiverStr = "") { | ||
/** converts are string container emails, and returns them as IReceivers[] | ||
* Emails are by default checked for validity, however optional parameter | ||
* checkIfEmailIsValid can be set to false, whereby emails are not checked, | ||
* and isValid is set to true. ParseGmailApi.parseMessage() always set isValid=true | ||
* without checking */ | ||
parseReceivers(receiverStr = "", checkIfEmailIsValid = true) { | ||
const receivers = []; | ||
@@ -174,3 +178,7 @@ if (!receiverStr) { | ||
resp.name = this.removeUnwantedCharsFromName(resp.name); | ||
receivers.push({ name: resp.name, email: resp.email, isValid: true }); | ||
receivers.push({ | ||
name: resp.name, | ||
email: resp.email, | ||
isValid: checkIfEmailIsValid ? this.isEmailValid(resp.email) : true | ||
}); | ||
} | ||
@@ -177,0 +185,0 @@ return receivers; |
{ | ||
"name": "gmail-api-parse-message-ts", | ||
"version": "2.2.28", | ||
"version": "2.2.29", | ||
"description": "Parses Gmail API's GET method to iGmail object. Typescript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -34,2 +34,15 @@ [![npm][npm]][npm-url] | ||
} | ||
/** converts are string container emails, and returns them as IReceivers[] | ||
* Emails are by default checked for validity, however optional parameter | ||
* checkIfEmailIsValid can be set to false, whereby emails are not checked, | ||
* and isValid is set to true. ParseGmailApi.parseMessage() always set isValid=true | ||
* without checking */ | ||
public parseReceivers(receiverStr: string = "", checkIfEmailIsValid: boolean = true): IReceiver[] | ||
/** check whether an email address is valid, exposes func from klingsten snippets | ||
* see https://bitbucket.org/LarsKlingsten/klingsten-snippets-ts/src/master/src/strings.ts */ | ||
public isEmailValid(s: string): boolean { | ||
return Strings.isEmailValid(s); | ||
} | ||
} | ||
@@ -36,0 +49,0 @@ ``` |
Sorry, the diff of this file is not supported yet
39160
479
171