diff --git a/data/database-testing b/data/database-testing new file mode 100644 index 0000000..5a911f3 Binary files /dev/null and b/data/database-testing differ diff --git a/database-calls/db.mjs b/database-calls/db.mjs index 5b6e3e8..fc1c1ba 100644 --- a/database-calls/db.mjs +++ b/database-calls/db.mjs @@ -7,6 +7,7 @@ export const db = Knex({ client: 'sqlite3', // or 'better-sqlite3' connection: { filename: "data/database" + //filename: "data/database-testing" }, useNullAsDefault: true }) @@ -49,7 +50,18 @@ export const getWords = async () => { .catch(error => { throw error }) } - +export const insertIntoBuffer = async (word,timestamp) => { + try { + db + .insert({ + word, + timestamp + }) + .into('buffer') + } catch (error) { + throw error + } +} @@ -109,3 +121,12 @@ export const deleteFromBuffer = async (word) => { } } +export const getDatePublished = async (word) => { + try { + return db('published') + .select('date') + .where('word',word) + } catch (error) { + throw error + } +} diff --git a/firefish-calls/createNote.mjs b/firefish-calls/createNote.mjs index 690c106..28061b7 100644 --- a/firefish-calls/createNote.mjs +++ b/firefish-calls/createNote.mjs @@ -12,12 +12,13 @@ import logger from '../logger.mjs' -export default async function createNote(text) { +export default async function createNote(text,replyId) { logger.trace("createNote called") const body = { text: text, cw:"Today's #micro365 prompt is:" } + if(replyId){body.replyId=replyId} try { const response = await firefish.post("notes/create",body) logger.info({ diff --git a/index.mjs b/index.mjs index fe09fed..a71cd96 100644 --- a/index.mjs +++ b/index.mjs @@ -3,7 +3,7 @@ import bodyParser from "body-parser"; import logger from "./logger.mjs"; import pinoHTTP from 'pino-http' import start from "./start.mjs"; -import receiveMention from "./social-interaction/receiveMention.mjs"; +import handleMention from "./social-interaction/handleMention.mjs"; const app = express() const port = 4000 app.use(bodyParser.json()) @@ -12,12 +12,11 @@ app.use( logger, }) ) -app.post('/api', (req,res) => { - //receiveMention(req.body) +app.post('/api', async (req,res) => { logger.info({body:req.body.body},"webhook received!") - //logger.info(req.body.body) - //logger.info("webhook received:",req.body.body.note.text) res.sendStatus(200) + const result = await handleMention(req.body.body) + logger.info(`handleMention returned ${result.code}`) }) app.listen(port, () => { diff --git a/logger.mjs b/logger.mjs index 3c1b596..4a8fd4b 100644 --- a/logger.mjs +++ b/logger.mjs @@ -16,7 +16,7 @@ const __dirname = path.dirname(__filename); // }) export default pino( { - level: 'trace', + level: 'info', formatters: { level: (label) => { return { level: label.toUpperCase() }; diff --git a/package.json b/package.json index 3b1b38c..0a7b528 100644 --- a/package.json +++ b/package.json @@ -4,21 +4,21 @@ "description": "a server that delivers daily writing prompts via REST API", "main": "index.js", "scripts": { - "test": "mocha" + "test": "mocha --timeout 15000" }, "author": "Andrzej Stepien", "license": "GPL-3.0-or-later", "devDependencies": { - "knex": "^2.5.1", - "spellchecker": "^3.7.1", - "sqlite3": "^5.1.6" + "chai": "^4.3.7", + "mocha": "^10.2.0" }, "dependencies": { "axios": "^1.4.0", + "sqlite3": "^5.1.6", "body-parser": "^1.20.2", - "chai": "^4.3.7", + "spellchecker": "^3.7.1", "express": "^4.18.2", - "mocha": "^10.2.0", + "knex": "^2.5.1", "node-cron": "^3.0.2", "pino": "^8.15.0", "pino-http": "^8.4.0", diff --git a/social-interaction/Note.mjs b/social-interaction/Note.mjs index 470c603..223f95d 100644 --- a/social-interaction/Note.mjs +++ b/social-interaction/Note.mjs @@ -1,4 +1,5 @@ import { isMisspelled } from "spellchecker" +import logger from "../logger.mjs" const sampleNote = { "id": "9id213fllx9y189f", "createdAt": "2023-08-13T13:37:09.537Z", @@ -79,6 +80,7 @@ const sampleNote = { export default class { constructor(raw){ this.raw = raw + logger.trace({id:raw.id},"new note cosntructed!") } #handle = /@[a-z,A-Z,0-9]* /g @@ -100,11 +102,15 @@ get id(){ } get isSingleWord() { - return this.cleanText.match(/[a-z]+/ig).length===1 + return this.cleanText.match(/[a-z]+/ig)?.length===1 } get isRealWord(){ return !isMisspelled(this.cleanText) } +get author(){ + return this.raw.user.username +} + } \ No newline at end of file diff --git a/social-interaction/handleMention.mjs b/social-interaction/handleMention.mjs new file mode 100644 index 0000000..f697ba0 --- /dev/null +++ b/social-interaction/handleMention.mjs @@ -0,0 +1,124 @@ +import logger from "../logger.mjs" +import Note from "./Note.mjs" +import createNote from "../firefish-calls/createNote.mjs" +import { getDatePublished, wordIsAlreadyInBuffer, getAcceptablePrompts, valueExistsInColumn } from "../database-calls/db.mjs" + +export default async function handleMentions(body) { + const note = new Note(body.note) + if (!note.isSingleWord) { + createNote("If you're trying to suggest a prompt, please message me a with *single word*.",note.id) + return { code: "NOTONEWORD" } + } + if (!note.isRealWord) { + createNote(`I'm afraid I can't do that, ${note.author}. That's not a 'real' word, at least as far as I'm aware! Have you checked the spelling? + You might just be too cool for me.`,note.id) + return { code: "NOTREAL" } + } + const word = note.cleanText + if (await wordIsAlreadyInBuffer(word)) { + createNote(`Believe it or not, somebody has already suggested that! Watch this space!`,note.id) + return { code: "INBUFFER" } + } + let unacceptable = await getAcceptablePrompts(word) + unacceptable = unacceptable.length===0 + if (unacceptable) { + if (await valueExistsInColumn('medical_dictionary', 'word', word)) { + createNote("I'm afraid I can't use any word that appears in my medical dictionary. I know this delivers some false positives, but it was the only way to avoid accidentally triggering people!",note.id) + return { code: "MEDICAL" } + } + if (await valueExistsInColumn('bad_words', 'word', word)) { + createNote("That word is on my blocklist.",note.id) + return { code: "BLOCKLIST" } + } + if(await valueExistsInColumn('published','word',word)){ + let datePublished = await getDatePublished(word) + datePublished = datePublished[0].date + 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) + return { code: "RARITY" } + } else { + createNote(`OK!`,note.id) + return { code: "OK" } + } +} +const sampleBody = { + note: { + "id": "9id213fllx9y189f", + "createdAt": "2023-08-13T13:37:09.537Z", + "userId": "9i5z4skgqvv58swy", + "user": { + "id": "9i5z4skgqvv58swy", + "name": null, + "username": "admin", + "host": null, + "avatarUrl": "https://localhost:3000/identicon/9i5z4skgqvv58swy", + "avatarBlurhash": null, + "avatarColor": null, + "isAdmin": true, + "isLocked": false, + "speakAsCat": true, + "emojis": [], + "onlineStatus": "online", + "driveCapacityOverrideMb": null + }, + "text": "@micro365 bananas", + "cw": "Today's #micro365 prompt is:", + "visibility": "public", + "renoteCount": 0, + "repliesCount": 0, + "reactions": {}, + "reactionEmojis": [], + "emojis": [], + "tags": [ + "micro365" + ], + "fileIds": [], + "files": [], + "replyId": "9id1ffugrao33bm4", + "renoteId": null, + "mentions": [ + "9i5z5o9zy11l3skl" + ], + "reply": { + "id": "9id1ffugrao33bm4", + "createdAt": "2023-08-13T13:20:19.192Z", + "userId": "9i5z5o9zy11l3skl", + "user": { + "id": "9i5z5o9zy11l3skl", + "name": null, + "username": "micro365", + "host": null, + "avatarUrl": "https://localhost:3000/files/thumbnail-4e0e8b82-df72-48f7-8100-b7515173da9d", + "avatarBlurhash": "ySPjGct7xu%M-;xu-;%MRjWBoffQofWB~qRjRjayRjfQM{M{t7ofWBt7ayfQ~qj[WBj[M{WBof?bofayfQM{WBfQt7xuofWBofofM{", + "avatarColor": null, + "isLocked": false, + "speakAsCat": true, + "emojis": [], + "onlineStatus": "active", + "driveCapacityOverrideMb": null + }, + "text": "# $[x2 $[font.serif **nudism**]]\n/njˈuːdɪzəm/\n**noun**:\n- The belief in or practice of going nude in social, nonsexualized and frequently mixed-gender groups specifically in cultures where going nude in the social situation is not the norm.\n#writing #microfiction #vss #nudism", + "cw": "Today's #micro365 prompt is:", + "visibility": "public", + "renoteCount": 0, + "repliesCount": 0, + "reactions": {}, + "reactionEmojis": [], + "emojis": [], + "tags": [ + "writing", + "microfiction", + "vss", + "nudism", + "micro365" + ], + "fileIds": [], + "files": [], + "replyId": null, + "renoteId": null + } + } +} + diff --git a/social-interaction/receiveMention.mjs b/social-interaction/receiveMention.mjs deleted file mode 100644 index 9e5992d..0000000 --- a/social-interaction/receiveMention.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import logger from "../logger.mjs" -import { checkSpelling } from "spellchecker" -import { wordIsAlreadyInBuffer, getAcceptablePrompts } from "../database-calls/db.mjs" - -export default async function (note) { - - -} \ No newline at end of file diff --git a/social-interaction/sendReply.mjs b/social-interaction/sendReply.mjs index 8ff310c..b69213e 100644 --- a/social-interaction/sendReply.mjs +++ b/social-interaction/sendReply.mjs @@ -1,5 +1,5 @@ +import logger from "../logger.mjs" - -export default async () => { - +export default async (text) => { + logger.trace(text) } \ No newline at end of file diff --git a/test/Note.test.mjs b/test/Note.test.mjs index 0b3c042..23027ad 100644 --- a/test/Note.test.mjs +++ b/test/Note.test.mjs @@ -1,25 +1,61 @@ import Note from "../social-interaction/Note.mjs"; import { expect } from "chai"; const sampleNote = { - "id": "9id213fllx9y189f", - "createdAt": "2023-08-13T13:37:09.537Z", - "userId": "9i5z4skgqvv58swy", + "id": "9id213fllx9y189f", + "createdAt": "2023-08-13T13:37:09.537Z", + "userId": "9i5z4skgqvv58swy", + "user": { + "id": "9i5z4skgqvv58swy", + "name": null, + "username": "admin", + "host": null, + "avatarUrl": "https://localhost:3000/identicon/9i5z4skgqvv58swy", + "avatarBlurhash": null, + "avatarColor": null, + "isAdmin": true, + "isLocked": false, + "speakAsCat": true, + "emojis": [], + "onlineStatus": "online", + "driveCapacityOverrideMb": null + }, + "text": "@micro365 hello", + "cw": "Today's #micro365 prompt is:", + "visibility": "public", + "renoteCount": 0, + "repliesCount": 0, + "reactions": {}, + "reactionEmojis": [], + "emojis": [], + "tags": [ + "micro365" + ], + "fileIds": [], + "files": [], + "replyId": "9id1ffugrao33bm4", + "renoteId": null, + "mentions": [ + "9i5z5o9zy11l3skl" + ], + "reply": { + "id": "9id1ffugrao33bm4", + "createdAt": "2023-08-13T13:20:19.192Z", + "userId": "9i5z5o9zy11l3skl", "user": { - "id": "9i5z4skgqvv58swy", + "id": "9i5z5o9zy11l3skl", "name": null, - "username": "admin", + "username": "micro365", "host": null, - "avatarUrl": "https://localhost:3000/identicon/9i5z4skgqvv58swy", - "avatarBlurhash": null, + "avatarUrl": "https://localhost:3000/files/thumbnail-4e0e8b82-df72-48f7-8100-b7515173da9d", + "avatarBlurhash": "ySPjGct7xu%M-;xu-;%MRjWBoffQofWB~qRjRjayRjfQM{M{t7ofWBt7ayfQ~qj[WBj[M{WBof?bofayfQM{WBfQt7xuofWBofofM{", "avatarColor": null, - "isAdmin": true, "isLocked": false, "speakAsCat": true, "emojis": [], - "onlineStatus": "online", + "onlineStatus": "active", "driveCapacityOverrideMb": null }, - "text": "@micro365 1", + "text": "# $[x2 $[font.serif **nudism**]]\n/njˈuːdɪzəm/\n**noun**:\n- The belief in or practice of going nude in social, nonsexualized and frequently mixed-gender groups specifically in cultures where going nude in the social situation is not the norm.\n#writing #microfiction #vss #nudism", "cw": "Today's #micro365 prompt is:", "visibility": "public", "renoteCount": 0, @@ -28,106 +64,87 @@ const sampleNote = { "reactionEmojis": [], "emojis": [], "tags": [ + "writing", + "microfiction", + "vss", + "nudism", "micro365" ], "fileIds": [], "files": [], - "replyId": "9id1ffugrao33bm4", - "renoteId": null, - "mentions": [ - "9i5z5o9zy11l3skl" - ], - "reply": { - "id": "9id1ffugrao33bm4", - "createdAt": "2023-08-13T13:20:19.192Z", - "userId": "9i5z5o9zy11l3skl", - "user": { - "id": "9i5z5o9zy11l3skl", - "name": null, - "username": "micro365", - "host": null, - "avatarUrl": "https://localhost:3000/files/thumbnail-4e0e8b82-df72-48f7-8100-b7515173da9d", - "avatarBlurhash": "ySPjGct7xu%M-;xu-;%MRjWBoffQofWB~qRjRjayRjfQM{M{t7ofWBt7ayfQ~qj[WBj[M{WBof?bofayfQM{WBfQt7xuofWBofofM{", - "avatarColor": null, - "isLocked": false, - "speakAsCat": true, - "emojis": [], - "onlineStatus": "active", - "driveCapacityOverrideMb": null - }, - "text": "# $[x2 $[font.serif **nudism**]]\n/njˈuːdɪzəm/\n**noun**:\n- The belief in or practice of going nude in social, nonsexualized and frequently mixed-gender groups specifically in cultures where going nude in the social situation is not the norm.\n#writing #microfiction #vss #nudism", - "cw": "Today's #micro365 prompt is:", - "visibility": "public", - "renoteCount": 0, - "repliesCount": 0, - "reactions": {}, - "reactionEmojis": [], - "emojis": [], - "tags": [ - "writing", - "microfiction", - "vss", - "nudism", - "micro365" - ], - "fileIds": [], - "files": [], - "replyId": null, - "renoteId": null - } + "replyId": null, + "renoteId": null } +} const N1 = new Note(sampleNote) -describe("Testing Note getters", function(){ - it("1. .text returns a string", function(done){ - expect(N1.text).to.be.a("string") - done() - }) - it("2. .cleanText returns a string", function(done){ - expect(N1.cleanText).to.be.a("string") - done() - }) - it("3. .cleanText contains no @s", function(done){ - expect(/@/.test(N1.cleanText)).to.equal(false) - done() - }) - it("4 .mentioned should be array", function(done){ - expect(N1.mentioned).to.be.a('array') - done() - }) - it("5. .mentioned should have length 4 when text = '@george @paul @ringo @john how about a reunion?'", function(done){ - N1.raw.text = "@george @paul @ringo @john how about a reunion?" - expect(N1.mentioned.length).to.equal(4) - done() - }) - it("6. .mentioned should have length 2 when text = '@laurel @hardy how about a reunion?'", function(done){ - N1.raw.text = "@laurel @hardy how about a reunion?" - expect(N1.mentioned.length).to.equal(2) - done() - }) - it("7. isSingleWord should return false when text = '@laurel @hardy how about a reunion?'", function(done){ - N1.raw.text = "@laurel @hardy how about a reunion?" - expect(N1.isSingleWord).to.equal(false) - done() - }) - it("8. isSingleWord should return true when text = '@laurel @me no'", function(done){ - N1.raw.text = "@laurel @me no" - expect(N1.isSingleWord).to.equal(true) - done() - }) - it("9. isSingleWord should return true when text = 'word'", function(done){ - N1.raw.text = "word" - expect(N1.isSingleWord).to.equal(true) - done() - }) - it("10. isRealWord should return true when text = 'word'", function(done){ - N1.raw.text = "word" - expect(N1.isRealWord).to.equal(true) - done() - }) - it("11. isRealWord should return false when text = 'embiggensly'", function(done){ - N1.raw.text = "embiggensly" - expect(N1.isRealWord).to.equal(false) - done() - }) +describe("Testing Note getters", function () { + it("1. .text returns a string", function (done) { + expect(N1.text).to.be.a("string") + done() + }) + it("2. .cleanText returns a string", function (done) { + expect(N1.cleanText).to.be.a("string") + done() + }) + it("3. .cleanText contains no @s", function (done) { + expect(/@/.test(N1.cleanText)).to.equal(false) + done() + }) + it("4 .mentioned should be array", function (done) { + expect(N1.mentioned).to.be.a('array') + done() + }) + it("5. .mentioned should have length 4 when text = '@george @paul @ringo @john how about a reunion?'", function (done) { + N1.raw.text = "@george @paul @ringo @john how about a reunion?" + expect(N1.mentioned.length).to.equal(4) + done() + }) + it("6. .mentioned should have length 2 when text = '@laurel @hardy how about a reunion?'", function (done) { + N1.raw.text = "@laurel @hardy how about a reunion?" + expect(N1.mentioned.length).to.equal(2) + done() + }) + it("7. isSingleWord should return false when text = '@laurel @hardy how about a reunion?'", function (done) { + N1.raw.text = "@laurel @hardy how about a reunion?" + expect(N1.isSingleWord).to.equal(false) + done() + }) + it("8. isSingleWord should return true when text = '@laurel @me no'", function (done) { + N1.raw.text = "@laurel @me no" + expect(N1.isSingleWord).to.equal(true) + done() + }) + it("9. isSingleWord should return true when text = 'word'", function (done) { + N1.raw.text = "word" + expect(N1.isSingleWord).to.equal(true) + done() + }) + it("10. isRealWord should return true when text = 'word'", function (done) { + N1.raw.text = "word" + expect(N1.isRealWord).to.equal(true) + done() + }) + it("11. isRealWord should return false when text = 'embiggensly'", function (done) { + N1.raw.text = "embiggensly" + expect(N1.isRealWord).to.equal(false) + done() + }) + it("11.1 isRealWord should return false when text = 'awjfdihfeauigfieau'", function (done) { + N1.raw.text = "awjfdihfeauigfieau" + expect(N1.isRealWord).to.equal(false) + done() + }) + it("12. author should return a string", function (done) { + expect(N1.author).is.a('string') + done() + }) + it("13. author should return the string 'admin'", function (done) { + expect(N1.author).to.equal('admin') + done() + }) + it("14. .id should return the string '9id213fllx9y189f'", function (done) { + expect(N1.id).to.equal('9id213fllx9y189f') + done() + }) }) \ No newline at end of file diff --git a/test/handleMentions.test.mjs b/test/handleMentions.test.mjs new file mode 100644 index 0000000..62bec58 --- /dev/null +++ b/test/handleMentions.test.mjs @@ -0,0 +1,146 @@ +import handleMentions from "../social-interaction/handleMention.mjs"; +import { expect } from "chai"; +import { insertIntoBuffer } from "../database-calls/db.mjs"; +const sampleBody = { + note: { + "id": "9id213fllx9y189f", + "createdAt": "2023-08-13T13:37:09.537Z", + "userId": "9i5z4skgqvv58swy", + "user": { + "id": "9i5z4skgqvv58swy", + "name": null, + "username": "admin", + "host": null, + "avatarUrl": "https://localhost:3000/identicon/9i5z4skgqvv58swy", + "avatarBlurhash": null, + "avatarColor": null, + "isAdmin": true, + "isLocked": false, + "speakAsCat": true, + "emojis": [], + "onlineStatus": "online", + "driveCapacityOverrideMb": null + }, + "text": "@micro365 hello", + "cw": "Today's #micro365 prompt is:", + "visibility": "public", + "renoteCount": 0, + "repliesCount": 0, + "reactions": {}, + "reactionEmojis": [], + "emojis": [], + "tags": [ + "micro365" + ], + "fileIds": [], + "files": [], + "replyId": "9id1ffugrao33bm4", + "renoteId": null, + "mentions": [ + "9i5z5o9zy11l3skl" + ], + "reply": { + "id": "9id1ffugrao33bm4", + "createdAt": "2023-08-13T13:20:19.192Z", + "userId": "9i5z5o9zy11l3skl", + "user": { + "id": "9i5z5o9zy11l3skl", + "name": null, + "username": "micro365", + "host": null, + "avatarUrl": "https://localhost:3000/files/thumbnail-4e0e8b82-df72-48f7-8100-b7515173da9d", + "avatarBlurhash": "ySPjGct7xu%M-;xu-;%MRjWBoffQofWB~qRjRjayRjfQM{M{t7ofWBt7ayfQ~qj[WBj[M{WBof?bofayfQM{WBfQt7xuofWBofofM{", + "avatarColor": null, + "isLocked": false, + "speakAsCat": true, + "emojis": [], + "onlineStatus": "active", + "driveCapacityOverrideMb": null + }, + "text": "# $[x2 $[font.serif **nudism**]]\n/njˈuːdɪzəm/\n**noun**:\n- The belief in or practice of going nude in social, nonsexualized and frequently mixed-gender groups specifically in cultures where going nude in the social situation is not the norm.\n#writing #microfiction #vss #nudism", + "cw": "Today's #micro365 prompt is:", + "visibility": "public", + "renoteCount": 0, + "repliesCount": 0, + "reactions": {}, + "reactionEmojis": [], + "emojis": [], + "tags": [ + "writing", + "microfiction", + "vss", + "nudism", + "micro365" + ], + "fileIds": [], + "files": [], + "replyId": null, + "renoteId": null + } + }} + + + +describe("Testing handleMentions responses", async function(){ + + it("1. handleMentions() returns code MEDICAL when text = '@micro365 hysterectomy'", async function(){ + sampleBody.note.text = "@micro365 hysterectomy" + const result = await handleMentions(sampleBody) + expect(result.code).to.equal("MEDICAL") + //done() + }) + it("2. handleMentions() returns code BLOCKLIST when text = '@micro365 knockers'", async function(){ + sampleBody.note.text = "@micro365 knockers" + const result = await handleMentions(sampleBody) + expect(result.code).to.equal("BLOCKLIST") + //done() + }) + it("3. handleMentions() returns code RARITY when text = '@micro365 the'", async function(){ + sampleBody.note.text = "@micro365 the" + const result = await handleMentions(sampleBody) + expect(result.code).to.equal("RARITY") + //done() + }) + it("4. handleMentions() returns code INBUFFER when text = '@micro365 incapacity'", async function(){ + sampleBody.note.text = "@micro365 incapacity" + const result = await handleMentions(sampleBody) + expect(result.code).to.equal("INBUFFER") + //done() + }) + it("5. handleMentions() returns code NOTREAL when text = '@micro365 embiggensly'", async function(){ + sampleBody.note.text = "@micro365 embiggensly" + const result = await handleMentions(sampleBody) + expect(result.code).to.equal("NOTREAL") + //done() + }) + it("5.1 handleMentions() returns code NOTREAL when text = '@micro365 uydwgqi'", async function(){ + sampleBody.note.text = "@micro365 uydwgqi" + const result = await handleMentions(sampleBody) + expect(result.code).to.equal("NOTREAL") + //done() + }) + + it("6. handleMentions() returns code NOTONEWORD when text = '@micro365 apple banana'", async function(){ + sampleBody.note.text = "@micro365 apple apple" + const result = await handleMentions(sampleBody) + expect(result.code).to.equal("NOTONEWORD") + //done() + }) + it("7. handleMentions() returns code OK when text = '@micro365 howler'", async function(){ + sampleBody.note.text = "@micro365 howler" + const result = await handleMentions(sampleBody) + expect(result.code).to.equal("OK") + //done() + }) + it("8. handleMentions() returns code PUBLISHED when text = '@micro365 nudism'", async function(){ + sampleBody.note.text = "@micro365 nudism" + const result = await handleMentions(sampleBody) + expect(result.code).to.equal("PUBLISHED") + //done() + }) + + + +}) + + diff --git a/test/receiveMention.test.mjs b/test/receiveMention.test.mjs deleted file mode 100644 index 365a644..0000000 --- a/test/receiveMention.test.mjs +++ /dev/null @@ -1,80 +0,0 @@ -import { expect } from "chai"; -import receiveMention from "../social-interaction/receiveMention.mjs"; -const sampleNote = { - "id": "9id213fllx9y189f", - "createdAt": "2023-08-13T13:37:09.537Z", - "userId": "9i5z4skgqvv58swy", - "user": { - "id": "9i5z4skgqvv58swy", - "name": null, - "username": "admin", - "host": null, - "avatarUrl": "https://localhost:3000/identicon/9i5z4skgqvv58swy", - "avatarBlurhash": null, - "avatarColor": null, - "isAdmin": true, - "isLocked": false, - "speakAsCat": true, - "emojis": [], - "onlineStatus": "online", - "driveCapacityOverrideMb": null - }, - "text": "@micro365 1", - "cw": "Today's #micro365 prompt is:", - "visibility": "public", - "renoteCount": 0, - "repliesCount": 0, - "reactions": {}, - "reactionEmojis": [], - "emojis": [], - "tags": [ - "micro365" - ], - "fileIds": [], - "files": [], - "replyId": "9id1ffugrao33bm4", - "renoteId": null, - "mentions": [ - "9i5z5o9zy11l3skl" - ], - "reply": { - "id": "9id1ffugrao33bm4", - "createdAt": "2023-08-13T13:20:19.192Z", - "userId": "9i5z5o9zy11l3skl", - "user": { - "id": "9i5z5o9zy11l3skl", - "name": null, - "username": "micro365", - "host": null, - "avatarUrl": "https://localhost:3000/files/thumbnail-4e0e8b82-df72-48f7-8100-b7515173da9d", - "avatarBlurhash": "ySPjGct7xu%M-;xu-;%MRjWBoffQofWB~qRjRjayRjfQM{M{t7ofWBt7ayfQ~qj[WBj[M{WBof?bofayfQM{WBfQt7xuofWBofofM{", - "avatarColor": null, - "isLocked": false, - "speakAsCat": true, - "emojis": [], - "onlineStatus": "active", - "driveCapacityOverrideMb": null - }, - "text": "# $[x2 $[font.serif **nudism**]]\n/njˈuːdɪzəm/\n**noun**:\n- The belief in or practice of going nude in social, nonsexualized and frequently mixed-gender groups specifically in cultures where going nude in the social situation is not the norm.\n#writing #microfiction #vss #nudism", - "cw": "Today's #micro365 prompt is:", - "visibility": "public", - "renoteCount": 0, - "repliesCount": 0, - "reactions": {}, - "reactionEmojis": [], - "emojis": [], - "tags": [ - "writing", - "microfiction", - "vss", - "nudism", - "micro365" - ], - "fileIds": [], - "files": [], - "replyId": null, - "renoteId": null - } - } - -