@evanp/activitypub-bot 0.25.1 → 0.26.0

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/lib/botcontext.js +12 -6
  2. package/package.json +1 -1
package/lib/botcontext.js CHANGED
@@ -378,12 +378,18 @@ export class BotContext {
378
378
  return `${username}@${actorUrl.hostname}`
379
379
  }
380
380
 
381
- async announceObject (obj) {
381
+ async announceObject (obj, actors = null) {
382
382
  assert.ok(obj)
383
383
  assert.equal(typeof obj, 'object')
384
- const owners = obj.attributedTo
385
- ? Array.from(obj.attributedTo).map((owner) => owner.id)
386
- : Array.from(obj.actor).map((owner) => owner.id)
384
+
385
+ const owners = (actors)
386
+ ? Array.from(actors).map(actor => actor.id)
387
+ : (obj.attributedTo)
388
+ ? Array.from(obj.attributedTo).map((owner) => owner.id)
389
+ : (obj.actor)
390
+ ? Array.from(obj.actor).map((owner) => owner.id)
391
+ : []
392
+
387
393
  const summary = `${this.#botId} shared "${await this.#nameOf(obj)}"`
388
394
  const activity = await this.#doActivity({
389
395
  type: 'Announce',
@@ -447,9 +453,9 @@ export class BotContext {
447
453
 
448
454
  #nameOf (obj) {
449
455
  if (obj.name) {
450
- return obj.name.valueOf()
456
+ return obj.name.get()
451
457
  } else if (obj.summary) {
452
- return obj.summary.valueOf()
458
+ return obj.summary.get()
453
459
  } else if (obj.type) {
454
460
  return `a(n) ${obj.type.first}`
455
461
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanp/activitypub-bot",
3
- "version": "0.25.1",
3
+ "version": "0.26.0",
4
4
  "description": "server-side ActivityPub bot framework",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",