start to load messages from rooms

This commit is contained in:
grimhilt
2023-03-20 21:28:13 +01:00
parent 9b3ddd291e
commit d6f06f3ca6
15 changed files with 4441 additions and 4401 deletions

View File

@@ -44,8 +44,39 @@ async function getRooms(mailboxId) {
return await execQueryAsync(query, values);
}
async function getMessages(roomId) {
// todo attachements name
const query = `
SELECT
address_field.address_id,
bodypart.text,
header_field.value
FROM bodypart
INNER JOIN header_field
INNER JOIN address_field
INNER JOIN field_name
WHERE
(
header_field.field_id = field_name.field_id OR
address_field.field_id = field_name.field_id
) AND
(
field_name.field_name = 'html' OR
field_name.field_name = 'text' OR
field_name.field_name = 'textAsHtml' OR
field_name.field_name = 'to' OR
field_name.field_name = 'cc' OR
field_name.field_name = 'subject'
)
`;
// todo roomID
const values = [];
return await execQueryAsync(query, values);
}
module.exports = {
registerMailbox,
getMailboxes,
getRooms
getRooms,
getMessages
};

View File

@@ -16,6 +16,7 @@ function registerMailbox_message(mailboxId, uid, messageId, modseq, seen, delete
INSERT IGNORE INTO mailbox_message
(mailbox_id, uid, message_id, modseq, seen, deleted) VALUES (1, 19, 10, '12450', 0, 0)
`;
// todo
const values = [mailboxId, uid, messageId, modseq, seen, deleted];
execQuery(query, values);
}
@@ -30,7 +31,7 @@ function registerBodypart(messageId, part, bodypartId, bytes, nbLines) {
}
async function saveBodypart(bytes, hash, text, data) {
const query = `INSERT IGNORE INTO bodypart (bytes, hash, text, data) VALUES (?, ?, ?,)`;
const query = `INSERT IGNORE INTO bodypart (bytes, hash, text, data) VALUES (?, ?, ?, ?)`;
const values = [bytes, hash, text, data];
return await execQueryAsyncWithId(query, values);
}