diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-03-22 15:14:54 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-03-22 15:14:54 +0900 |
| commit | 7c3086e9d9508d5df03d7859932c766a26b9664e (patch) | |
| tree | ddb4da56c3a14fdb6115c91290dd58d1111ef51b /src/remote/activitypub/request.ts | |
| parent | tweak cache lifetime (diff) | |
| download | misskey-7c3086e9d9508d5df03d7859932c766a26b9664e.tar.gz misskey-7c3086e9d9508d5df03d7859932c766a26b9664e.tar.bz2 misskey-7c3086e9d9508d5df03d7859932c766a26b9664e.zip | |
perf(server): Cache user keypair
Diffstat (limited to 'src/remote/activitypub/request.ts')
| -rw-r--r-- | src/remote/activitypub/request.ts | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/remote/activitypub/request.ts b/src/remote/activitypub/request.ts index 2f07351635..5f15d5480c 100644 --- a/src/remote/activitypub/request.ts +++ b/src/remote/activitypub/request.ts @@ -5,11 +5,11 @@ import * as crypto from 'crypto'; import config from '../../config'; import { ILocalUser } from '../../models/entities/user'; -import { UserKeypairs } from '../../models'; import { getAgentByUrl } from '../../misc/fetch'; import { URL } from 'url'; import got from 'got'; import * as Got from 'got'; +import { getUserKeypair } from '../../misc/keypair-store'; export default async (user: ILocalUser, url: string, object: any) => { const timeout = 10 * 1000; @@ -22,9 +22,7 @@ export default async (user: ILocalUser, url: string, object: any) => { sha256.update(data); const hash = sha256.digest('base64'); - const keypair = await UserKeypairs.findOneOrFail({ - userId: user.id - }); + const keypair = await getUserKeypair(user.id); await new Promise((resolve, reject) => { const req = https.request({ @@ -74,9 +72,7 @@ export default async (user: ILocalUser, url: string, object: any) => { export async function signedGet(url: string, user: ILocalUser) { const timeout = 10 * 1000; - const keypair = await UserKeypairs.findOneOrFail({ - userId: user.id - }); + const keypair = await getUserKeypair(user.id); const req = got.get<any>(url, { headers: { |