Incoming filename fixes
This commit is contained in:
parent
d2a3c71bcd
commit
6f0f97ab7b
4 changed files with 124 additions and 106 deletions
|
|
@ -24,8 +24,23 @@ const fetchAttachments = async (attachments: any[] | undefined) => {
|
|||
const arrayBuffer = await blob.arrayBuffer();
|
||||
const base64Attachment = Buffer.from(arrayBuffer).toString("base64");
|
||||
|
||||
// Generate default filename if not provided by Signal API
|
||||
let defaultFilename = name;
|
||||
if (!defaultFilename) {
|
||||
// Check if id already has an extension
|
||||
const hasExtension = id.includes('.');
|
||||
if (hasExtension) {
|
||||
// ID already includes extension
|
||||
defaultFilename = id;
|
||||
} else {
|
||||
// Add extension based on content type
|
||||
const extension = contentType?.split('/')[1] || 'bin';
|
||||
defaultFilename = `${id}.${extension}`;
|
||||
}
|
||||
}
|
||||
|
||||
const formattedAttachment = {
|
||||
filename: name,
|
||||
filename: defaultFilename,
|
||||
mimeType: contentType,
|
||||
attachment: base64Attachment,
|
||||
};
|
||||
|
|
@ -62,7 +77,7 @@ const processMessage = async ({
|
|||
const { attachments } = dataMessage;
|
||||
const rawTimestamp = dataMessage?.timestamp;
|
||||
|
||||
logger.debug({
|
||||
logger.debug({
|
||||
sourceUuid,
|
||||
source,
|
||||
rawTimestamp,
|
||||
|
|
@ -160,7 +175,7 @@ const fetchSignalMessagesTask = async ({
|
|||
});
|
||||
for (const formattedMessage of formattedMessages) {
|
||||
if (formattedMessage.to !== formattedMessage.from) {
|
||||
logger.debug({
|
||||
logger.debug({
|
||||
messageId: formattedMessage.messageId,
|
||||
from: formattedMessage.from,
|
||||
to: formattedMessage.to,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue