From 591f53fd06cf8c92a1538c7125ab08421a7b199a Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 3 Feb 2022 21:20:25 +0900 Subject: [PATCH] refactor --- packages/backend/{ => src}/@types/hcaptcha.d.ts | 0 packages/backend/{ => src}/@types/http-signature.d.ts | 0 packages/backend/{ => src}/@types/jsrsasign.d.ts | 0 packages/backend/{ => src}/@types/koa-json-body.d.ts | 0 packages/backend/{ => src}/@types/koa-slow.d.ts | 0 packages/backend/{ => src}/@types/langmap.d.ts | 0 packages/backend/{ => src}/@types/os-utils.d.ts | 0 packages/backend/{ => src}/@types/package.json.d.ts | 0 packages/backend/{ => src}/@types/probe-image-size.d.ts | 0 packages/backend/src/misc/gen-identicon.ts | 2 +- packages/backend/src/remote/activitypub/renderer/note.ts | 2 +- .../remote/activitypub/renderer/ordered-collection.ts | 9 ++++++++- packages/backend/src/server/activitypub/featured.ts | 2 +- packages/backend/tsconfig.json | 2 +- 14 files changed, 12 insertions(+), 5 deletions(-) rename packages/backend/{ => src}/@types/hcaptcha.d.ts (100%) rename packages/backend/{ => src}/@types/http-signature.d.ts (100%) rename packages/backend/{ => src}/@types/jsrsasign.d.ts (100%) rename packages/backend/{ => src}/@types/koa-json-body.d.ts (100%) rename packages/backend/{ => src}/@types/koa-slow.d.ts (100%) rename packages/backend/{ => src}/@types/langmap.d.ts (100%) rename packages/backend/{ => src}/@types/os-utils.d.ts (100%) rename packages/backend/{ => src}/@types/package.json.d.ts (100%) rename packages/backend/{ => src}/@types/probe-image-size.d.ts (100%) diff --git a/packages/backend/@types/hcaptcha.d.ts b/packages/backend/src/@types/hcaptcha.d.ts similarity index 100% rename from packages/backend/@types/hcaptcha.d.ts rename to packages/backend/src/@types/hcaptcha.d.ts diff --git a/packages/backend/@types/http-signature.d.ts b/packages/backend/src/@types/http-signature.d.ts similarity index 100% rename from packages/backend/@types/http-signature.d.ts rename to packages/backend/src/@types/http-signature.d.ts diff --git a/packages/backend/@types/jsrsasign.d.ts b/packages/backend/src/@types/jsrsasign.d.ts similarity index 100% rename from packages/backend/@types/jsrsasign.d.ts rename to packages/backend/src/@types/jsrsasign.d.ts diff --git a/packages/backend/@types/koa-json-body.d.ts b/packages/backend/src/@types/koa-json-body.d.ts similarity index 100% rename from packages/backend/@types/koa-json-body.d.ts rename to packages/backend/src/@types/koa-json-body.d.ts diff --git a/packages/backend/@types/koa-slow.d.ts b/packages/backend/src/@types/koa-slow.d.ts similarity index 100% rename from packages/backend/@types/koa-slow.d.ts rename to packages/backend/src/@types/koa-slow.d.ts diff --git a/packages/backend/@types/langmap.d.ts b/packages/backend/src/@types/langmap.d.ts similarity index 100% rename from packages/backend/@types/langmap.d.ts rename to packages/backend/src/@types/langmap.d.ts diff --git a/packages/backend/@types/os-utils.d.ts b/packages/backend/src/@types/os-utils.d.ts similarity index 100% rename from packages/backend/@types/os-utils.d.ts rename to packages/backend/src/@types/os-utils.d.ts diff --git a/packages/backend/@types/package.json.d.ts b/packages/backend/src/@types/package.json.d.ts similarity index 100% rename from packages/backend/@types/package.json.d.ts rename to packages/backend/src/@types/package.json.d.ts diff --git a/packages/backend/@types/probe-image-size.d.ts b/packages/backend/src/@types/probe-image-size.d.ts similarity index 100% rename from packages/backend/@types/probe-image-size.d.ts rename to packages/backend/src/@types/probe-image-size.d.ts diff --git a/packages/backend/src/misc/gen-identicon.ts b/packages/backend/src/misc/gen-identicon.ts index 5cedd7afa..fca67fcf2 100644 --- a/packages/backend/src/misc/gen-identicon.ts +++ b/packages/backend/src/misc/gen-identicon.ts @@ -39,7 +39,7 @@ const sideN = Math.floor(n / 2); */ export function genIdenticon(seed: string, stream: WriteStream): Promise { const rand = gen.create(seed); - const canvas = p.make(size, size); + const canvas = p.make(size, size, undefined); const ctx = canvas.getContext('2d'); ctx.fillStyle = bg; diff --git a/packages/backend/src/remote/activitypub/renderer/note.ts b/packages/backend/src/remote/activitypub/renderer/note.ts index 4f9a372b2..654ab6812 100644 --- a/packages/backend/src/remote/activitypub/renderer/note.ts +++ b/packages/backend/src/remote/activitypub/renderer/note.ts @@ -11,7 +11,7 @@ import { In } from 'typeorm'; import { Emoji } from '@/models/entities/emoji'; import { Poll } from '@/models/entities/poll'; -export default async function renderNote(note: Note, dive = true, isTalk = false): Promise { +export default async function renderNote(note: Note, dive = true, isTalk = false): Promise> { const getPromisedFiles = async (ids: string[]) => { if (!ids || ids.length === 0) return []; const items = await DriveFiles.find({ id: In(ids) }); diff --git a/packages/backend/src/remote/activitypub/renderer/ordered-collection.ts b/packages/backend/src/remote/activitypub/renderer/ordered-collection.ts index c4b4337af..ff9a77be3 100644 --- a/packages/backend/src/remote/activitypub/renderer/ordered-collection.ts +++ b/packages/backend/src/remote/activitypub/renderer/ordered-collection.ts @@ -6,7 +6,14 @@ * @param last URL of last page (optional) * @param orderedItems attached objects (optional) */ -export default function(id: string | null, totalItems: any, first?: string, last?: string, orderedItems?: Record) { +export default function(id: string | null, totalItems: any, first?: string, last?: string, orderedItems?: Record[]): { + id: string | null; + type: 'OrderedCollection'; + totalItems: any; + first?: string; + last?: string; + orderedItems?: Record[]; +} { const page: any = { id, type: 'OrderedCollection', diff --git a/packages/backend/src/server/activitypub/featured.ts b/packages/backend/src/server/activitypub/featured.ts index 40b8d8cc8..ed5bfc426 100644 --- a/packages/backend/src/server/activitypub/featured.ts +++ b/packages/backend/src/server/activitypub/featured.ts @@ -32,7 +32,7 @@ export default async (ctx: Router.RouterContext) => { const rendered = renderOrderedCollection( `${config.url}/users/${userId}/collections/featured`, - renderedNotes.length, undefined, undefined, renderedNotes + renderedNotes.length, undefined, undefined, renderedNotes, ); ctx.body = renderActivity(rendered); diff --git a/packages/backend/tsconfig.json b/packages/backend/tsconfig.json index 3311e117d..f3252b286 100644 --- a/packages/backend/tsconfig.json +++ b/packages/backend/tsconfig.json @@ -30,7 +30,7 @@ "outDir": "./built", "typeRoots": [ "./node_modules/@types", - "./@types" + "./src/@types" ], "lib": [ "esnext"