arn-rawmime 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -71,6 +71,8 @@ export interface ParsedMailData {
|
|
|
71
71
|
trafficSource: "dbr-w4m" | "dbr-m4w" | "other";
|
|
72
72
|
/** Status, set to 'bounce' if email is a bounce notification */
|
|
73
73
|
status: "bounce" | undefined;
|
|
74
|
+
/** First @username handle found in the HTML body (without @ prefix, trimmed), or null if none found */
|
|
75
|
+
username: string | null;
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
/**
|
|
@@ -161,6 +161,22 @@ export const parseMail = async ({ rawData }) => {
|
|
|
161
161
|
}
|
|
162
162
|
if (!originalPostId) originalPostId = subjectPostId;
|
|
163
163
|
|
|
164
|
+
// --- 7b. Extract Username (first @handle in HTML, fallback to text) ---
|
|
165
|
+
let username = null;
|
|
166
|
+
const usernameRegex = /(?<![a-zA-Z0-9._%+-])@([a-zA-Z0-9_]+)/;
|
|
167
|
+
if (html) {
|
|
168
|
+
const usernameMatch = html.match(usernameRegex);
|
|
169
|
+
if (usernameMatch && usernameMatch[1]) {
|
|
170
|
+
username = usernameMatch[1].trim().toLowerCase();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (!username && text) {
|
|
174
|
+
const usernameMatch = text.match(usernameRegex);
|
|
175
|
+
if (usernameMatch && usernameMatch[1]) {
|
|
176
|
+
username = usernameMatch[1].trim().toLowerCase();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
164
180
|
// --- 8. Traffic Source ---
|
|
165
181
|
const isOfficialMailer = fromEmail === "mailer@mailersp.doublelist.com" || fromEmail === "robot@doublelist.com";
|
|
166
182
|
if (isOfficialMailer && mail.replyTo?.value[0]?.address) {
|
|
@@ -207,6 +223,7 @@ export const parseMail = async ({ rawData }) => {
|
|
|
207
223
|
envelopeToDomain,
|
|
208
224
|
trafficSource,
|
|
209
225
|
status,
|
|
226
|
+
username,
|
|
210
227
|
},
|
|
211
228
|
error: null,
|
|
212
229
|
};
|