Throw exception when error code is not defined in messaging import

This commit is contained in:
Charles Bochet 2024-06-08 23:46:52 +02:00
parent a79b256409
commit d7ce42cff7

View File

@ -181,11 +181,14 @@ export class MessagingGmailFetchMessagesByBatchesService {
const historyId = message.historyId; const historyId = message.historyId;
const internalDate = message.internalDate; const internalDate = message.internalDate;
assert(id); assert(id, 'ID is missing');
assert(messageId); assert(
assert(threadId); messageId,
assert(historyId); 'Message-ID is missing: ' + JSON.stringify(message.payload?.headers),
assert(internalDate); );
assert(threadId, 'Thread-ID is missing');
assert(historyId, 'History-ID is missing');
assert(internalDate, 'Internal date is missing');
const bodyData = this.getBodyData(message); const bodyData = this.getBodyData(message);
const text = bodyData ? Buffer.from(bodyData, 'base64').toString() : ''; const text = bodyData ? Buffer.from(bodyData, 'base64').toString() : '';