micro365/firefish-calls/createNote.mjs

40 lines
760 B
JavaScript
Raw Permalink Normal View History

2023-08-13 13:00:24 +00:00
import firefish from './firefish.mjs'
2023-08-12 10:05:24 +00:00
import logger from '../logger.mjs'
2023-08-13 13:00:24 +00:00
// //JUST FOR USE IN LOCAL ENVIRONMENT
// import { Agent, setGlobalDispatcher } from 'undici'
// const agent = new Agent({
// connect: {
// rejectUnauthorized: false
// }
// })
// setGlobalDispatcher(agent)
// //^^^JUST FOR USE IN LOCAL ENVIRONMENT^^^
2023-08-08 19:19:19 +00:00
export default async function createNote(text,replyId) {
2023-08-13 13:00:24 +00:00
logger.trace("createNote called")
const body = {
2023-08-08 19:19:19 +00:00
text: text,
2023-08-13 13:32:49 +00:00
cw:"Today's #micro365 prompt is:"
2023-08-08 19:19:19 +00:00
}
if(replyId){body.replyId=replyId}
2023-08-13 13:00:24 +00:00
const response = await firefish.post("notes/create",body)
2023-08-13 13:15:18 +00:00
logger.info({
status: response.status,
statusText: response.statusText,
data: response.data
})
2023-08-13 13:00:24 +00:00
return response.data
2023-08-08 19:19:19 +00:00
}