chore: format
This commit is contained in:
parent
78c9911788
commit
99c592f4dd
113 changed files with 801 additions and 749 deletions
|
@ -67,7 +67,7 @@ export const refs = {
|
|||
Emoji: packedEmojiSchema,
|
||||
};
|
||||
|
||||
export type Packed<x extends keyof typeof refs> = SchemaType<typeof refs[x]>;
|
||||
export type Packed<x extends keyof typeof refs> = SchemaType<(typeof refs)[x]>;
|
||||
|
||||
type TypeStringef =
|
||||
| "null"
|
||||
|
@ -210,9 +210,13 @@ export type SchemaTypeDef<p extends Schema> = p["type"] extends "null"
|
|||
? p["items"]["anyOf"] extends ReadonlyArray<Schema>
|
||||
? UnionSchemaType<NonNullable<p["items"]["anyOf"]>>[]
|
||||
: p["items"]["oneOf"] extends ReadonlyArray<Schema>
|
||||
? ArrayUnion<UnionSchemaType<NonNullable<p["items"]["oneOf"]>>>
|
||||
? ArrayUnion<
|
||||
UnionSchemaType<NonNullable<p["items"]["oneOf"]>>
|
||||
>
|
||||
: p["items"]["allOf"] extends ReadonlyArray<Schema>
|
||||
? UnionToIntersection<UnionSchemaType<NonNullable<p["items"]["allOf"]>>>[]
|
||||
? UnionToIntersection<
|
||||
UnionSchemaType<NonNullable<p["items"]["allOf"]>>
|
||||
>[]
|
||||
: never
|
||||
: p["items"] extends NonNullable<Schema>
|
||||
? SchemaTypeDef<p["items"]>[]
|
||||
|
|
|
@ -51,5 +51,5 @@ export class MutedNote {
|
|||
enum: mutedNoteReasons,
|
||||
comment: "The reason of the MutedNote.",
|
||||
})
|
||||
public reason: typeof mutedNoteReasons[number];
|
||||
public reason: (typeof mutedNoteReasons)[number];
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ export class Note {
|
|||
* specified ... visibleUserIds で指定したユーザーのみ
|
||||
*/
|
||||
@Column("enum", { enum: noteVisibilities })
|
||||
public visibility: typeof noteVisibilities[number];
|
||||
public visibility: (typeof noteVisibilities)[number];
|
||||
|
||||
@Index({ unique: true })
|
||||
@Column("varchar", {
|
||||
|
|
|
@ -78,7 +78,7 @@ export class Notification {
|
|||
enum: notificationTypes,
|
||||
comment: "The type of the Notification.",
|
||||
})
|
||||
public type: typeof notificationTypes[number];
|
||||
public type: (typeof notificationTypes)[number];
|
||||
|
||||
/**
|
||||
* Whether the notification was read.
|
||||
|
|
|
@ -47,7 +47,7 @@ export class Poll {
|
|||
enum: noteVisibilities,
|
||||
comment: "[Denormalized]",
|
||||
})
|
||||
public noteVisibility: typeof noteVisibilities[number];
|
||||
public noteVisibility: (typeof noteVisibilities)[number];
|
||||
|
||||
@Index()
|
||||
@Column({
|
||||
|
|
|
@ -99,7 +99,7 @@ export class UserProfile {
|
|||
enum: ffVisibility,
|
||||
default: "public",
|
||||
})
|
||||
public ffVisibility: typeof ffVisibility[number];
|
||||
public ffVisibility: (typeof ffVisibility)[number];
|
||||
|
||||
@Column("varchar", {
|
||||
length: 128,
|
||||
|
@ -238,7 +238,7 @@ export class UserProfile {
|
|||
array: true,
|
||||
default: [],
|
||||
})
|
||||
public mutingNotificationTypes: typeof notificationTypes[number][];
|
||||
public mutingNotificationTypes: (typeof notificationTypes)[number][];
|
||||
|
||||
//#region Denormalized fields
|
||||
@Index()
|
||||
|
|
|
@ -55,7 +55,7 @@ export class Webhook {
|
|||
array: true,
|
||||
default: "{}",
|
||||
})
|
||||
public on: typeof webhookEventTypes[number][];
|
||||
public on: (typeof webhookEventTypes)[number][];
|
||||
|
||||
@Column("varchar", {
|
||||
length: 1024,
|
||||
|
|
|
@ -80,9 +80,9 @@ export const PageRepository = db.getRepository(Page).extend({
|
|||
? await DriveFiles.pack(page.eyeCatchingImageId)
|
||||
: null,
|
||||
attachedFiles: DriveFiles.packMany(
|
||||
(
|
||||
await Promise.all(attachedFiles)
|
||||
).filter((x): x is DriveFile => x != null),
|
||||
(await Promise.all(attachedFiles)).filter(
|
||||
(x): x is DriveFile => x != null,
|
||||
),
|
||||
),
|
||||
likedCount: page.likedCount,
|
||||
isLiked: meId
|
||||
|
|
|
@ -17,7 +17,15 @@ export function dateUTC(time: number[]): Date {
|
|||
: time.length === 6
|
||||
? Date.UTC(time[0], time[1], time[2], time[3], time[4], time[5])
|
||||
: time.length === 7
|
||||
? Date.UTC(time[0], time[1], time[2], time[3], time[4], time[5], time[6])
|
||||
? Date.UTC(
|
||||
time[0],
|
||||
time[1],
|
||||
time[2],
|
||||
time[3],
|
||||
time[4],
|
||||
time[5],
|
||||
time[6],
|
||||
)
|
||||
: null;
|
||||
|
||||
if (!d) throw new Error("wrong number of arguments");
|
||||
|
|
|
@ -492,7 +492,7 @@ export function createIndexAllNotesJob(data = {}) {
|
|||
|
||||
export function webhookDeliver(
|
||||
webhook: Webhook,
|
||||
type: typeof webhookEventTypes[number],
|
||||
type: (typeof webhookEventTypes)[number],
|
||||
content: unknown,
|
||||
) {
|
||||
const data = {
|
||||
|
|
|
@ -10,9 +10,12 @@ import { ApiError } from "./error.js";
|
|||
|
||||
const userIpHistories = new Map<User["id"], Set<string>>();
|
||||
|
||||
setInterval(() => {
|
||||
setInterval(
|
||||
() => {
|
||||
userIpHistories.clear();
|
||||
}, 1000 * 60 * 60);
|
||||
},
|
||||
1000 * 60 * 60,
|
||||
);
|
||||
|
||||
export default (endpoint: IEndpoint, ctx: Koa.Context) =>
|
||||
new Promise<void>((res) => {
|
||||
|
|
|
@ -99,7 +99,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
async function fetchAny(
|
||||
uri: string,
|
||||
me: CacheableLocalUser | null | undefined,
|
||||
): Promise<SchemaType<typeof meta["res"]> | null> {
|
||||
): Promise<SchemaType<(typeof meta)["res"]> | null> {
|
||||
// Wait if blocked.
|
||||
if (await shouldBlockInstance(extractDbHost(uri))) return null;
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ export default define(meta, paramDef, async (ps, _user, token) => {
|
|||
profileUpdates.mutedInstances = ps.mutedInstances;
|
||||
if (ps.mutingNotificationTypes !== undefined)
|
||||
profileUpdates.mutingNotificationTypes =
|
||||
ps.mutingNotificationTypes as typeof notificationTypes[number][];
|
||||
ps.mutingNotificationTypes as (typeof notificationTypes)[number][];
|
||||
if (typeof ps.isLocked === "boolean") updates.isLocked = ps.isLocked;
|
||||
if (typeof ps.isExplorable === "boolean")
|
||||
updates.isExplorable = ps.isExplorable;
|
||||
|
|
|
@ -61,11 +61,14 @@ export const initializeStreamingServer = (server: http.Server) => {
|
|||
);
|
||||
|
||||
const intervalId = user
|
||||
? setInterval(() => {
|
||||
? setInterval(
|
||||
() => {
|
||||
Users.update(user.id, {
|
||||
lastActiveDate: new Date(),
|
||||
});
|
||||
}, 1000 * 60 * 5)
|
||||
},
|
||||
1000 * 60 * 5,
|
||||
)
|
||||
: null;
|
||||
if (user) {
|
||||
Users.update(user.id, {
|
||||
|
|
|
@ -44,13 +44,13 @@ type KeyToColumnName<T extends string> = T extends `${infer R1}.${infer R2}`
|
|||
: T;
|
||||
|
||||
type Columns<S extends Schema> = {
|
||||
[K in
|
||||
keyof S as `${typeof columnPrefix}${KeyToColumnName<string & K>}`]: number;
|
||||
[K in keyof S as `${typeof columnPrefix}${KeyToColumnName<
|
||||
string & K
|
||||
>}`]: number;
|
||||
};
|
||||
|
||||
type TempColumnsForUnique<S extends Schema> = {
|
||||
[K in
|
||||
keyof S as `${typeof uniqueTempColumnPrefix}${KeyToColumnName<
|
||||
[K in keyof S as `${typeof uniqueTempColumnPrefix}${KeyToColumnName<
|
||||
string & K
|
||||
>}`]: S[K]["uniqueIncrement"] extends true ? string[] : never;
|
||||
};
|
||||
|
@ -325,7 +325,7 @@ export default abstract class Chart<T extends Schema> {
|
|||
private getNewLog(latest: KVs<T> | null): KVs<T> {
|
||||
const log = {} as Record<keyof T, number>;
|
||||
for (const [k, v] of Object.entries(this.schema) as [
|
||||
keyof typeof this["schema"],
|
||||
keyof (typeof this)["schema"],
|
||||
this["schema"][string],
|
||||
][]) {
|
||||
if (v.accumulate && latest) {
|
||||
|
|
|
@ -42,10 +42,13 @@ const charts = [
|
|||
];
|
||||
|
||||
// 20分おきにメモリ情報をDBに書き込み
|
||||
setInterval(() => {
|
||||
setInterval(
|
||||
() => {
|
||||
for (const chart of charts) {
|
||||
chart.save();
|
||||
}
|
||||
}, 1000 * 60 * 20);
|
||||
},
|
||||
1000 * 60 * 20,
|
||||
);
|
||||
|
||||
beforeShutdown(() => Promise.all(charts.map((chart) => chart.save())));
|
||||
|
|
|
@ -22,7 +22,7 @@ describe("ユーザー", () => {
|
|||
// エンティティとしてのユーザーを主眼においたテストを記述する
|
||||
// (Userを返すエンドポイントとUserエンティティを書き換えるエンドポイントをテストする)
|
||||
|
||||
const stripUndefined = <T extends { [key: string]: any },>(
|
||||
const stripUndefined = <T extends { [key: string]: any }>(
|
||||
orig: T,
|
||||
): Partial<T> => {
|
||||
return Object.entries({ ...orig })
|
||||
|
@ -224,11 +224,15 @@ describe("ユーザー", () => {
|
|||
let userFollowRequesting: User;
|
||||
let userFollowRequested: User;
|
||||
|
||||
beforeAll(async () => {
|
||||
beforeAll(
|
||||
async () => {
|
||||
app = await startServer();
|
||||
}, 1000 * 60 * 2);
|
||||
},
|
||||
1000 * 60 * 2,
|
||||
);
|
||||
|
||||
beforeAll(async () => {
|
||||
beforeAll(
|
||||
async () => {
|
||||
root = await signup({ username: "root" });
|
||||
alice = await signup({ username: "alice" });
|
||||
aliceNote = (await post(alice, { text: "test" })) as any;
|
||||
|
@ -245,15 +249,21 @@ describe("ユーザー", () => {
|
|||
// @alice -> @replyingへのリプライ。Promise.allで一気に作るとtimeoutしてしまうのでreduceで一つ一つawaitする
|
||||
usersReplying = await [...Array(10)]
|
||||
.map((_, i) => i)
|
||||
.reduce(async (acc, i) => {
|
||||
.reduce(
|
||||
async (acc, i) => {
|
||||
const u = await signup({ username: `replying${i}` });
|
||||
for (let j = 0; j < 10 - i; j++) {
|
||||
const p = await post(u, { text: `test${j}` });
|
||||
await post(alice, { text: `@${u.username} test${j}`, replyId: p.id });
|
||||
await post(alice, {
|
||||
text: `@${u.username} test${j}`,
|
||||
replyId: p.id,
|
||||
});
|
||||
}
|
||||
|
||||
return (await acc).concat(u);
|
||||
}, Promise.resolve([] as User[]));
|
||||
},
|
||||
Promise.resolve([] as User[]),
|
||||
);
|
||||
|
||||
userNoNote = await signup({ username: "userNoNote" });
|
||||
userNotExplorable = await signup({ username: "userNotExplorable" });
|
||||
|
@ -263,7 +273,10 @@ describe("ユーザー", () => {
|
|||
await post(userLocking, { text: "test" });
|
||||
await api("i/update", { isLocked: true }, userLocking);
|
||||
userAdmin = await signup({ username: "userAdmin" });
|
||||
roleAdmin = await role(root, { isAdministrator: true, name: "Admin Role" });
|
||||
roleAdmin = await role(root, {
|
||||
isAdministrator: true,
|
||||
name: "Admin Role",
|
||||
});
|
||||
await api(
|
||||
"admin/roles/assign",
|
||||
{ userId: userAdmin.id, roleId: roleAdmin.id },
|
||||
|
@ -325,7 +338,11 @@ describe("ユーザー", () => {
|
|||
);
|
||||
userDeletedByAdmin = await signup({ username: "userDeletedByAdmin" });
|
||||
await post(userDeletedByAdmin, { text: "test" });
|
||||
await api("admin/delete-account", { userId: userDeletedByAdmin.id }, root);
|
||||
await api(
|
||||
"admin/delete-account",
|
||||
{ userId: userDeletedByAdmin.id },
|
||||
root,
|
||||
);
|
||||
userFollowingAlice = await signup({ username: "userFollowingAlice" });
|
||||
await post(userFollowingAlice, { text: "test" });
|
||||
await api("following/create", { userId: alice.id }, userFollowingAlice);
|
||||
|
@ -358,7 +375,9 @@ describe("ユーザー", () => {
|
|||
{ userId: userFollowRequested.id },
|
||||
userFollowRequesting,
|
||||
);
|
||||
}, 1000 * 60 * 10);
|
||||
},
|
||||
1000 * 60 * 10,
|
||||
);
|
||||
|
||||
afterAll(async () => {
|
||||
await app.close();
|
||||
|
|
3
packages/client/assets/tagcanvas.min.js
vendored
3
packages/client/assets/tagcanvas.min.js
vendored
|
@ -1476,7 +1476,8 @@
|
|||
(a.weightSizeMin > 0 && a.weightSizeMax > a.weightSizeMin
|
||||
? (this.textHeight =
|
||||
a.weightSize *
|
||||
(a.weightSizeMin + (a.weightSizeMax - a.weightSizeMin) * c))
|
||||
(a.weightSizeMin +
|
||||
(a.weightSizeMax - a.weightSizeMin) * c))
|
||||
: (this.textHeight = g(1, b * a.weightSize)));
|
||||
}),
|
||||
(d.SetShadowColourFixed = function (a, b, c) {
|
||||
|
|
|
@ -1023,8 +1023,9 @@ async function post() {
|
|||
|
||||
if (postAccount.value) {
|
||||
const storedAccounts = await getAccounts();
|
||||
token = storedAccounts.find((x) => x.id === postAccount.value.id)
|
||||
?.token;
|
||||
token = storedAccounts.find(
|
||||
(x) => x.id === postAccount.value.id,
|
||||
)?.token;
|
||||
}
|
||||
|
||||
posting.value = true;
|
||||
|
|
|
@ -62,7 +62,9 @@ const relative = computed<string>(() => {
|
|||
n: Math.floor(ago / 3600).toString(),
|
||||
})
|
||||
: ago >= 60
|
||||
? i18n.t("_ago.minutesAgo", { n: (~~(ago / 60)).toString() })
|
||||
? i18n.t("_ago.minutesAgo", {
|
||||
n: (~~(ago / 60)).toString(),
|
||||
})
|
||||
: ago >= 10
|
||||
? i18n.t("_ago.secondsAgo", {
|
||||
n: (~~(ago % 60)).toString(),
|
||||
|
|
|
@ -7,7 +7,7 @@ export const i18n = markRaw(new I18n(locale));
|
|||
// このファイルに書きたくないけどここに書かないと何故かVeturが認識しない
|
||||
declare module "@vue/runtime-core" {
|
||||
interface ComponentCustomProperties {
|
||||
$t: typeof i18n["t"];
|
||||
$ts: typeof i18n["locale"];
|
||||
$t: (typeof i18n)["t"];
|
||||
$ts: (typeof i18n)["locale"];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import { defaultStore } from "@/store";
|
|||
|
||||
export interface UnicodeEmojiDef {
|
||||
emoji: string;
|
||||
category: typeof unicodeEmojiCategories[number];
|
||||
category: (typeof unicodeEmojiCategories)[number];
|
||||
skin_tone_support: boolean;
|
||||
slug: string;
|
||||
keywords?: string[];
|
||||
|
|
|
@ -17,7 +17,15 @@ export function dateUTC(time: number[]): Date {
|
|||
: time.length === 6
|
||||
? Date.UTC(time[0], time[1], time[2], time[3], time[4], time[5])
|
||||
: time.length === 7
|
||||
? Date.UTC(time[0], time[1], time[2], time[3], time[4], time[5], time[6])
|
||||
? Date.UTC(
|
||||
time[0],
|
||||
time[1],
|
||||
time[2],
|
||||
time[3],
|
||||
time[4],
|
||||
time[5],
|
||||
time[6],
|
||||
)
|
||||
: null;
|
||||
|
||||
if (!d) throw "wrong number of arguments";
|
||||
|
|
|
@ -421,7 +421,7 @@ export class ColdDeviceStorage {
|
|||
|
||||
public static get<T extends keyof typeof ColdDeviceStorage.default>(
|
||||
key: T,
|
||||
): typeof ColdDeviceStorage.default[T] {
|
||||
): (typeof ColdDeviceStorage.default)[T] {
|
||||
// TODO: indexedDBにする
|
||||
// ただしその際はnullチェックではなくキー存在チェックにしないとダメ
|
||||
// (indexedDBはnullを保存できるため、ユーザーが意図してnullを格納した可能性がある)
|
||||
|
@ -435,7 +435,7 @@ export class ColdDeviceStorage {
|
|||
|
||||
public static set<T extends keyof typeof ColdDeviceStorage.default>(
|
||||
key: T,
|
||||
value: typeof ColdDeviceStorage.default[T],
|
||||
value: (typeof ColdDeviceStorage.default)[T],
|
||||
): void {
|
||||
// 呼び出し側のバグ等で undefined が来ることがある
|
||||
// undefined を文字列として localStorage に入れると参照する際の JSON.parse でコケて不具合の元になるため無視
|
||||
|
|
|
@ -31,7 +31,7 @@ export interface Column {
|
|||
antennaId?: string;
|
||||
channelId?: string;
|
||||
listId?: string;
|
||||
includingTypes?: typeof notificationTypes[number][];
|
||||
includingTypes?: (typeof notificationTypes)[number][];
|
||||
tl?: "home" | "local" | "social" | "recommended" | "global";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue