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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/outbox.js +39 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microfed",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Minimal, modular ActivityPub microservices",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/src/outbox.js CHANGED
@@ -41,25 +41,54 @@ export function createActivity(options) {
41
41
 
42
42
  /**
43
43
  * Create a Note (post)
44
- * @param {Object} options - Note options
45
- * @param {string} options.actor - Author's actor ID
46
- * @param {string} options.content - HTML content
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 {boolean} [options.public=true] - Make post public
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
- const { actor, content, public: isPublic = true, inReplyTo } = options
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: options.id || `${actor}/notes/${Date.now()}`,
86
+ id: id || `${actor}/notes/${Date.now()}`,
58
87
  attributedTo: actor,
59
- content,
88
+ content: noteContent,
60
89
  published: new Date().toISOString(),
61
- to: isPublic ? [PUBLIC] : [],
62
- cc: isPublic ? [`${actor}/followers`] : []
90
+ to,
91
+ cc
63
92
  }
64
93
 
65
94
  if (inReplyTo) note.inReplyTo = inReplyTo