@evanp/activitypub-bot 0.30.4 → 0.30.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/lib/app.js +8 -3
- package/lib/ratelimiter.js +9 -2
- package/package.json +1 -1
package/lib/app.js
CHANGED
|
@@ -188,15 +188,20 @@ export async function makeApp ({ databaseUrl, origin, bots, logLevel = 'silent',
|
|
|
188
188
|
}
|
|
189
189
|
}))
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
// These should not check HTTP Signature even if provided
|
|
192
192
|
|
|
193
193
|
app.use('/', serverRouter)
|
|
194
|
+
app.use('/', healthRouter)
|
|
195
|
+
app.use('/', webfingerRouter)
|
|
196
|
+
|
|
197
|
+
// These should check HTTP Signature if provided
|
|
198
|
+
|
|
199
|
+
app.use(signature.authenticate.bind(signature))
|
|
200
|
+
|
|
194
201
|
app.use('/', userRouter)
|
|
195
202
|
app.use('/', collectionRouter)
|
|
196
203
|
app.use('/', inboxRouter)
|
|
197
204
|
app.use('/', objectRouter)
|
|
198
|
-
app.use('/', healthRouter)
|
|
199
|
-
app.use('/', webfingerRouter)
|
|
200
205
|
app.use('/', sharedInboxRouter)
|
|
201
206
|
|
|
202
207
|
app.use(async (req, res) => {
|
package/lib/ratelimiter.js
CHANGED
|
@@ -36,8 +36,15 @@ export class RateLimiter {
|
|
|
36
36
|
|
|
37
37
|
if (resetHeader && remainingHeader) {
|
|
38
38
|
const remaining = parseInt(remainingHeader)
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
let resetSeconds
|
|
40
|
+
let reset
|
|
41
|
+
if (resetHeader.match(/^\d+$/)) {
|
|
42
|
+
resetSeconds = parseInt(resetHeader)
|
|
43
|
+
reset = new Date(Date.now() + (resetSeconds * 1000))
|
|
44
|
+
} else {
|
|
45
|
+
reset = new Date(resetHeader)
|
|
46
|
+
resetSeconds = reset - Date.now()
|
|
47
|
+
}
|
|
41
48
|
this.#logger.debug({ reset, remaining, host }, 'updating')
|
|
42
49
|
await this.#connection.query(
|
|
43
50
|
`INSERT INTO rate_limit (host, remaining, reset)
|