generated from lucien/api-template
add: added image attachments to messages
This commit is contained in:
parent
8f77a271e1
commit
fb90f1ef4f
10 changed files with 169 additions and 10 deletions
|
@ -617,6 +617,20 @@ function deleteUnusedAttachments(connection) {
|
|||
});
|
||||
}
|
||||
|
||||
function getUnusedAttachments(connection) {
|
||||
return new Promise((resolve, reject) => {
|
||||
connection.query(
|
||||
`SELECT * FROM attachments WHERE message_id IS NULL`,
|
||||
(error, result) => {
|
||||
if (error) {
|
||||
reject(new Error(error));
|
||||
}
|
||||
resolve(result);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function getMessageAttachments(connection, message_id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
connection.query(
|
||||
|
@ -632,6 +646,21 @@ function getMessageAttachments(connection, message_id) {
|
|||
});
|
||||
}
|
||||
|
||||
function getAttachment(connection, file_name) {
|
||||
return new Promise((resolve, reject) => {
|
||||
connection.query(
|
||||
`SELECT * FROM attachments WHERE file_name = ?`,
|
||||
[file_name],
|
||||
(error, result) => {
|
||||
if (error) {
|
||||
reject(new Error(error));
|
||||
}
|
||||
resolve(result);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getConnection,
|
||||
|
||||
|
@ -672,4 +701,10 @@ module.exports = {
|
|||
getEmoji,
|
||||
getEmojiByName,
|
||||
searchEmojis,
|
||||
|
||||
addAttachment,
|
||||
deleteUnusedAttachments,
|
||||
getUnusedAttachments,
|
||||
getMessageAttachments,
|
||||
getAttachment,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue