revert
This commit is contained in:
parent
ef822a1c3c
commit
98293e5e96
@ -7,15 +7,23 @@ exports.register = function () {
|
|||||||
if (!transaction) return next();
|
if (!transaction) return next();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Get the raw email content
|
// Get the full message body
|
||||||
const body = await new Promise((resolve, reject) => {
|
let body = '';
|
||||||
let messageContent = '';
|
|
||||||
transaction.message_stream.on('data', chunk => {
|
if (transaction.message_stream) {
|
||||||
messageContent += chunk.toString();
|
// Convert Buffer to string and handle JSON stringification properly
|
||||||
});
|
if (Buffer.isBuffer(transaction.message_stream)) {
|
||||||
transaction.message_stream.on('end', () => resolve(messageContent));
|
body = transaction.message_stream.toString('utf8');
|
||||||
transaction.message_stream.on('error', reject);
|
} else if (typeof transaction.message_stream === 'object') {
|
||||||
});
|
body = JSON.stringify(transaction.message_stream);
|
||||||
|
} else {
|
||||||
|
body = String(transaction.message_stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debug logging
|
||||||
|
connection.logdebug(plugin, 'Message Stream Type:', typeof transaction.message_stream);
|
||||||
|
connection.logdebug(plugin, 'Message Stream:', transaction.message_stream);
|
||||||
|
|
||||||
const messageData = {
|
const messageData = {
|
||||||
from: transaction.mail_from.address(),
|
from: transaction.mail_from.address(),
|
||||||
@ -25,6 +33,11 @@ exports.register = function () {
|
|||||||
headers: transaction.header ? transaction.header.headers_decoded : {},
|
headers: transaction.header ? transaction.header.headers_decoded : {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Debug logging
|
||||||
|
connection.logdebug(plugin, 'Message Data:');
|
||||||
|
connection.logdebug(plugin, `Body type: ${typeof body}`);
|
||||||
|
connection.logdebug(plugin, `Body content: ${body.substring(0, 100)}...`); // First 100 chars
|
||||||
|
|
||||||
await MessageService.store(messageData);
|
await MessageService.store(messageData);
|
||||||
next();
|
next();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user