Fix database helpers

pull/451/head
Beaudan Brown 6 years ago
parent 63293c5b03
commit 6392c77952

@ -790,7 +790,7 @@ async function updateToLokiSchemaVersion1(currentVersion, instance) {
await instance.run(
`ALTER TABLE messages
ADD COLUMN serverId STRING;`
ADD COLUMN serverId INTEGER;`
);
await instance.run(
@ -2060,11 +2060,14 @@ async function removeMessage(id) {
);
}
async function getMessageByServerId(serverId) {
async function getMessageByServerId(serverId, conversationId) {
const row = await db.get(
'SELECT * FROM messages WHERE serverId = $serverId;',
`SELECT * FROM messages WHERE
serverId = $serverId AND
conversationId = $conversationId;`,
{
$serverId: serverId,
$conversationId: conversationId,
}
);

@ -908,8 +908,8 @@ async function _removeMessages(ids) {
await channels.removeMessage(ids);
}
async function getMessageByServerId(id, { Message }) {
const message = await channels.getMessageByServerId(id);
async function getMessageByServerId(serverId, conversationId, { Message }) {
const message = await channels.getMessageByServerId(serverId, conversationId);
if (!message) {
return null;
}

Loading…
Cancel
Save