microfed 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/outbox.js +39 -10
package/package.json
CHANGED
package/src/outbox.js
CHANGED
|
@@ -41,25 +41,54 @@ export function createActivity(options) {
|
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Create a Note (post)
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
44
|
+
* Supports two call signatures:
|
|
45
|
+
* - createNote(actor, content, options) - positional
|
|
46
|
+
* - createNote({ actor, content, ...options }) - object
|
|
47
|
+
*
|
|
48
|
+
* @param {string|Object} actorOrOptions - Actor ID or options object
|
|
49
|
+
* @param {string} [content] - HTML content (if using positional args)
|
|
50
|
+
* @param {Object} [options] - Additional options (if using positional args)
|
|
47
51
|
* @param {string} [options.id] - Note ID (auto-generated if not provided)
|
|
48
|
-
* @param {
|
|
52
|
+
* @param {Array} [options.to] - Primary recipients
|
|
53
|
+
* @param {Array} [options.cc] - Secondary recipients
|
|
49
54
|
* @param {string} [options.inReplyTo] - ID of post being replied to
|
|
50
55
|
* @returns {Object} Note object
|
|
51
56
|
*/
|
|
52
|
-
export function createNote(options) {
|
|
53
|
-
|
|
57
|
+
export function createNote(actorOrOptions, content, options = {}) {
|
|
58
|
+
// Support both call signatures
|
|
59
|
+
let actor, noteContent, noteOptions
|
|
60
|
+
if (typeof actorOrOptions === 'object') {
|
|
61
|
+
// Object signature: createNote({ actor, content, ... })
|
|
62
|
+
actor = actorOrOptions.actor
|
|
63
|
+
noteContent = actorOrOptions.content
|
|
64
|
+
noteOptions = actorOrOptions
|
|
65
|
+
} else {
|
|
66
|
+
// Positional signature: createNote(actor, content, options)
|
|
67
|
+
actor = actorOrOptions
|
|
68
|
+
noteContent = content
|
|
69
|
+
noteOptions = options
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Handle public/private addressing
|
|
73
|
+
const isPublic = noteOptions.public !== false
|
|
74
|
+
const defaultTo = isPublic ? [PUBLIC] : []
|
|
75
|
+
const defaultCc = isPublic ? [`${actor}/followers`] : []
|
|
76
|
+
|
|
77
|
+
const {
|
|
78
|
+
id,
|
|
79
|
+
to = defaultTo,
|
|
80
|
+
cc = defaultCc,
|
|
81
|
+
inReplyTo
|
|
82
|
+
} = noteOptions
|
|
54
83
|
|
|
55
84
|
const note = {
|
|
56
85
|
type: 'Note',
|
|
57
|
-
id:
|
|
86
|
+
id: id || `${actor}/notes/${Date.now()}`,
|
|
58
87
|
attributedTo: actor,
|
|
59
|
-
content,
|
|
88
|
+
content: noteContent,
|
|
60
89
|
published: new Date().toISOString(),
|
|
61
|
-
to
|
|
62
|
-
cc
|
|
90
|
+
to,
|
|
91
|
+
cc
|
|
63
92
|
}
|
|
64
93
|
|
|
65
94
|
if (inReplyTo) note.inReplyTo = inReplyTo
|