Move job queue to redis
We'll use it as cache in the future. /!\ You'll loose your old jobs (pending jobs too) so upgrade only when you don't have pending job anymore.
This commit is contained in:
parent
d765fafc3f
commit
94a5ff8a4a
60 changed files with 992 additions and 703 deletions
|
@ -0,0 +1,39 @@
|
|||
import { buildSignedActivity } from '../../../../helpers/activitypub'
|
||||
import { getServerActor } from '../../../../helpers/utils'
|
||||
import { ActorModel } from '../../../../models/activitypub/actor'
|
||||
|
||||
async function computeBody (payload: { body: any, signatureActorId?: number }) {
|
||||
let body = payload.body
|
||||
|
||||
if (payload.signatureActorId) {
|
||||
const actorSignature = await ActorModel.load(payload.signatureActorId)
|
||||
if (!actorSignature) throw new Error('Unknown signature actor id.')
|
||||
body = await buildSignedActivity(actorSignature, payload.body)
|
||||
}
|
||||
|
||||
return body
|
||||
}
|
||||
|
||||
async function buildSignedRequestOptions (payload: { signatureActorId?: number }) {
|
||||
let actor: ActorModel
|
||||
if (payload.signatureActorId) {
|
||||
actor = await ActorModel.load(payload.signatureActorId)
|
||||
if (!actor) throw new Error('Unknown signature actor id.')
|
||||
} else {
|
||||
// We need to sign the request, so use the server
|
||||
actor = await getServerActor()
|
||||
}
|
||||
|
||||
const keyId = actor.getWebfingerUrl()
|
||||
return {
|
||||
algorithm: 'rsa-sha256',
|
||||
authorizationHeaderName: 'Signature',
|
||||
keyId,
|
||||
key: actor.privateKey
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
computeBody,
|
||||
buildSignedRequestOptions
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue