@evanp/activitypub-bot 0.45.5 → 0.45.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.
package/CHANGELOG.md CHANGED
@@ -9,6 +9,21 @@ and this project adheres to
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [0.45.6] - 2026-04-27
13
+
14
+ ### Fixed
15
+
16
+ - Remove `onIdle` call that stalled FollowbackBot
17
+ since no workers had started yet.
18
+
19
+ ## [0.45.6] - 2026-04-27
20
+
21
+ ### Fixed
22
+
23
+ - Patch up database problem where actors are
24
+ stored in `pendingFollowing` instead of
25
+ `Follow` activities.
26
+
12
27
  ## [0.45.5] - 2026-04-27
13
28
 
14
29
  ### Fixed
package/lib/botcontext.js CHANGED
@@ -278,6 +278,15 @@ export class BotContext {
278
278
  'pendingFollowing',
279
279
  followActivity
280
280
  )
281
+ // Buggy code used to put the actor in
282
+ // the collection
283
+ if (await this.#actorStorage.isInCollection(this.#botId, 'pendingFollowing', actor)) {
284
+ await this.#actorStorage.removeFromCollection(
285
+ this.#botId,
286
+ 'pendingFollowing',
287
+ actor
288
+ )
289
+ }
281
290
  }
282
291
  await this.#actorStorage.removeFromCollection(
283
292
  this.#botId,
@@ -3,6 +3,9 @@ import Bot from '../bot.js'
3
3
  const DEFAULT_NAME = 'FollowBackBot'
4
4
  const DEFAULT_DESCRIPTION = 'A bot that follows you back'
5
5
 
6
+ const NS = 'https://www.w3.org/ns/activitystreams#'
7
+ const FOLLOW = `${NS}Follow`
8
+
6
9
  // 7-day default timeout
7
10
 
8
11
  const DEFAULT_STALE_FOLLOW_TIMEOUT = 7 * 24 * 60 * 60 * 1000
@@ -24,8 +27,6 @@ export default class FollowBackBot extends Bot {
24
27
  async initialize (context) {
25
28
  await super.initialize(context)
26
29
  await this.#undoStalePendingFollowing()
27
- // Drain the queue so undos arrive before re-follows
28
- await this._context.onIdle()
29
30
  await this.#synchronizeFollowers()
30
31
  }
31
32
 
@@ -77,15 +78,26 @@ export default class FollowBackBot extends Bot {
77
78
  for await (const follow of this._context.pendingFollowing()) {
78
79
  try {
79
80
  const activity = await this._context.getObject(follow.id)
80
- if (activity.published && (now - activity.published > this.#staleFollowTimeout)) {
81
- await this._context.unfollowActor(activity.object.first)
82
- this._context.logger.info(
81
+ if (activity.type === FOLLOW) {
82
+ if (activity.published && (now - activity.published > this.#staleFollowTimeout)) {
83
+ await this._context.unfollowActor(activity.object.first)
84
+ this._context.logger.info(
85
+ {
86
+ actorId: activity.object.first?.id,
87
+ published: activity.published
88
+ },
89
+ 'Unfollowed stale actor'
90
+ )
91
+ }
92
+ } else if (activity.inbox) {
93
+ const actor = activity
94
+ this._context.logger.warn(
83
95
  {
84
- actorId: activity.object.first?.id,
85
- published: activity.published
96
+ actorId: actor.id
86
97
  },
87
- 'Unfollowed stale actor'
98
+ 'actor incorrectly in pendingFollowing'
88
99
  )
100
+ await this._context.unfollowActor(actor)
89
101
  }
90
102
  } catch (err) {
91
103
  this._context.logger.error(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanp/activitypub-bot",
3
- "version": "0.45.5",
3
+ "version": "0.45.7",
4
4
  "description": "server-side ActivityPub bot framework",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",