@evanp/activitypub-bot 0.13.4 → 0.13.7

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.
@@ -65,15 +65,21 @@ export class ActivityDeliverer {
65
65
  const recipients = this.getRecipients(activity)
66
66
 
67
67
  for (const recipient of recipients) {
68
+ this.#logger.debug(`Checking recipient ${recipient.id}`)
68
69
  if (this.#isPublic(recipient)) {
70
+ this.#logger.debug(`Public recipient for ${activity.id}`)
69
71
  await this.#deliverPublic(activity, bots)
70
72
  } else if (this.#isLocal(recipient)) {
73
+ this.#logger.debug(`Local recipient for ${activity.id}`)
71
74
  const parts = this.#formatter.unformat(recipient.id)
72
75
  if (this.#isLocalActor(parts)) {
76
+ this.#logger.debug(`Local actor ${recipient.id} for ${activity.id}`)
73
77
  await this.#deliverLocalActor(activity, recipient, bots, deliveredTo)
74
78
  } else if (this.#isLocalFollowersCollection(parts)) {
79
+ this.#logger.debug(`Local followers for ${parts.username} for ${activity.id}`)
75
80
  await this.#deliverLocalFollowersCollection(activity, parts.username, bots, deliveredTo)
76
81
  } else if (this.#isLocalFollowingCollection(parts)) {
82
+ this.#logger.debug(`Local following for ${parts.username} for ${activity.id}`)
77
83
  await this.#deliverLocalFollowingCollection(activity, parts.username, bots, deliveredTo)
78
84
  } else {
79
85
  this.#logger.warn(
@@ -86,10 +92,13 @@ export class ActivityDeliverer {
86
92
  if (await this.#isRemoteActor(fullRecipient)) {
87
93
  this.#logger.warn(`Skipping remote actor ${recipient.id}`)
88
94
  } else if (await this.#isRemoteFollowersCollection(fullActor, fullRecipient)) {
95
+ this.#logger.debug(`Remote followers for ${fullActor.id} for ${activity.id}`)
89
96
  await this.#deliverRemoteFollowersCollection(activity, fullRecipient, fullActor, deliveredTo, bots)
90
97
  } else if (await this.#isRemoteFollowingCollection(fullActor, fullRecipient)) {
98
+ this.#logger.debug(`Remote following for ${fullActor.id} for ${activity.id}`)
91
99
  await this.#deliverRemoteFollowingCollection(activity, fullRecipient, fullActor, deliveredTo, bots)
92
100
  } else if (await this.#isRemoteCollection(fullRecipient)) {
101
+ this.#logger.debug(`Remote collection ${fullRecipient.id} for ${activity.id}`)
93
102
  await this.#deliverRemoteCollection(activity, fullRecipient, deliveredTo, bots)
94
103
  } else {
95
104
  this.#logger.warn(`Unrecognized recipient: ${recipient.id}`)
package/lib/keystorage.js CHANGED
@@ -36,11 +36,12 @@ export class KeyStorage {
36
36
  async #getKeys (username) {
37
37
  let privateKey
38
38
  let publicKey
39
- const qry = (username)
40
- ? 'SELECT public_key, private_key FROM new_keys WHERE username = ?'
41
- : 'SELECT public_key, private_key FROM new_keys WHERE username IS NULL'
39
+ // system key uses username null but primary key can't be null
40
+ if (!username) {
41
+ username = ''
42
+ }
42
43
  const [result] = await this.#connection.query(
43
- qry,
44
+ 'SELECT public_key, private_key FROM new_keys WHERE username = ?',
44
45
  { replacements: [username] }
45
46
  )
46
47
  if (result.length > 0) {
@@ -60,6 +60,8 @@ router.post('/user/:username/inbox', async (req, res, next) => {
60
60
  return next(createHttpError(400, 'Activity already delivered'))
61
61
  }
62
62
 
63
+ logger.info(`Activity ${activity.id} received at ${bot.username} inbox`)
64
+
63
65
  await deliverer.deliverTo(activity, bot)
64
66
 
65
67
  res.status(200)
@@ -44,6 +44,8 @@ router.post('/shared/inbox', async (req, res, next) => {
44
44
  return next(createHttpError(403, `${subject} is not the actor ${actor.id}`))
45
45
  }
46
46
 
47
+ logger.info(`Activity ${activity.id} received at shared inbox`)
48
+
47
49
  await deliverer.deliverToAll(activity, bots)
48
50
 
49
51
  res.status(200)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanp/activitypub-bot",
3
- "version": "0.13.4",
3
+ "version": "0.13.7",
4
4
  "description": "server-side ActivityPub bot framework",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",