mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
Use got instead of request
This commit is contained in:
parent
71926aae07
commit
db4b15f21f
32 changed files with 346 additions and 328 deletions
|
@ -6,21 +6,24 @@ import { getServerActor } from '@server/models/application/application'
|
|||
import { buildDigest } from '@server/helpers/peertube-crypto'
|
||||
import { ContextType } from '@shared/models/activitypub/context'
|
||||
|
||||
type Payload = { body: any, contextType?: ContextType, signatureActorId?: number }
|
||||
type Payload <T> = { body: T, contextType?: ContextType, signatureActorId?: number }
|
||||
|
||||
async function computeBody (payload: Payload) {
|
||||
async function computeBody <T> (
|
||||
payload: Payload<T>
|
||||
): Promise<T | T & { type: 'RsaSignature2017', creator: string, created: string }> {
|
||||
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, payload.contextType)
|
||||
}
|
||||
|
||||
return body
|
||||
}
|
||||
|
||||
async function buildSignedRequestOptions (payload: Payload) {
|
||||
async function buildSignedRequestOptions (payload: Payload<any>) {
|
||||
let actor: MActor | null
|
||||
|
||||
if (payload.signatureActorId) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue