@evanp/activitypub-bot 0.45.5 → 0.45.6
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 +8 -0
- package/lib/botcontext.js +9 -0
- package/lib/bots/followback.js +20 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,14 @@ and this project adheres to
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.45.6] - 2026-04-27
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Patch up database problem where actors are
|
|
17
|
+
stored in `pendingFollowing` instead of
|
|
18
|
+
`Follow` activities.
|
|
19
|
+
|
|
12
20
|
## [0.45.5] - 2026-04-27
|
|
13
21
|
|
|
14
22
|
### 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,
|
package/lib/bots/followback.js
CHANGED
|
@@ -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
|
|
@@ -77,15 +80,26 @@ export default class FollowBackBot extends Bot {
|
|
|
77
80
|
for await (const follow of this._context.pendingFollowing()) {
|
|
78
81
|
try {
|
|
79
82
|
const activity = await this._context.getObject(follow.id)
|
|
80
|
-
if (activity.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
if (activity.type === FOLLOW) {
|
|
84
|
+
if (activity.published && (now - activity.published > this.#staleFollowTimeout)) {
|
|
85
|
+
await this._context.unfollowActor(activity.object.first)
|
|
86
|
+
this._context.logger.info(
|
|
87
|
+
{
|
|
88
|
+
actorId: activity.object.first?.id,
|
|
89
|
+
published: activity.published
|
|
90
|
+
},
|
|
91
|
+
'Unfollowed stale actor'
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
} else if (activity.inbox) {
|
|
95
|
+
const actor = activity
|
|
96
|
+
this._context.logger.warn(
|
|
83
97
|
{
|
|
84
|
-
actorId:
|
|
85
|
-
published: activity.published
|
|
98
|
+
actorId: actor.id
|
|
86
99
|
},
|
|
87
|
-
'
|
|
100
|
+
'actor incorrectly in pendingFollowing'
|
|
88
101
|
)
|
|
102
|
+
await this._context.unfollowActor(actor)
|
|
89
103
|
}
|
|
90
104
|
} catch (err) {
|
|
91
105
|
this._context.logger.error(
|