diff --git a/api/src/api-utils.js b/api/src/api-utils.js index 7f17662..241da8b 100644 --- a/api/src/api-utils.js +++ b/api/src/api-utils.js @@ -37,7 +37,19 @@ module.exports = { else return null return o }, - apRandomURL: () => { - return 'https://'+apex.domain+'/'+crypto.randomUUID() + apRandomURL: (masks) => { + masks = masks || [':id'] + if (typeof masks === 'string') + masks = [ masks ] + var result = [] + const id = crypto.randomUUID() + for (var i = 0; i < masks.length; i++) + result.push(`https://${apex.domain}/` + +masks[i].replaceAll(':id', id)) + if (result.length === 0) + return null + if (result.length === 1) + return result[0] + return result }, } diff --git a/api/src/api/me.js b/api/src/api/me.js index dc27af7..54ab5df 100644 --- a/api/src/api/me.js +++ b/api/src/api/me.js @@ -127,14 +127,14 @@ async function sendNote(from, to, html, modc) { if ([false, undefined, null].includes(to)) return false - const id = utils.apRandomURL() + const ids = utils.apRandomURL(['s/:id', 'o/:id']) var payload = { - id: id+'#activity', + id: ids[0], type: 'Create', actor: actor.id, to: [ to.url ], object: { - id, + id: ids[1], type: 'Note', content: html, attributedTo: actor.id,