From 218e756555d5d24d6b9d8f8d13842f7c8e80cedc Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 1 Mar 2022 01:24:50 +0900 Subject: [PATCH] fix esm --- .../backend/src/remote/activitypub/models/person.ts | 10 +++++----- packages/backend/src/remote/resolve-user.ts | 2 +- packages/backend/src/server/activitypub/followers.ts | 4 ++-- packages/backend/src/server/activitypub/following.ts | 4 ++-- packages/backend/src/server/activitypub/outbox.ts | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/backend/src/remote/activitypub/models/person.ts b/packages/backend/src/remote/activitypub/models/person.ts index bfc613523..cd9da3390 100644 --- a/packages/backend/src/remote/activitypub/models/person.ts +++ b/packages/backend/src/remote/activitypub/models/person.ts @@ -57,15 +57,15 @@ function validateActor(x: IObject, uri: string): IActor { if (e) throw new Error(`invalid Actor: ${name} ${e.message}`); }; - validate('id', x.id, $.str.min(1)); - validate('inbox', x.inbox, $.str.min(1)); - validate('preferredUsername', x.preferredUsername, $.str.min(1).max(128).match(/^\w([\w-.]*\w)?$/)); + validate('id', x.id, $.default.str.min(1)); + validate('inbox', x.inbox, $.default.str.min(1)); + validate('preferredUsername', x.preferredUsername, $.default.str.min(1).max(128).match(/^\w([\w-.]*\w)?$/)); // These fields are only informational, and some AP software allows these // fields to be very long. If they are too long, we cut them off. This way // we can at least see these users and their activities. - validate('name', truncate(x.name, nameLength), $.optional.nullable.str); - validate('summary', truncate(x.summary, summaryLength), $.optional.nullable.str); + validate('name', truncate(x.name, nameLength), $.default.optional.nullable.str); + validate('summary', truncate(x.summary, summaryLength), $.default.optional.nullable.str); const idHost = toPuny(new URL(x.id!).hostname); if (idHost !== expectHost) { diff --git a/packages/backend/src/remote/resolve-user.ts b/packages/backend/src/remote/resolve-user.ts index 8cbf02e68..aa37013c4 100644 --- a/packages/backend/src/remote/resolve-user.ts +++ b/packages/backend/src/remote/resolve-user.ts @@ -26,7 +26,7 @@ export async function resolveUser(username: string, host: string | null, option? host = toPuny(host); - if (config.host == host) { + if (config.host === host) { logger.info(`return local user: ${usernameLower}`); return await Users.findOne({ usernameLower, host: null }).then(u => { if (u == null) { diff --git a/packages/backend/src/server/activitypub/followers.ts b/packages/backend/src/server/activitypub/followers.ts index 644ecaf8c..5d1d7c59e 100644 --- a/packages/backend/src/server/activitypub/followers.ts +++ b/packages/backend/src/server/activitypub/followers.ts @@ -15,10 +15,10 @@ export default async (ctx: Router.RouterContext) => { const userId = ctx.params.user; // Get 'cursor' parameter - const [cursor, cursorErr] = $.optional.type(ID).get(ctx.request.query.cursor); + const [cursor, cursorErr] = $.default.optional.type(ID).get(ctx.request.query.cursor); // Get 'page' parameter - const pageErr = !$.optional.str.or(['true', 'false']).ok(ctx.request.query.page); + const pageErr = !$.default.optional.str.or(['true', 'false']).ok(ctx.request.query.page); const page: boolean = ctx.request.query.page === 'true'; // Validate parameters diff --git a/packages/backend/src/server/activitypub/following.ts b/packages/backend/src/server/activitypub/following.ts index b1f3f9ac7..23110ce87 100644 --- a/packages/backend/src/server/activitypub/following.ts +++ b/packages/backend/src/server/activitypub/following.ts @@ -16,10 +16,10 @@ export default async (ctx: Router.RouterContext) => { const userId = ctx.params.user; // Get 'cursor' parameter - const [cursor, cursorErr] = $.optional.type(ID).get(ctx.request.query.cursor); + const [cursor, cursorErr] = $.default.optional.type(ID).get(ctx.request.query.cursor); // Get 'page' parameter - const pageErr = !$.optional.str.or(['true', 'false']).ok(ctx.request.query.page); + const pageErr = !$.default.optional.str.or(['true', 'false']).ok(ctx.request.query.page); const page: boolean = ctx.request.query.page === 'true'; // Validate parameters diff --git a/packages/backend/src/server/activitypub/outbox.ts b/packages/backend/src/server/activitypub/outbox.ts index 525ac81b9..57c126752 100644 --- a/packages/backend/src/server/activitypub/outbox.ts +++ b/packages/backend/src/server/activitypub/outbox.ts @@ -20,13 +20,13 @@ export default async (ctx: Router.RouterContext) => { const userId = ctx.params.user; // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $.optional.type(ID).get(ctx.request.query.since_id); + const [sinceId, sinceIdErr] = $.default.optional.type(ID).get(ctx.request.query.since_id); // Get 'untilId' parameter - const [untilId, untilIdErr] = $.optional.type(ID).get(ctx.request.query.until_id); + const [untilId, untilIdErr] = $.default.optional.type(ID).get(ctx.request.query.until_id); // Get 'page' parameter - const pageErr = !$.optional.str.or(['true', 'false']).ok(ctx.request.query.page); + const pageErr = !$.default.optional.str.or(['true', 'false']).ok(ctx.request.query.page); const page: boolean = ctx.request.query.page === 'true'; // Validate parameters