don't allow suggestions without CW
This commit is contained in:
parent
bafb0e800e
commit
0a98f3a477
|
@ -80,7 +80,7 @@ const sampleNote = {
|
|||
export default class {
|
||||
constructor(raw){
|
||||
this.raw = raw
|
||||
logger.trace({id:raw.id},"new note cosntructed!")
|
||||
logger.trace({id:raw.id},"new note constructed!")
|
||||
}
|
||||
|
||||
#handle = /@[a-z,A-Z,0-9]* /g
|
||||
|
@ -113,4 +113,8 @@ get author(){
|
|||
return this.raw.user.username
|
||||
}
|
||||
|
||||
get hasCW(){
|
||||
return this.raw.cw===""?false:true
|
||||
}
|
||||
|
||||
}
|
|
@ -6,6 +6,10 @@ import { getDatePublished, wordIsAlreadyInBuffer, getAcceptablePrompts, valueExi
|
|||
|
||||
export default async function handleMentions(body) {
|
||||
const note = new Note(body.note)
|
||||
if(!note.hasCW){
|
||||
createNote("Please put your prompt suggestions behind a CW. No spoilers!")
|
||||
return {code: "NOCW"}
|
||||
}
|
||||
if (!note.isSingleWord) {
|
||||
createNote("If you're trying to suggest a prompt, please message me a with *single word*.",note.id)
|
||||
return { code: "NOTONEWORD" }
|
||||
|
@ -39,7 +43,7 @@ export default async function handleMentions(body) {
|
|||
createNote(`I already used that prompt on ${datePublished}, actually!`,note.id)
|
||||
return {code: "PUBLISHED"}
|
||||
}
|
||||
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 quirky or not quirky enough. Them's the breaks.`,note.id)
|
||||
return { code: "RARITY" }
|
||||
} else {
|
||||
await insertIntoBuffer(word,isoDate())
|
||||
|
|
|
@ -149,5 +149,14 @@ describe("Testing Note getters", function () {
|
|||
expect(N1.id).to.equal('9id213fllx9y189f')
|
||||
done()
|
||||
})
|
||||
it("15. .hasCW should return true", function (done) {
|
||||
expect(N1.hasCW).to.equal(true)
|
||||
done()
|
||||
})
|
||||
it("16. .hasCW should return false", function (done) {
|
||||
N1.raw.cw = ""
|
||||
expect(N1.hasCW).to.equal(false)
|
||||
done()
|
||||
})
|
||||
|
||||
})
|
|
@ -137,6 +137,13 @@ describe("Testing handleMentions responses", async function(){
|
|||
expect(result.code).to.equal("PUBLISHED")
|
||||
//done()
|
||||
})
|
||||
it("9. handleMentions() returns code NOCW when cw = ''", async function(){
|
||||
sampleBody.note.cw = ""
|
||||
const result = await handleMentions(sampleBody)
|
||||
expect(result.code).to.equal("NOCW")
|
||||
//done()
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue