diff options
Diffstat (limited to 'src/remote')
| -rw-r--r-- | src/remote/activitypub/deliver-manager.ts | 6 | ||||
| -rw-r--r-- | src/remote/activitypub/renderer/index.ts | 6 | ||||
| -rw-r--r-- | src/remote/activitypub/renderer/person.ts | 5 | ||||
| -rw-r--r-- | src/remote/activitypub/request.ts | 10 |
4 files changed, 11 insertions, 16 deletions
diff --git a/src/remote/activitypub/deliver-manager.ts b/src/remote/activitypub/deliver-manager.ts index d147b3c9b0..92721f5525 100644 --- a/src/remote/activitypub/deliver-manager.ts +++ b/src/remote/activitypub/deliver-manager.ts @@ -76,7 +76,7 @@ export default class DeliverManager { public async execute() { if (!Users.isLocalUser(this.actor)) return; - const inboxes: string[] = []; + const inboxes = new Set<string>(); // build inbox list for (const recipe of this.recipes) { @@ -89,13 +89,13 @@ export default class DeliverManager { for (const following of followers) { if (Followings.isRemoteFollower(following)) { const inbox = following.followerSharedInbox || following.followerInbox; - if (!inboxes.includes(inbox)) inboxes.push(inbox); + inboxes.add(inbox); } } } else if (isDirect(recipe)) { // direct deliver const inbox = recipe.to.inbox; - if (inbox && !inboxes.includes(inbox)) inboxes.push(inbox); + if (inbox) inboxes.add(inbox); } } diff --git a/src/remote/activitypub/renderer/index.ts b/src/remote/activitypub/renderer/index.ts index e74affdadf..4c33fdafb1 100644 --- a/src/remote/activitypub/renderer/index.ts +++ b/src/remote/activitypub/renderer/index.ts @@ -3,7 +3,7 @@ import { v4 as uuid } from 'uuid'; import { IActivity } from '../type'; import { LdSignature } from '../misc/ld-signature'; import { ILocalUser } from '../../../models/entities/user'; -import { UserKeypairs } from '../../../models'; +import { getUserKeypair } from '../../../misc/keypair-store'; export const renderActivity = (x: any): IActivity | null => { if (x == null) return null; @@ -23,9 +23,7 @@ export const renderActivity = (x: any): IActivity | null => { export const attachLdSignature = async (activity: any, user: ILocalUser): Promise<IActivity | null> => { if (activity == null) return null; - const keypair = await UserKeypairs.findOneOrFail({ - userId: user.id - }); + const keypair = await getUserKeypair(user.id); const obj = { // as non-standards diff --git a/src/remote/activitypub/renderer/person.ts b/src/remote/activitypub/renderer/person.ts index 4907e3bc6f..479e6d76bf 100644 --- a/src/remote/activitypub/renderer/person.ts +++ b/src/remote/activitypub/renderer/person.ts @@ -8,7 +8,8 @@ import { getEmojis } from './note'; import renderEmoji from './emoji'; import { IIdentifier } from '../models/identifier'; import renderHashtag from './hashtag'; -import { DriveFiles, UserProfiles, UserKeypairs } from '../../../models'; +import { DriveFiles, UserProfiles } from '../../../models'; +import { getUserKeypair } from '../../../misc/keypair-store'; export async function renderPerson(user: ILocalUser) { const id = `${config.url}/users/${user.id}`; @@ -49,7 +50,7 @@ export async function renderPerson(user: ILocalUser) { ...hashtagTags, ]; - const keypair = await UserKeypairs.findOneOrFail(user.id); + const keypair = await getUserKeypair(user.id); const person = { type: isSystem ? 'Application' : user.isBot ? 'Service' : 'Person', 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: { |