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) => {
|
export const insertIntoBuffer = async (word,timestamp) => {
|
||||||
try {
|
try {
|
||||||
db
|
return db('buffer')
|
||||||
.insert({
|
.insert({
|
||||||
word,
|
word:word,
|
||||||
timestamp
|
timestamp:timestamp
|
||||||
})
|
})
|
||||||
.into('buffer')
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
logger.error("buffer insert failed!")
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,7 @@ export const deleteFromBuffer = async (word) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const getDatePublished = async (word) => {
|
export const getDatePublished = async (word) => {
|
||||||
try {
|
try {
|
||||||
return db('published')
|
return db('published')
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import logger from "../logger.mjs"
|
import logger from "../logger.mjs"
|
||||||
|
import { isoDate } from "../utilities.mjs"
|
||||||
import Note from "./Note.mjs"
|
import Note from "./Note.mjs"
|
||||||
import createNote from "../firefish-calls/createNote.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) {
|
export default async function handleMentions(body) {
|
||||||
const note = new Note(body.note)
|
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)
|
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" }
|
return { code: "RARITY" }
|
||||||
} else {
|
} else {
|
||||||
createNote(`OK!`,note.id)
|
await insertIntoBuffer(word,isoDate())
|
||||||
|
await createNote(`OK!`,note.id)
|
||||||
return { code: "OK" }
|
return { code: "OK" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import handleMentions from "../social-interaction/handleMention.mjs";
|
import handleMentions from "../social-interaction/handleMention.mjs";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import { insertIntoBuffer } from "../database-calls/db.mjs";
|
|
||||||
const sampleBody = {
|
const sampleBody = {
|
||||||
note: {
|
note: {
|
||||||
"id": "9id213fllx9y189f",
|
"id": "9id213fllx9y189f",
|
||||||
|
|
Loading…
Reference in New Issue