successful suggestions now added to buffer
This commit is contained in:
parent
764be98422
commit
b565408a31
|
@ -52,13 +52,13 @@ export const getWords = async () => {
|
|||
|
||||
export const insertIntoBuffer = async (word,timestamp) => {
|
||||
try {
|
||||
db
|
||||
return db('buffer')
|
||||
.insert({
|
||||
word,
|
||||
timestamp
|
||||
word:word,
|
||||
timestamp:timestamp
|
||||
})
|
||||
.into('buffer')
|
||||
} catch (error) {
|
||||
logger.error("buffer insert failed!")
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
@ -124,6 +124,7 @@ export const deleteFromBuffer = async (word) => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
export const getDatePublished = async (word) => {
|
||||
try {
|
||||
return db('published')
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import logger from "../logger.mjs"
|
||||
import { isoDate } from "../utilities.mjs"
|
||||
import Note from "./Note.mjs"
|
||||
import createNote from "../firefish-calls/createNote.mjs"
|
||||
import { getDatePublished, wordIsAlreadyInBuffer, getAcceptablePrompts, valueExistsInColumn } from "../database-calls/db.mjs"
|
||||
import { getDatePublished, wordIsAlreadyInBuffer, getAcceptablePrompts, valueExistsInColumn, insertIntoBuffer } from "../database-calls/db.mjs"
|
||||
|
||||
export default async function handleMentions(body) {
|
||||
const note = new Note(body.note)
|
||||
|
@ -41,7 +42,8 @@ export default async function handleMentions(body) {
|
|||
createNote(`I'm afraid I can't do that, ${note.author}. The word you've suggested is either too common or too uncommon. Standards must be maintained!`,note.id)
|
||||
return { code: "RARITY" }
|
||||
} else {
|
||||
createNote(`OK!`,note.id)
|
||||
await insertIntoBuffer(word,isoDate())
|
||||
await createNote(`OK!`,note.id)
|
||||
return { code: "OK" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import handleMentions from "../social-interaction/handleMention.mjs";
|
||||
import { expect } from "chai";
|
||||
import { insertIntoBuffer } from "../database-calls/db.mjs";
|
||||
const sampleBody = {
|
||||
note: {
|
||||
"id": "9id213fllx9y189f",
|
||||
|
|
Loading…
Reference in New Issue