chore: format

This commit is contained in:
naskya 2024-02-09 04:14:28 +09:00
parent 78c9911788
commit 99c592f4dd
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
113 changed files with 801 additions and 749 deletions

View file

@ -30,10 +30,10 @@ function normalizeHost(
src === "." src === "."
? null // .はローカルホスト (ここがマッチするのはリアクションのみ) ? null // .はローカルホスト (ここがマッチするのはリアクションのみ)
: src === undefined : src === undefined
? noteUserHost // ノートなどでホスト省略表記の場合はローカルホスト (ここがリアクションにマッチすることはない) ? noteUserHost // ノートなどでホスト省略表記の場合はローカルホスト (ここがリアクションにマッチすることはない)
: isSelfHost(src) : isSelfHost(src)
? null // 自ホスト指定 ? null // 自ホスト指定
: src || noteUserHost; // 指定されたホスト || ノートなどの所有者のホスト (こっちがリアクションにマッチすることはない) : src || noteUserHost; // 指定されたホスト || ノートなどの所有者のホスト (こっちがリアクションにマッチすることはない)
host = toPunyNullable(host); host = toPunyNullable(host);

View file

@ -67,7 +67,7 @@ export const refs = {
Emoji: packedEmojiSchema, 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 = type TypeStringef =
| "null" | "null"
@ -81,18 +81,18 @@ type TypeStringef =
type StringDefToType<T extends TypeStringef> = T extends "null" type StringDefToType<T extends TypeStringef> = T extends "null"
? null ? null
: T extends "boolean" : T extends "boolean"
? boolean ? boolean
: T extends "integer" : T extends "integer"
? number ? number
: T extends "number" : T extends "number"
? number ? number
: T extends "string" : T extends "string"
? string | Date ? string | Date
: T extends "array" : T extends "array"
? ReadonlyArray<any> ? ReadonlyArray<any>
: T extends "object" : T extends "object"
? Record<string, any> ? Record<string, any>
: any; : any;
// https://swagger.io/specification/?sbsearch=optional#schema-object // https://swagger.io/specification/?sbsearch=optional#schema-object
type OfSchema = { type OfSchema = {
@ -130,14 +130,14 @@ type RequiredPropertyNames<s extends Obj> = {
s[K]["optional"] extends false s[K]["optional"] extends false
? K ? K
: // K has default value : // K has default value
s[K]["default"] extends s[K]["default"] extends
| null | null
| string | string
| number | number
| boolean | boolean
| Record<string, unknown> | Record<string, unknown>
? K ? K
: never; : never;
}[keyof s]; }[keyof s];
export type Obj = Record<string, Schema>; export type Obj = Record<string, Schema>;
@ -182,43 +182,47 @@ type ArrayUnion<T> = T extends any ? Array<T> : never;
export type SchemaTypeDef<p extends Schema> = p["type"] extends "null" export type SchemaTypeDef<p extends Schema> = p["type"] extends "null"
? null ? null
: p["type"] extends "integer" : p["type"] extends "integer"
? number ? number
: p["type"] extends "number" : p["type"] extends "number"
? number ? number
: p["type"] extends "string" : p["type"] extends "string"
? p["enum"] extends readonly string[] ? p["enum"] extends readonly string[]
? p["enum"][number] ? p["enum"][number]
: p["format"] extends "date-time" : p["format"] extends "date-time"
? string ? string
: // Dateにする : // Dateにする
string string
: p["type"] extends "boolean" : p["type"] extends "boolean"
? boolean ? boolean
: p["type"] extends "object" : p["type"] extends "object"
? p["ref"] extends keyof typeof refs ? p["ref"] extends keyof typeof refs
? Packed<p["ref"]> ? Packed<p["ref"]>
: p["properties"] extends NonNullable<Obj> : p["properties"] extends NonNullable<Obj>
? ObjType<p["properties"], NonNullable<p["required"]>[number]> ? ObjType<p["properties"], NonNullable<p["required"]>[number]>
: p["anyOf"] extends ReadonlyArray<Schema> : p["anyOf"] extends ReadonlyArray<Schema>
? UnionSchemaType<p["anyOf"]> & ? UnionSchemaType<p["anyOf"]> &
Partial<UnionToIntersection<UnionSchemaType<p["anyOf"]>>> Partial<UnionToIntersection<UnionSchemaType<p["anyOf"]>>>
: p["allOf"] extends ReadonlyArray<Schema> : p["allOf"] extends ReadonlyArray<Schema>
? UnionToIntersection<UnionSchemaType<p["allOf"]>> ? UnionToIntersection<UnionSchemaType<p["allOf"]>>
: any : any
: p["type"] extends "array" : p["type"] extends "array"
? p["items"] extends OfSchema ? p["items"] extends OfSchema
? p["items"]["anyOf"] extends ReadonlyArray<Schema> ? p["items"]["anyOf"] extends ReadonlyArray<Schema>
? UnionSchemaType<NonNullable<p["items"]["anyOf"]>>[] ? UnionSchemaType<NonNullable<p["items"]["anyOf"]>>[]
: p["items"]["oneOf"] extends ReadonlyArray<Schema> : p["items"]["oneOf"] extends ReadonlyArray<Schema>
? ArrayUnion<UnionSchemaType<NonNullable<p["items"]["oneOf"]>>> ? ArrayUnion<
: p["items"]["allOf"] extends ReadonlyArray<Schema> UnionSchemaType<NonNullable<p["items"]["oneOf"]>>
? UnionToIntersection<UnionSchemaType<NonNullable<p["items"]["allOf"]>>>[] >
: never : p["items"]["allOf"] extends ReadonlyArray<Schema>
: p["items"] extends NonNullable<Schema> ? UnionToIntersection<
? SchemaTypeDef<p["items"]>[] UnionSchemaType<NonNullable<p["items"]["allOf"]>>
: any[] >[]
: p["oneOf"] extends ReadonlyArray<Schema> : never
? UnionSchemaType<p["oneOf"]> : p["items"] extends NonNullable<Schema>
: any; ? SchemaTypeDef<p["items"]>[]
: any[]
: p["oneOf"] extends ReadonlyArray<Schema>
? UnionSchemaType<p["oneOf"]>
: any;
export type SchemaType<p extends Schema> = NullOrUndefined<p, SchemaTypeDef<p>>; export type SchemaType<p extends Schema> = NullOrUndefined<p, SchemaTypeDef<p>>;

View file

@ -51,5 +51,5 @@ export class MutedNote {
enum: mutedNoteReasons, enum: mutedNoteReasons,
comment: "The reason of the MutedNote.", comment: "The reason of the MutedNote.",
}) })
public reason: typeof mutedNoteReasons[number]; public reason: (typeof mutedNoteReasons)[number];
} }

View file

@ -125,7 +125,7 @@ export class Note {
* specified ... visibleUserIds * specified ... visibleUserIds
*/ */
@Column("enum", { enum: noteVisibilities }) @Column("enum", { enum: noteVisibilities })
public visibility: typeof noteVisibilities[number]; public visibility: (typeof noteVisibilities)[number];
@Index({ unique: true }) @Index({ unique: true })
@Column("varchar", { @Column("varchar", {

View file

@ -78,7 +78,7 @@ export class Notification {
enum: notificationTypes, enum: notificationTypes,
comment: "The type of the Notification.", comment: "The type of the Notification.",
}) })
public type: typeof notificationTypes[number]; public type: (typeof notificationTypes)[number];
/** /**
* Whether the notification was read. * Whether the notification was read.

View file

@ -47,7 +47,7 @@ export class Poll {
enum: noteVisibilities, enum: noteVisibilities,
comment: "[Denormalized]", comment: "[Denormalized]",
}) })
public noteVisibility: typeof noteVisibilities[number]; public noteVisibility: (typeof noteVisibilities)[number];
@Index() @Index()
@Column({ @Column({

View file

@ -99,7 +99,7 @@ export class UserProfile {
enum: ffVisibility, enum: ffVisibility,
default: "public", default: "public",
}) })
public ffVisibility: typeof ffVisibility[number]; public ffVisibility: (typeof ffVisibility)[number];
@Column("varchar", { @Column("varchar", {
length: 128, length: 128,
@ -238,7 +238,7 @@ export class UserProfile {
array: true, array: true,
default: [], default: [],
}) })
public mutingNotificationTypes: typeof notificationTypes[number][]; public mutingNotificationTypes: (typeof notificationTypes)[number][];
//#region Denormalized fields //#region Denormalized fields
@Index() @Index()

View file

@ -55,7 +55,7 @@ export class Webhook {
array: true, array: true,
default: "{}", default: "{}",
}) })
public on: typeof webhookEventTypes[number][]; public on: (typeof webhookEventTypes)[number][];
@Column("varchar", { @Column("varchar", {
length: 1024, length: 1024,

View file

@ -80,9 +80,9 @@ export const PageRepository = db.getRepository(Page).extend({
? await DriveFiles.pack(page.eyeCatchingImageId) ? await DriveFiles.pack(page.eyeCatchingImageId)
: null, : null,
attachedFiles: DriveFiles.packMany( attachedFiles: DriveFiles.packMany(
( (await Promise.all(attachedFiles)).filter(
await Promise.all(attachedFiles) (x): x is DriveFile => x != null,
).filter((x): x is DriveFile => x != null), ),
), ),
likedCount: page.likedCount, likedCount: page.likedCount,
isLiked: meId isLiked: meId

View file

@ -52,8 +52,8 @@ type IsMeAndIsUserDetailed<
? ExpectsMe extends true ? ExpectsMe extends true
? Packed<"MeDetailed"> ? Packed<"MeDetailed">
: ExpectsMe extends false : ExpectsMe extends false
? Packed<"UserDetailedNotMe"> ? Packed<"UserDetailedNotMe">
: Packed<"UserDetailed"> : Packed<"UserDetailed">
: Packed<"UserLite">; : Packed<"UserLite">;
const ajv = new Ajv(); const ajv = new Ajv();
@ -327,8 +327,8 @@ export const UserRepository = db.getRepository(User).extend({
return elapsed < USER_ONLINE_THRESHOLD return elapsed < USER_ONLINE_THRESHOLD
? "online" ? "online"
: elapsed < USER_ACTIVE_THRESHOLD : elapsed < USER_ACTIVE_THRESHOLD
? "active" ? "active"
: "offline"; : "offline";
}, },
async getAvatarUrl(user: User): Promise<string> { async getAvatarUrl(user: User): Promise<string> {
@ -421,23 +421,23 @@ export const UserRepository = db.getRepository(User).extend({
profile == null profile == null
? null ? null
: profile.ffVisibility === "public" || isMe : profile.ffVisibility === "public" || isMe
? user.followingCount ? user.followingCount
: profile.ffVisibility === "followers" && : profile.ffVisibility === "followers" &&
relation && relation &&
relation.isFollowing relation.isFollowing
? user.followingCount ? user.followingCount
: null; : null;
const followersCount = const followersCount =
profile == null profile == null
? null ? null
: profile.ffVisibility === "public" || isMe : profile.ffVisibility === "public" || isMe
? user.followersCount ? user.followersCount
: profile.ffVisibility === "followers" && : profile.ffVisibility === "followers" &&
relation && relation &&
relation.isFollowing relation.isFollowing
? user.followersCount ? user.followersCount
: null; : null;
const falsy = opts.detail ? false : undefined; const falsy = opts.detail ? false : undefined;

View file

@ -9,16 +9,24 @@ export function dateUTC(time: number[]): Date {
time.length === 2 time.length === 2
? Date.UTC(time[0], time[1]) ? Date.UTC(time[0], time[1])
: time.length === 3 : time.length === 3
? Date.UTC(time[0], time[1], time[2]) ? Date.UTC(time[0], time[1], time[2])
: time.length === 4 : time.length === 4
? Date.UTC(time[0], time[1], time[2], time[3]) ? Date.UTC(time[0], time[1], time[2], time[3])
: time.length === 5 : time.length === 5
? Date.UTC(time[0], time[1], time[2], time[3], time[4]) ? Date.UTC(time[0], time[1], time[2], time[3], time[4])
: time.length === 6 : time.length === 6
? Date.UTC(time[0], time[1], time[2], time[3], time[4], time[5]) ? Date.UTC(time[0], time[1], time[2], time[3], time[4], time[5])
: time.length === 7 : time.length === 7
? Date.UTC(time[0], time[1], time[2], time[3], time[4], time[5], time[6]) ? Date.UTC(
: null; time[0],
time[1],
time[2],
time[3],
time[4],
time[5],
time[6],
)
: null;
if (!d) throw new Error("wrong number of arguments"); if (!d) throw new Error("wrong number of arguments");

View file

@ -7,8 +7,8 @@ export function getJobInfo(job: Bull.Job, increment = false) {
age > 60000 age > 60000
? `${Math.floor(age / 1000 / 60)}m` ? `${Math.floor(age / 1000 / 60)}m`
: age > 10000 : age > 10000
? `${Math.floor(age / 1000)}s` ? `${Math.floor(age / 1000)}s`
: `${age}ms`; : `${age}ms`;
// onActiveとかonCompletedのattemptsMadeがなぜか0始まりなのでインクリメントする // onActiveとかonCompletedのattemptsMadeがなぜか0始まりなのでインクリメントする
const currentAttempts = job.attemptsMade + (increment ? 1 : 0); const currentAttempts = job.attemptsMade + (increment ? 1 : 0);

View file

@ -492,7 +492,7 @@ export function createIndexAllNotesJob(data = {}) {
export function webhookDeliver( export function webhookDeliver(
webhook: Webhook, webhook: Webhook,
type: typeof webhookEventTypes[number], type: (typeof webhookEventTypes)[number],
content: unknown, content: unknown,
) { ) {
const data = { const data = {

View file

@ -205,8 +205,8 @@ export async function createNote(
note.attachment = Array.isArray(note.attachment) note.attachment = Array.isArray(note.attachment)
? note.attachment ? note.attachment
: note.attachment : note.attachment
? [note.attachment] ? [note.attachment]
: []; : [];
const files = note.attachment.map( const files = note.attachment.map(
(attach) => (attach.sensitive = note.sensitive), (attach) => (attach.sensitive = note.sensitive),
) )

View file

@ -276,26 +276,26 @@ export async function createPerson(
followersCount !== undefined followersCount !== undefined
? followersCount ? followersCount
: person.followers && : person.followers &&
typeof person.followers !== "string" && typeof person.followers !== "string" &&
isCollectionOrOrderedCollection(person.followers) isCollectionOrOrderedCollection(person.followers)
? person.followers.totalItems ? person.followers.totalItems
: undefined, : undefined,
followingCount: followingCount:
followingCount !== undefined followingCount !== undefined
? followingCount ? followingCount
: person.following && : person.following &&
typeof person.following !== "string" && typeof person.following !== "string" &&
isCollectionOrOrderedCollection(person.following) isCollectionOrOrderedCollection(person.following)
? person.following.totalItems ? person.following.totalItems
: undefined, : undefined,
notesCount: notesCount:
notesCount !== undefined notesCount !== undefined
? notesCount ? notesCount
: person.outbox && : person.outbox &&
typeof person.outbox !== "string" && typeof person.outbox !== "string" &&
isCollectionOrOrderedCollection(person.outbox) isCollectionOrOrderedCollection(person.outbox)
? person.outbox.totalItems ? person.outbox.totalItems
: undefined, : undefined,
featured: person.featured ? getApId(person.featured) : undefined, featured: person.featured ? getApId(person.featured) : undefined,
uri: person.id, uri: person.id,
tags, tags,
@ -315,8 +315,8 @@ export async function createPerson(
description: person._misskey_summary description: person._misskey_summary
? truncate(person._misskey_summary, summaryLength) ? truncate(person._misskey_summary, summaryLength)
: person.summary : person.summary
? htmlToMfm(truncate(person.summary, summaryLength), person.tag) ? htmlToMfm(truncate(person.summary, summaryLength), person.tag)
: null, : null,
url: url, url: url,
fields, fields,
birthday: bday ? bday[0] : null, birthday: bday ? bday[0] : null,
@ -527,26 +527,26 @@ export async function updatePerson(
followersCount !== undefined followersCount !== undefined
? followersCount ? followersCount
: person.followers && : person.followers &&
typeof person.followers !== "string" && typeof person.followers !== "string" &&
isCollectionOrOrderedCollection(person.followers) isCollectionOrOrderedCollection(person.followers)
? person.followers.totalItems ? person.followers.totalItems
: undefined, : undefined,
followingCount: followingCount:
followingCount !== undefined followingCount !== undefined
? followingCount ? followingCount
: person.following && : person.following &&
typeof person.following !== "string" && typeof person.following !== "string" &&
isCollectionOrOrderedCollection(person.following) isCollectionOrOrderedCollection(person.following)
? person.following.totalItems ? person.following.totalItems
: undefined, : undefined,
notesCount: notesCount:
notesCount !== undefined notesCount !== undefined
? notesCount ? notesCount
: person.outbox && : person.outbox &&
typeof person.outbox !== "string" && typeof person.outbox !== "string" &&
isCollectionOrOrderedCollection(person.outbox) isCollectionOrOrderedCollection(person.outbox)
? person.outbox.totalItems ? person.outbox.totalItems
: undefined, : undefined,
featured: person.featured, featured: person.featured,
emojis: emojiNames, emojis: emojiNames,
name: truncate(person.name, nameLength), name: truncate(person.name, nameLength),
@ -593,8 +593,8 @@ export async function updatePerson(
description: person._misskey_summary description: person._misskey_summary
? truncate(person._misskey_summary, summaryLength) ? truncate(person._misskey_summary, summaryLength)
: person.summary : person.summary
? htmlToMfm(truncate(person.summary, summaryLength), person.tag) ? htmlToMfm(truncate(person.summary, summaryLength), person.tag)
: null, : null,
birthday: bday ? bday[0] : null, birthday: bday ? bday[0] : null,
location: person["vcard:Address"] || null, location: person["vcard:Address"] || null,
}, },

View file

@ -22,8 +22,8 @@ export async function extractPollFromQuestion(
const expiresAt = question.endTime const expiresAt = question.endTime
? new Date(question.endTime) ? new Date(question.endTime)
: question.closed : question.closed
? new Date(question.closed) ? new Date(question.closed)
: null; : null;
if (multiple && !question.anyOf) { if (multiple && !question.anyOf) {
throw new Error("invalid question"); throw new Error("invalid question");

View file

@ -10,17 +10,20 @@ import { ApiError } from "./error.js";
const userIpHistories = new Map<User["id"], Set<string>>(); const userIpHistories = new Map<User["id"], Set<string>>();
setInterval(() => { setInterval(
userIpHistories.clear(); () => {
}, 1000 * 60 * 60); userIpHistories.clear();
},
1000 * 60 * 60,
);
export default (endpoint: IEndpoint, ctx: Koa.Context) => export default (endpoint: IEndpoint, ctx: Koa.Context) =>
new Promise<void>((res) => { new Promise<void>((res) => {
const body = ctx.is("multipart/form-data") const body = ctx.is("multipart/form-data")
? (ctx.request as any).body ? (ctx.request as any).body
: ctx.method === "GET" : ctx.method === "GET"
? ctx.query ? ctx.query
: ctx.request.body; : ctx.request.body;
const reply = (x?: any, y?: ApiError) => { const reply = (x?: any, y?: ApiError) => {
if (x == null) { if (x == null) {
@ -73,8 +76,8 @@ export default (endpoint: IEndpoint, ctx: Koa.Context) =>
e.httpStatusCode e.httpStatusCode
? e.httpStatusCode ? e.httpStatusCode
: e.kind === "client" : e.kind === "client"
? 400 ? 400
: 500, : 500,
e, e,
); );
}); });

View file

@ -99,7 +99,7 @@ export default define(meta, paramDef, async (ps, me) => {
async function fetchAny( async function fetchAny(
uri: string, uri: string,
me: CacheableLocalUser | null | undefined, me: CacheableLocalUser | null | undefined,
): Promise<SchemaType<typeof meta["res"]> | null> { ): Promise<SchemaType<(typeof meta)["res"]> | null> {
// Wait if blocked. // Wait if blocked.
if (await shouldBlockInstance(extractDbHost(uri))) return null; if (await shouldBlockInstance(extractDbHost(uri))) return null;

View file

@ -38,16 +38,16 @@ export default define(meta, paramDef, async (ps, user) => {
item.value === null item.value === null
? "null" ? "null"
: Array.isArray(item.value) : Array.isArray(item.value)
? "array" ? "array"
: type === "number" : type === "number"
? "number" ? "number"
: type === "string" : type === "string"
? "string" ? "string"
: type === "boolean" : type === "boolean"
? "boolean" ? "boolean"
: type === "object" : type === "object"
? "object" ? "object"
: (null as never); : (null as never);
} }
return res; return res;

View file

@ -189,7 +189,7 @@ export default define(meta, paramDef, async (ps, _user, token) => {
profileUpdates.mutedInstances = ps.mutedInstances; profileUpdates.mutedInstances = ps.mutedInstances;
if (ps.mutingNotificationTypes !== undefined) if (ps.mutingNotificationTypes !== undefined)
profileUpdates.mutingNotificationTypes = 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.isLocked === "boolean") updates.isLocked = ps.isLocked;
if (typeof ps.isExplorable === "boolean") if (typeof ps.isExplorable === "boolean")
updates.isExplorable = ps.isExplorable; updates.isExplorable = ps.isExplorable;

View file

@ -293,14 +293,14 @@ export default define(meta, paramDef, async (ps, me) => {
}, },
] ]
: ps.host !== undefined : ps.host !== undefined
? [ ? [
{ {
term: { term: {
userHost: ps.host, userHost: ps.host,
},
}, },
}, ]
] : []
: []
: []; : [];
const result = await es.search({ const result = await es.search({

View file

@ -128,7 +128,7 @@ export default define(meta, paramDef, async (ps, user) => {
ps.eyeCatchingImageId === null ps.eyeCatchingImageId === null
? null ? null
: ps.eyeCatchingImageId === undefined : ps.eyeCatchingImageId === undefined
? page.eyeCatchingImageId ? page.eyeCatchingImageId
: eyeCatchingImage!.id, : eyeCatchingImage!.id,
}); });
}); });

View file

@ -61,11 +61,14 @@ export const initializeStreamingServer = (server: http.Server) => {
); );
const intervalId = user const intervalId = user
? setInterval(() => { ? setInterval(
Users.update(user.id, { () => {
lastActiveDate: new Date(), Users.update(user.id, {
}); lastActiveDate: new Date(),
}, 1000 * 60 * 5) });
},
1000 * 60 * 5,
)
: null; : null;
if (user) { if (user) {
Users.update(user.id, { Users.update(user.id, {

View file

@ -114,8 +114,8 @@ router.get(webFingerPath, async (ctx) => {
resource.startsWith(`${config.url.toLowerCase()}/@`) resource.startsWith(`${config.url.toLowerCase()}/@`)
? resource.split("/").pop()! ? resource.split("/").pop()!
: resource.startsWith("acct:") : resource.startsWith("acct:")
? resource.slice("acct:".length) ? resource.slice("acct:".length)
: resource, : resource,
), ),
); );

View file

@ -44,15 +44,15 @@ type KeyToColumnName<T extends string> = T extends `${infer R1}.${infer R2}`
: T; : T;
type Columns<S extends Schema> = { type Columns<S extends Schema> = {
[K in [K in keyof S as `${typeof columnPrefix}${KeyToColumnName<
keyof S as `${typeof columnPrefix}${KeyToColumnName<string & K>}`]: number; string & K
>}`]: number;
}; };
type TempColumnsForUnique<S extends Schema> = { type TempColumnsForUnique<S extends Schema> = {
[K in [K in keyof S as `${typeof uniqueTempColumnPrefix}${KeyToColumnName<
keyof S as `${typeof uniqueTempColumnPrefix}${KeyToColumnName< string & K
string & K >}`]: S[K]["uniqueIncrement"] extends true ? string[] : never;
>}`]: S[K]["uniqueIncrement"] extends true ? string[] : never;
}; };
type RawRecord<S extends Schema> = { type RawRecord<S extends Schema> = {
@ -186,8 +186,8 @@ export default abstract class Chart<T extends Schema> {
v.range === "big" v.range === "big"
? "bigint" ? "bigint"
: v.range === "small" : v.range === "small"
? "smallint" ? "smallint"
: "integer"; : "integer";
if (v.uniqueIncrement) { if (v.uniqueIncrement) {
columns[uniqueTempColumnPrefix + name] = { columns[uniqueTempColumnPrefix + name] = {
type: "varchar", type: "varchar",
@ -244,8 +244,8 @@ export default abstract class Chart<T extends Schema> {
span === "hour" span === "hour"
? `__chart__${camelToSnake(name)}` ? `__chart__${camelToSnake(name)}`
: span === "day" : span === "day"
? `__chart_day__${camelToSnake(name)}` ? `__chart_day__${camelToSnake(name)}`
: (new Error("not happen") as never), : (new Error("not happen") as never),
columns: { columns: {
id: { id: {
type: "integer", type: "integer",
@ -325,7 +325,7 @@ export default abstract class Chart<T extends Schema> {
private getNewLog(latest: KVs<T> | null): KVs<T> { private getNewLog(latest: KVs<T> | null): KVs<T> {
const log = {} as Record<keyof T, number>; const log = {} as Record<keyof T, number>;
for (const [k, v] of Object.entries(this.schema) as [ for (const [k, v] of Object.entries(this.schema) as [
keyof typeof this["schema"], keyof (typeof this)["schema"],
this["schema"][string], this["schema"][string],
][]) { ][]) {
if (v.accumulate && latest) { if (v.accumulate && latest) {
@ -345,8 +345,8 @@ export default abstract class Chart<T extends Schema> {
span === "hour" span === "hour"
? this.repositoryForHour ? this.repositoryForHour
: span === "day" : span === "day"
? this.repositoryForDay ? this.repositoryForDay
: (new Error("not happen") as never); : (new Error("not happen") as never);
return repository return repository
.findOne({ .findOne({
@ -375,16 +375,16 @@ export default abstract class Chart<T extends Schema> {
span === "hour" span === "hour"
? [y, m, d, h] ? [y, m, d, h]
: span === "day" : span === "day"
? [y, m, d] ? [y, m, d]
: (new Error("not happen") as never), : (new Error("not happen") as never),
); );
const repository = const repository =
span === "hour" span === "hour"
? this.repositoryForHour ? this.repositoryForHour
: span === "day" : span === "day"
? this.repositoryForDay ? this.repositoryForDay
: (new Error("not happen") as never); : (new Error("not happen") as never);
// 現在(=今のHour or Day)のログ // 現在(=今のHour or Day)のログ
const currentLog = (await repository.findOneBy({ const currentLog = (await repository.findOneBy({
@ -793,19 +793,19 @@ export default abstract class Chart<T extends Schema> {
"day", "day",
) )
: span === "hour" : span === "hour"
? subtractTime( ? subtractTime(
cursor ? dateUTC([y2, m2, d2, h2]) : dateUTC([y, m, d, h]), cursor ? dateUTC([y2, m2, d2, h2]) : dateUTC([y, m, d, h]),
amount - 1, amount - 1,
"hour", "hour",
) )
: (new Error("not happen") as never); : (new Error("not happen") as never);
const repository = const repository =
span === "hour" span === "hour"
? this.repositoryForHour ? this.repositoryForHour
: span === "day" : span === "day"
? this.repositoryForDay ? this.repositoryForDay
: (new Error("not happen") as never); : (new Error("not happen") as never);
// ログ取得 // ログ取得
let logs = (await repository.find({ let logs = (await repository.find({
@ -863,8 +863,8 @@ export default abstract class Chart<T extends Schema> {
span === "hour" span === "hour"
? subtractTime(dateUTC([y, m, d, h]), i, "hour") ? subtractTime(dateUTC([y, m, d, h]), i, "hour")
: span === "day" : span === "day"
? subtractTime(dateUTC([y, m, d]), i, "day") ? subtractTime(dateUTC([y, m, d]), i, "day")
: (new Error("not happen") as never); : (new Error("not happen") as never);
const log = logs.find((l) => const log = logs.find((l) =>
isTimeSame(new Date(l.date * 1000), current), isTimeSame(new Date(l.date * 1000), current),

View file

@ -42,10 +42,13 @@ const charts = [
]; ];
// 20分おきにメモリ情報をDBに書き込み // 20分おきにメモリ情報をDBに書き込み
setInterval(() => { setInterval(
for (const chart of charts) { () => {
chart.save(); for (const chart of charts) {
} chart.save();
}, 1000 * 60 * 20); }
},
1000 * 60 * 20,
);
beforeShutdown(() => Promise.all(charts.map((chart) => chart.save()))); beforeShutdown(() => Promise.all(charts.map((chart) => chart.save())));

View file

@ -497,12 +497,12 @@ export async function addFile({
instance.sensitiveMediaDetectionSensitivity === "veryHigh" instance.sensitiveMediaDetectionSensitivity === "veryHigh"
? 0.1 ? 0.1
: instance.sensitiveMediaDetectionSensitivity === "high" : instance.sensitiveMediaDetectionSensitivity === "high"
? 0.3 ? 0.3
: instance.sensitiveMediaDetectionSensitivity === "low" : instance.sensitiveMediaDetectionSensitivity === "low"
? 0.7 ? 0.7
: instance.sensitiveMediaDetectionSensitivity === "veryLow" : instance.sensitiveMediaDetectionSensitivity === "veryLow"
? 0.9 ? 0.9
: 0.5, : 0.5,
sensitiveThresholdForPorn: 0.75, sensitiveThresholdForPorn: 0.75,
enableSensitiveMediaDetectionForVideos: enableSensitiveMediaDetectionForVideos:
instance.enableSensitiveMediaDetectionForVideos, instance.enableSensitiveMediaDetectionForVideos,
@ -627,8 +627,8 @@ export async function addFile({
? Users.isLocalUser(user) && profile!.alwaysMarkNsfw ? Users.isLocalUser(user) && profile!.alwaysMarkNsfw
? true ? true
: sensitive != null : sensitive != null
? sensitive ? sensitive
: false : false
: false; : false;
if (info.sensitive && profile!.autoSensitive) file.isSensitive = true; if (info.sensitive && profile!.autoSensitive) file.isSensitive = true;

View file

@ -80,16 +80,16 @@ export default class Logger {
? chalk.bgRed.white("ERR ") ? chalk.bgRed.white("ERR ")
: chalk.red("ERR ") : chalk.red("ERR ")
: level === "warning" : level === "warning"
? chalk.yellow("WARN") ? chalk.yellow("WARN")
: level === "success" : level === "success"
? important ? important
? chalk.bgGreen.white("DONE") ? chalk.bgGreen.white("DONE")
: chalk.green("DONE") : chalk.green("DONE")
: level === "debug" : level === "debug"
? chalk.gray("VERB") ? chalk.gray("VERB")
: level === "info" : level === "info"
? chalk.blue("INFO") ? chalk.blue("INFO")
: null; : null;
const domains = [this.domain] const domains = [this.domain]
.concat(subDomains) .concat(subDomains)
.map((d) => .map((d) =>
@ -101,14 +101,14 @@ export default class Logger {
level === "error" level === "error"
? chalk.red(message) ? chalk.red(message)
: level === "warning" : level === "warning"
? chalk.yellow(message) ? chalk.yellow(message)
: level === "success" : level === "success"
? chalk.green(message) ? chalk.green(message)
: level === "debug" : level === "debug"
? chalk.gray(message) ? chalk.gray(message)
: level === "info" : level === "info"
? message ? message
: null; : null;
let log = `${l} ${worker}\t[${domains.join(" ")}]\t${m}`; let log = `${l} ${worker}\t[${domains.join(" ")}]\t${m}`;
if (envOption.withLogTime) log = `${chalk.gray(time)} ${log}`; if (envOption.withLogTime) log = `${chalk.gray(time)} ${log}`;
@ -125,14 +125,14 @@ export default class Logger {
level === "error" level === "error"
? this.syslogClient.error ? this.syslogClient.error
: level === "warning" : level === "warning"
? this.syslogClient.warning ? this.syslogClient.warning
: level === "success" : level === "success"
? this.syslogClient.info ? this.syslogClient.info
: level === "debug" : level === "debug"
? this.syslogClient.info ? this.syslogClient.info
: level === "info" : level === "info"
? this.syslogClient.info ? this.syslogClient.info
: (null as never); : (null as never);
send send
.bind(this.syslogClient)(message) .bind(this.syslogClient)(message)

View file

@ -33,8 +33,8 @@ class Publisher {
type == null type == null
? value ? value
: value == null : value == null
? { type: type, body: null } ? { type: type, body: null }
: { type: type, body: value }; : { type: type, body: value };
redisClient.publish( redisClient.publish(
config.host, config.host,

View file

@ -31,15 +31,15 @@ export async function validateEmailForAccount(emailAddress: string): Promise<{
reason: available reason: available
? null ? null
: exist !== 0 : exist !== 0
? "used" ? "used"
: validated.reason === "regex" : validated.reason === "regex"
? "format" ? "format"
: validated.reason === "disposable" : validated.reason === "disposable"
? "disposable" ? "disposable"
: validated.reason === "mx" : validated.reason === "mx"
? "mx" ? "mx"
: validated.reason === "smtp" : validated.reason === "smtp"
? "smtp" ? "smtp"
: null, : null,
}; };
} }

View file

@ -22,7 +22,7 @@ describe("ユーザー", () => {
// エンティティとしてのユーザーを主眼においたテストを記述する // エンティティとしてのユーザーを主眼においたテストを記述する
// (Userを返すエンドポイントとUserエンティティを書き換えるエンドポイントをテストする) // (Userを返すエンドポイントとUserエンティティを書き換えるエンドポイントをテストする)
const stripUndefined = <T extends { [key: string]: any },>( const stripUndefined = <T extends { [key: string]: any }>(
orig: T, orig: T,
): Partial<T> => { ): Partial<T> => {
return Object.entries({ ...orig }) return Object.entries({ ...orig })
@ -224,141 +224,160 @@ describe("ユーザー", () => {
let userFollowRequesting: User; let userFollowRequesting: User;
let userFollowRequested: User; let userFollowRequested: User;
beforeAll(async () => { beforeAll(
app = await startServer(); async () => {
}, 1000 * 60 * 2); app = await startServer();
},
1000 * 60 * 2,
);
beforeAll(async () => { beforeAll(
root = await signup({ username: "root" }); async () => {
alice = await signup({ username: "alice" }); root = await signup({ username: "root" });
aliceNote = (await post(alice, { text: "test" })) as any; alice = await signup({ username: "alice" });
alicePage = await page(alice); aliceNote = (await post(alice, { text: "test" })) as any;
aliceList = (await api("users/list/create", { name: "aliceList" }, alice)) alicePage = await page(alice);
.body; aliceList = (await api("users/list/create", { name: "aliceList" }, alice))
bob = await signup({ username: "bob" }); .body;
bobNote = (await post(bob, { text: "test" })) as any; bob = await signup({ username: "bob" });
carol = await signup({ username: "carol" }); bobNote = (await post(bob, { text: "test" })) as any;
dave = await signup({ username: "dave" }); carol = await signup({ username: "carol" });
ellen = await signup({ username: "ellen" }); dave = await signup({ username: "dave" });
frank = await signup({ username: "frank" }); ellen = await signup({ username: "ellen" });
frank = await signup({ username: "frank" });
// @alice -> @replyingへのリプライ。Promise.allで一気に作るとtimeoutしてしまうのでreduceで一つ一つawaitする // @alice -> @replyingへのリプライ。Promise.allで一気に作るとtimeoutしてしまうのでreduceで一つ一つawaitする
usersReplying = await [...Array(10)] usersReplying = await [...Array(10)]
.map((_, i) => i) .map((_, i) => i)
.reduce(async (acc, i) => { .reduce(
const u = await signup({ username: `replying${i}` }); async (acc, i) => {
for (let j = 0; j < 10 - i; j++) { const u = await signup({ username: `replying${i}` });
const p = await post(u, { text: `test${j}` }); for (let j = 0; j < 10 - i; j++) {
await post(alice, { text: `@${u.username} test${j}`, replyId: p.id }); const p = await post(u, { text: `test${j}` });
} await post(alice, {
text: `@${u.username} test${j}`,
replyId: p.id,
});
}
return (await acc).concat(u); return (await acc).concat(u);
}, Promise.resolve([] as User[])); },
Promise.resolve([] as User[]),
);
userNoNote = await signup({ username: "userNoNote" }); userNoNote = await signup({ username: "userNoNote" });
userNotExplorable = await signup({ username: "userNotExplorable" }); userNotExplorable = await signup({ username: "userNotExplorable" });
await post(userNotExplorable, { text: "test" }); await post(userNotExplorable, { text: "test" });
await api("i/update", { isExplorable: false }, userNotExplorable); await api("i/update", { isExplorable: false }, userNotExplorable);
userLocking = await signup({ username: "userLocking" }); userLocking = await signup({ username: "userLocking" });
await post(userLocking, { text: "test" }); await post(userLocking, { text: "test" });
await api("i/update", { isLocked: true }, userLocking); await api("i/update", { isLocked: true }, userLocking);
userAdmin = await signup({ username: "userAdmin" }); userAdmin = await signup({ username: "userAdmin" });
roleAdmin = await role(root, { isAdministrator: true, name: "Admin Role" }); roleAdmin = await role(root, {
await api( isAdministrator: true,
"admin/roles/assign", name: "Admin Role",
{ userId: userAdmin.id, roleId: roleAdmin.id }, });
root, await api(
); "admin/roles/assign",
userModerator = await signup({ username: "userModerator" }); { userId: userAdmin.id, roleId: roleAdmin.id },
roleModerator = await role(root, { root,
isModerator: true, );
name: "Moderator Role", userModerator = await signup({ username: "userModerator" });
}); roleModerator = await role(root, {
await api( isModerator: true,
"admin/roles/assign", name: "Moderator Role",
{ userId: userModerator.id, roleId: roleModerator.id }, });
root, await api(
); "admin/roles/assign",
userRolePublic = await signup({ username: "userRolePublic" }); { userId: userModerator.id, roleId: roleModerator.id },
rolePublic = await role(root, { isPublic: true, name: "Public Role" }); root,
await api( );
"admin/roles/assign", userRolePublic = await signup({ username: "userRolePublic" });
{ userId: userRolePublic.id, roleId: rolePublic.id }, rolePublic = await role(root, { isPublic: true, name: "Public Role" });
root, await api(
); "admin/roles/assign",
userRoleBadge = await signup({ username: "userRoleBadge" }); { userId: userRolePublic.id, roleId: rolePublic.id },
roleBadge = await role(root, { asBadge: true, name: "Badge Role" }); root,
await api( );
"admin/roles/assign", userRoleBadge = await signup({ username: "userRoleBadge" });
{ userId: userRoleBadge.id, roleId: roleBadge.id }, roleBadge = await role(root, { asBadge: true, name: "Badge Role" });
root, await api(
); "admin/roles/assign",
userSilenced = await signup({ username: "userSilenced" }); { userId: userRoleBadge.id, roleId: roleBadge.id },
await post(userSilenced, { text: "test" }); root,
roleSilenced = await role( );
root, userSilenced = await signup({ username: "userSilenced" });
{}, await post(userSilenced, { text: "test" });
{ canPublicNote: { priority: 0, useDefault: false, value: false } }, roleSilenced = await role(
); root,
await api( {},
"admin/roles/assign", { canPublicNote: { priority: 0, useDefault: false, value: false } },
{ userId: userSilenced.id, roleId: roleSilenced.id }, );
root, await api(
); "admin/roles/assign",
userSuspended = await signup({ username: "userSuspended" }); { userId: userSilenced.id, roleId: roleSilenced.id },
await post(userSuspended, { text: "test" }); root,
await successfulApiCall({ );
endpoint: "i/update", userSuspended = await signup({ username: "userSuspended" });
parameters: { description: "#user_testuserSuspended" }, await post(userSuspended, { text: "test" });
user: userSuspended, await successfulApiCall({
}); endpoint: "i/update",
await api("admin/suspend-user", { userId: userSuspended.id }, root); parameters: { description: "#user_testuserSuspended" },
userDeletedBySelf = await signup({ user: userSuspended,
username: "userDeletedBySelf", });
password: "userDeletedBySelf", await api("admin/suspend-user", { userId: userSuspended.id }, root);
}); userDeletedBySelf = await signup({
await post(userDeletedBySelf, { text: "test" }); username: "userDeletedBySelf",
await api( password: "userDeletedBySelf",
"i/delete-account", });
{ password: "userDeletedBySelf" }, await post(userDeletedBySelf, { text: "test" });
userDeletedBySelf, await api(
); "i/delete-account",
userDeletedByAdmin = await signup({ username: "userDeletedByAdmin" }); { password: "userDeletedBySelf" },
await post(userDeletedByAdmin, { text: "test" }); userDeletedBySelf,
await api("admin/delete-account", { userId: userDeletedByAdmin.id }, root); );
userFollowingAlice = await signup({ username: "userFollowingAlice" }); userDeletedByAdmin = await signup({ username: "userDeletedByAdmin" });
await post(userFollowingAlice, { text: "test" }); await post(userDeletedByAdmin, { text: "test" });
await api("following/create", { userId: alice.id }, userFollowingAlice); await api(
userFollowedByAlice = await signup({ username: "userFollowedByAlice" }); "admin/delete-account",
await post(userFollowedByAlice, { text: "test" }); { userId: userDeletedByAdmin.id },
await api("following/create", { userId: userFollowedByAlice.id }, alice); root,
userBlockingAlice = await signup({ username: "userBlockingAlice" }); );
await post(userBlockingAlice, { text: "test" }); userFollowingAlice = await signup({ username: "userFollowingAlice" });
await api("blocking/create", { userId: alice.id }, userBlockingAlice); await post(userFollowingAlice, { text: "test" });
userBlockedByAlice = await signup({ username: "userBlockedByAlice" }); await api("following/create", { userId: alice.id }, userFollowingAlice);
await post(userBlockedByAlice, { text: "test" }); userFollowedByAlice = await signup({ username: "userFollowedByAlice" });
await api("blocking/create", { userId: userBlockedByAlice.id }, alice); await post(userFollowedByAlice, { text: "test" });
userMutingAlice = await signup({ username: "userMutingAlice" }); await api("following/create", { userId: userFollowedByAlice.id }, alice);
await post(userMutingAlice, { text: "test" }); userBlockingAlice = await signup({ username: "userBlockingAlice" });
await api("mute/create", { userId: alice.id }, userMutingAlice); await post(userBlockingAlice, { text: "test" });
userMutedByAlice = await signup({ username: "userMutedByAlice" }); await api("blocking/create", { userId: alice.id }, userBlockingAlice);
await post(userMutedByAlice, { text: "test" }); userBlockedByAlice = await signup({ username: "userBlockedByAlice" });
await api("mute/create", { userId: userMutedByAlice.id }, alice); await post(userBlockedByAlice, { text: "test" });
userRnMutingAlice = await signup({ username: "userRnMutingAlice" }); await api("blocking/create", { userId: userBlockedByAlice.id }, alice);
await post(userRnMutingAlice, { text: "test" }); userMutingAlice = await signup({ username: "userMutingAlice" });
await api("renote-mute/create", { userId: alice.id }, userRnMutingAlice); await post(userMutingAlice, { text: "test" });
userRnMutedByAlice = await signup({ username: "userRnMutedByAlice" }); await api("mute/create", { userId: alice.id }, userMutingAlice);
await post(userRnMutedByAlice, { text: "test" }); userMutedByAlice = await signup({ username: "userMutedByAlice" });
await api("renote-mute/create", { userId: userRnMutedByAlice.id }, alice); await post(userMutedByAlice, { text: "test" });
userFollowRequesting = await signup({ username: "userFollowRequesting" }); await api("mute/create", { userId: userMutedByAlice.id }, alice);
await post(userFollowRequesting, { text: "test" }); userRnMutingAlice = await signup({ username: "userRnMutingAlice" });
userFollowRequested = userLocking; await post(userRnMutingAlice, { text: "test" });
await api( await api("renote-mute/create", { userId: alice.id }, userRnMutingAlice);
"following/create", userRnMutedByAlice = await signup({ username: "userRnMutedByAlice" });
{ userId: userFollowRequested.id }, await post(userRnMutedByAlice, { text: "test" });
userFollowRequesting, await api("renote-mute/create", { userId: userRnMutedByAlice.id }, alice);
); userFollowRequesting = await signup({ username: "userFollowRequesting" });
}, 1000 * 60 * 10); await post(userFollowRequesting, { text: "test" });
userFollowRequested = userLocking;
await api(
"following/create",
{ userId: userFollowRequested.id },
userFollowRequesting,
);
},
1000 * 60 * 10,
);
afterAll(async () => { afterAll(async () => {
await app.close(); await app.close();

View file

@ -152,8 +152,8 @@ export const uploadFile = async (user: any, _path?: string): Promise<any> => {
_path == null _path == null
? `${_dirname}/resources/Lenna.jpg` ? `${_dirname}/resources/Lenna.jpg`
: path.isAbsolute(_path) : path.isAbsolute(_path)
? _path ? _path
: `${_dirname}/resources/${_path}`; : `${_dirname}/resources/${_path}`;
const formData = new FormData() as any; const formData = new FormData() as any;
formData.append("i", user.token); formData.append("i", user.token);

View file

@ -173,10 +173,10 @@
return c == 0 return c == 0
? Math.PI / 2 ? Math.PI / 2
: ((a = c / (this.length() * b.length())), a >= 1) : ((a = c / (this.length() * b.length())), a >= 1)
? 0 ? 0
: a <= -1 : a <= -1
? Math.PI ? Math.PI
: Math.acos(a); : Math.acos(a);
}), }),
(z.unit = function () { (z.unit = function () {
var a = this.length(); var a = this.length();
@ -332,12 +332,12 @@
D[a.substr(5, 2)])), D[a.substr(5, 2)])),
(b = I[a] + f)) (b = I[a] + f))
: a.substr(0, 4) === "rgb(" || a.substr(0, 4) === "hsl(" : a.substr(0, 4) === "rgb(" || a.substr(0, 4) === "hsl("
? (b = a.replace("(", "a(").replace(")", "," + f)) ? (b = a.replace("(", "a(").replace(")", "," + f))
: (a.substr(0, 5) === "rgba(" || a.substr(0, 5) === "hsla(") && : (a.substr(0, 5) === "rgba(" || a.substr(0, 5) === "hsla(") &&
((d = a.lastIndexOf(",") + 1), ((d = a.lastIndexOf(",") + 1),
(e = a.indexOf(")")), (e = a.indexOf(")")),
(c *= parseFloat(a.substring(d, e))), (c *= parseFloat(a.substring(d, e))),
(b = a.substr(0, d) + c.toPrecision(3) + ")")), (b = a.substr(0, d) + c.toPrecision(3) + ")")),
b b
); );
} }
@ -884,8 +884,8 @@
b.BeginDrag(c), b.BeginDrag(c),
(d = K(c, b.canvas)) && ((b.mx = d.x), (b.my = d.y), (b.drawn = 0))) (d = K(c, b.canvas)) && ((b.mx = d.x), (b.my = d.y), (b.drawn = 0)))
: c.targetTouches.length == 2 && b.pinchZoom : c.targetTouches.length == 2 && b.pinchZoom
? ((b.touchState = 3), b.EndDrag(), b.BeginPinch(c)) ? ((b.touchState = 3), b.EndDrag(), b.BeginPinch(c))
: (b.EndDrag(), b.EndPinch(), (b.touchState = 0))); : (b.EndDrag(), b.EndPinch(), (b.touchState = 0)));
} }
function ac(c) { function ac(c) {
var d = u(c), var d = u(c),
@ -1001,10 +1001,10 @@
b[a].nodeName == "BR" b[a].nodeName == "BR"
? (this.text.push(this.line.join(" ")), (this.br = 1)) ? (this.text.push(this.line.join(" ")), (this.br = 1))
: b[a].nodeType == 3 : b[a].nodeType == 3
? this.br ? this.br
? ((this.line = [b[a].nodeValue]), (this.br = 0)) ? ((this.line = [b[a].nodeValue]), (this.br = 0))
: this.line.push(b[a].nodeValue) : this.line.push(b[a].nodeValue)
: this.Lines(b[a]); : this.Lines(b[a]);
return e || this.br || this.text.push(this.line.join(" ")), this.text; return e || this.br || this.text.push(this.line.join(" ")), this.text;
}), }),
(F.SplitWidth = function (h, e, f, g) { (F.SplitWidth = function (h, e, f, g) {
@ -1262,8 +1262,8 @@
return this.a.href != a.href return this.a.href != a.href
? 0 ? 0
: b.length : b.length
? this.image.src == b[0].src ? this.image.src == b[0].src
: (a.innerText || a.textContent) == this.text_original; : (a.innerText || a.textContent) == this.text_original;
}), }),
(d.SetImage = function (a) { (d.SetImage = function (a) {
this.image = this.fimage = a; this.image = this.fimage = a;
@ -1467,17 +1467,18 @@
"colour" == d "colour" == d
? (this.colour = L(a, c, e)) ? (this.colour = L(a, c, e))
: "bgcolour" == d : "bgcolour" == d
? (this.bgColour = L(a, c, e)) ? (this.bgColour = L(a, c, e))
: "bgoutline" == d : "bgoutline" == d
? (this.bgOutline = L(a, c, e)) ? (this.bgOutline = L(a, c, e))
: "outline" == d : "outline" == d
? (this.outline.colour = L(a, c, e)) ? (this.outline.colour = L(a, c, e))
: "size" == d && : "size" == d &&
(a.weightSizeMin > 0 && a.weightSizeMax > a.weightSizeMin (a.weightSizeMin > 0 && a.weightSizeMax > a.weightSizeMin
? (this.textHeight = ? (this.textHeight =
a.weightSize * a.weightSize *
(a.weightSizeMin + (a.weightSizeMax - a.weightSizeMin) * c)) (a.weightSizeMin +
: (this.textHeight = g(1, b * a.weightSize))); (a.weightSizeMax - a.weightSizeMin) * c))
: (this.textHeight = g(1, b * a.weightSize)));
}), }),
(d.SetShadowColourFixed = function (a, b, c) { (d.SetShadowColourFixed = function (a, b, c) {
a.shadowColor = b; a.shadowColor = b;
@ -1503,8 +1504,8 @@
"right" == e.textAlign "right" == e.textAlign
? (d += this.w / 2 - this.line_widths[b]) ? (d += this.w / 2 - this.line_widths[b])
: "centre" == e.textAlign : "centre" == e.textAlign
? (d -= this.line_widths[b] / 2) ? (d -= this.line_widths[b] / 2)
: (d -= this.w / 2), : (d -= this.w / 2),
a.setTransform(c, 0, 0, c, c * d, c * f), a.setTransform(c, 0, 0, c, c * d, c * f),
a.fillText(this.text[b], 0, 0), a.fillText(this.text[b], 0, 0),
(f += this.textHeight); (f += this.textHeight);
@ -2188,8 +2189,8 @@
b && a && a.title b && a && a.title
? this.SetTTDiv(a.title, a) ? this.SetTTDiv(a.title, a)
: !b && this.mx != -1 && this.my != -1 && this.ctitle.length : !b && this.mx != -1 && this.my != -1 && this.ctitle.length
? this.SetTTDiv(this.ctitle) ? this.SetTTDiv(this.ctitle)
: (this.ttdiv.style.display = "none"); : (this.ttdiv.style.display = "none");
}), }),
(b.Transform = function (c, a, b) { (b.Transform = function (c, a, b) {
if (a || b) { if (a || b) {

View file

@ -20,7 +20,7 @@
1 - 1 -
angleDiff(hAngle, angle) / Math.PI - angleDiff(hAngle, angle) / Math.PI -
numbersOpacityFactor, numbersOpacityFactor,
) )
" "
/> />
</template> </template>
@ -49,7 +49,7 @@
1 - 1 -
angleDiff(hAngle, angle) / Math.PI - angleDiff(hAngle, angle) / Math.PI -
numbersOpacityFactor, numbersOpacityFactor,
) )
" "
> >
{{ i === 0 ? (props.twentyfour ? "24" : "12") : i }} {{ i === 0 ? (props.twentyfour ? "24" : "12") : i }}

View file

@ -330,7 +330,7 @@ const render = () => {
max: "original", max: "original",
}, },
}, },
} }
: undefined, : undefined,
// gradient, // gradient,
}, },
@ -473,7 +473,7 @@ const fetchNotesChart = async (type: string): Promise<typeof chartData> => {
negate(raw.local.dec), negate(raw.local.dec),
raw.remote.inc, raw.remote.inc,
negate(raw.remote.dec), negate(raw.remote.dec),
) )
: sum(raw[type].inc, negate(raw[type].dec)), : sum(raw[type].inc, negate(raw[type].dec)),
), ),
color: "#888888", color: "#888888",
@ -516,7 +516,7 @@ const fetchNotesChart = async (type: string): Promise<typeof chartData> => {
? sum( ? sum(
raw.local.diffs.withFile, raw.local.diffs.withFile,
raw.remote.diffs.withFile, raw.remote.diffs.withFile,
) )
: raw[type].diffs.withFile, : raw[type].diffs.withFile,
), ),
color: colors.purple, color: colors.purple,
@ -569,7 +569,7 @@ const fetchUsersChart = async (total: boolean): Promise<typeof chartData> => {
negate(raw.local.dec), negate(raw.local.dec),
raw.remote.inc, raw.remote.inc,
negate(raw.remote.dec), negate(raw.remote.dec),
), ),
), ),
}, },
{ {
@ -926,7 +926,7 @@ const fetchPerUserNotesChart = async (): Promise<typeof chartData> => {
data: format(sum(raw.inc, negate(raw.dec))), data: format(sum(raw.inc, negate(raw.dec))),
color: "#888888", color: "#888888",
}, },
]), ]),
{ {
name: "With file", name: "With file",
type: "area", type: "area",

View file

@ -12,7 +12,7 @@
? `/my/messaging/group/${message.groupId}` ? `/my/messaging/group/${message.groupId}`
: `/my/messaging/${getAcct( : `/my/messaging/${getAcct(
isMe(message) ? message.recipient : message.user, isMe(message) ? message.recipient : message.user,
)}` )}`
" "
> >
<div class="message _block"> <div class="message _block">
@ -22,8 +22,8 @@
message.groupId message.groupId
? message.user ? message.user
: isMe(message) : isMe(message)
? message.recipient ? message.recipient
: message.user : message.user
" "
:show-indicator="true" :show-indicator="true"
disable-link disable-link

View file

@ -117,10 +117,10 @@ export default defineComponent({
tag: "div", tag: "div",
"data-direction": props.direction, "data-direction": props.direction,
"data-reversed": props.reversed ? "true" : "false", "data-reversed": props.reversed ? "true" : "false",
} }
: { : {
class: "sqadhkmv" + (props.noGap ? " noGap" : ""), class: "sqadhkmv" + (props.noGap ? " noGap" : ""),
}, },
{ default: renderChildren }, { default: renderChildren },
); );
}, },

View file

@ -327,8 +327,8 @@ async function ok() {
const result = props.input const result = props.input
? inputValue.value ? inputValue.value
: props.select : props.select
? selectedValue.value ? selectedValue.value
: true; : true;
done(false, result); done(false, result);
} }

View file

@ -710,7 +710,7 @@ function getMenu() {
action: () => { action: () => {
renameFolder(folder.value); renameFolder(folder.value);
}, },
} }
: undefined, : undefined,
folder.value folder.value
? { ? {
@ -721,7 +721,7 @@ function getMenu() {
folder.value as firefish.entities.DriveFolder, folder.value as firefish.entities.DriveFolder,
); );
}, },
} }
: undefined, : undefined,
{ {
text: i18n.ts.createFolder, text: i18n.ts.createFolder,

View file

@ -17,8 +17,8 @@
? i18n.ts.selectFiles ? i18n.ts.selectFiles
: i18n.ts.selectFolders : i18n.ts.selectFolders
: type === "file" : type === "file"
? i18n.ts.selectFile ? i18n.ts.selectFile
: i18n.ts.selectFolder : i18n.ts.selectFolder
}} }}
<span <span
v-if="selected.length > 0" v-if="selected.length > 0"

View file

@ -25,7 +25,7 @@
props.skinToneLabels props.skinToneLabels
? props.skinToneLabels[ ? props.skinToneLabels[
props.skinTones.indexOf(skinTone) props.skinTones.indexOf(skinTone)
] ]
: '' : ''
" "
></i> ></i>

View file

@ -60,7 +60,7 @@ export default defineComponent({
localStorage.getItem(localStoragePrefix + this.persistKey) localStorage.getItem(localStoragePrefix + this.persistKey)
? localStorage.getItem( ? localStorage.getItem(
localStoragePrefix + this.persistKey, localStoragePrefix + this.persistKey,
) === "t" ) === "t"
: this.expanded, : this.expanded,
animation: defaultStore.state.animation, animation: defaultStore.state.animation,
}; };

View file

@ -88,8 +88,8 @@ const preferedModalType =
deviceKind === "desktop" && props.src != null deviceKind === "desktop" && props.src != null
? "popup" ? "popup"
: deviceKind === "smartphone" : deviceKind === "smartphone"
? "drawer" ? "drawer"
: "dialog"; : "dialog";
const modal = ref<InstanceType<typeof MkModal>>(); const modal = ref<InstanceType<typeof MkModal>>();

View file

@ -113,9 +113,9 @@ const url =
props.raw || defaultStore.state.loadRawImages props.raw || defaultStore.state.loadRawImages
? props.media.url ? props.media.url
: defaultStore.state.disableShowingAnimatedImages && : defaultStore.state.disableShowingAnimatedImages &&
props.media.type.startsWith("image") props.media.type.startsWith("image")
? getStaticImageUrl(props.media.thumbnailUrl) ? getStaticImageUrl(props.media.thumbnailUrl)
: props.media.thumbnailUrl; : props.media.thumbnailUrl;
const mediaType = computed(() => { const mediaType = computed(() => {
return props.media.type === "video/quicktime" return props.media.type === "video/quicktime"
@ -151,7 +151,7 @@ watch(
defaultStore.state.nsfw === "force" defaultStore.state.nsfw === "force"
? true ? true
: props.media.isSensitive && : props.media.isSensitive &&
defaultStore.state.nsfw !== "ignore"; defaultStore.state.nsfw !== "ignore";
}, },
{ {
deep: true, deep: true,

View file

@ -100,13 +100,13 @@ onMounted(() => {
bottom: 32, bottom: 32,
left: 32, left: 32,
right: 32, right: 32,
} }
: { : {
top: 0, top: 0,
bottom: 0, bottom: 0,
left: 0, left: 0,
right: 0, right: 0,
}, },
imageClickAction: "close", imageClickAction: "close",
tapAction: "toggle-controls", tapAction: "toggle-controls",
preloadFirstSlide: false, preloadFirstSlide: false,

View file

@ -169,22 +169,22 @@ const transitionName = computed(() =>
? useSendAnime.value ? useSendAnime.value
? "send" ? "send"
: type.value === "drawer" : type.value === "drawer"
? "modal-drawer" ? "modal-drawer"
: type.value === "popup" : type.value === "popup"
? "modal-popup" ? "modal-popup"
: "modal" : "modal"
: "", : "",
); );
const transitionDuration = computed(() => const transitionDuration = computed(() =>
transitionName.value === "send" transitionName.value === "send"
? 400 ? 400
: transitionName.value === "modal-popup" : transitionName.value === "modal-popup"
? 100 ? 100
: transitionName.value === "modal" : transitionName.value === "modal"
? 200 ? 200
: transitionName.value === "modal-drawer" : transitionName.value === "modal-drawer"
? 200 ? 200
: 0, : 0,
); );
let contentClicking = false; let contentClicking = false;

View file

@ -17,8 +17,8 @@
? `${props.height}px` ? `${props.height}px`
: null : null
: height : height
? `min(${props.height}px, 100%)` ? `min(${props.height}px, 100%)`
: '100%', : '100%',
}" }"
tabindex="-1" tabindex="-1"
> >

View file

@ -510,7 +510,7 @@ function onContextmenu(ev: MouseEvent): void {
"forcePage", "forcePage",
); );
}, },
} }
: undefined, : undefined,
null, null,
{ {
@ -537,7 +537,7 @@ function onContextmenu(ev: MouseEvent): void {
appearNote.value.uri ?? appearNote.value.uri ??
"", "",
target: "_blank", target: "_blank",
} }
: undefined, : undefined,
], ],
ev, ev,

View file

@ -428,7 +428,7 @@ function onContextmenu(ev: MouseEvent): void {
"forcePage", "forcePage",
); );
}, },
} }
: undefined, : undefined,
null, null,
{ {
@ -452,7 +452,7 @@ function onContextmenu(ev: MouseEvent): void {
text: i18n.ts.showOnRemote, text: i18n.ts.showOnRemote,
href: note.value.url ?? note.value.uri ?? "", href: note.value.url ?? note.value.uri ?? "",
target: "_blank", target: "_blank",
} }
: undefined, : undefined,
], ],
ev, ev,

View file

@ -74,7 +74,7 @@
? notification.reaction.replace( ? notification.reaction.replace(
/^:(\w+):$/, /^:(\w+):$/,
':$1@.:', ':$1@.:',
) )
: notification.reaction : notification.reaction
" "
:custom-emojis="notification.note.emojis" :custom-emojis="notification.note.emojis"

View file

@ -257,14 +257,14 @@ const fetchMore = async (): Promise<void> => {
...(props.pagination.offsetMode ...(props.pagination.offsetMode
? { ? {
offset: offset.value, offset: offset.value,
} }
: props.pagination.reversed : props.pagination.reversed
? { ? {
sinceId: items.value[0].id, sinceId: items.value[0].id,
} }
: { : {
untilId: items.value[items.value.length - 1].id, untilId: items.value[items.value.length - 1].id,
}), }),
}) })
.then( .then(
(res) => { (res) => {
@ -318,14 +318,14 @@ const fetchMoreAhead = async (): Promise<void> => {
...(props.pagination.offsetMode ...(props.pagination.offsetMode
? { ? {
offset: offset.value, offset: offset.value,
} }
: props.pagination.reversed : props.pagination.reversed
? { ? {
untilId: items.value[0].id, untilId: items.value[0].id,
} }
: { : {
sinceId: items.value[items.value.length - 1].id, sinceId: items.value[items.value.length - 1].id,
}), }),
}) })
.then( .then(
(res) => { (res) => {

View file

@ -81,10 +81,10 @@ const timer = computed(() =>
remaining.value >= 86400 remaining.value >= 86400
? "_poll.remainingDays" ? "_poll.remainingDays"
: remaining.value >= 3600 : remaining.value >= 3600
? "_poll.remainingHours" ? "_poll.remainingHours"
: remaining.value >= 60 : remaining.value >= 60
? "_poll.remainingMinutes" ? "_poll.remainingMinutes"
: "_poll.remainingSeconds", : "_poll.remainingSeconds",
{ {
s: Math.floor(remaining.value % 60), s: Math.floor(remaining.value % 60),
m: Math.floor(remaining.value / 60) % 60, m: Math.floor(remaining.value / 60) % 60,

View file

@ -171,8 +171,8 @@ function get() {
...(expiration.value === "at" ...(expiration.value === "at"
? { expiresAt: calcAt() } ? { expiresAt: calcAt() }
: expiration.value === "after" : expiration.value === "after"
? { expiredAfter: calcAfter() } ? { expiredAfter: calcAfter() }
: {}), : {}),
}; };
} }

View file

@ -87,8 +87,8 @@
reply reply
? 'ph-arrow-u-up-left' ? 'ph-arrow-u-up-left'
: renote : renote
? 'ph-quotes' ? 'ph-quotes'
: 'ph-paper-plane-tilt', : 'ph-paper-plane-tilt',
) )
" "
></i> ></i>
@ -421,10 +421,10 @@ const submitText = computed((): string => {
return props.editId return props.editId
? i18n.ts.edit ? i18n.ts.edit
: props.renote : props.renote
? i18n.ts.quote ? i18n.ts.quote
: props.reply : props.reply
? i18n.ts.reply ? i18n.ts.reply
: i18n.ts.note; : i18n.ts.note;
}); });
const textLength = computed((): number => { const textLength = computed((): number => {
@ -493,8 +493,8 @@ if (props.reply && props.reply.text != null) {
const mention = x.host const mention = x.host
? `@${x.username}@${toASCII(x.host)}` ? `@${x.username}@${toASCII(x.host)}`
: otherHost == null || otherHost === host : otherHost == null || otherHost === host
? `@${x.username}` ? `@${x.username}`
: `@${x.username}@${toASCII(otherHost)}`; : `@${x.username}@${toASCII(otherHost)}`;
// exclude me // exclude me
if ($i.username === x.username && (x.host == null || x.host === host)) if ($i.username === x.username && (x.host == null || x.host === host))
@ -987,8 +987,8 @@ async function post() {
renoteId: props.renote renoteId: props.renote
? props.renote.id ? props.renote.id
: quoteId.value : quoteId.value
? quoteId.value ? quoteId.value
: undefined, : undefined,
channelId: props.channel ? props.channel.id : undefined, channelId: props.channel ? props.channel.id : undefined,
poll: poll.value, poll: poll.value,
cw: useCw.value ? cw.value || "" : undefined, cw: useCw.value ? cw.value || "" : undefined,
@ -1023,8 +1023,9 @@ async function post() {
if (postAccount.value) { if (postAccount.value) {
const storedAccounts = await getAccounts(); const storedAccounts = await getAccounts();
token = storedAccounts.find((x) => x.id === postAccount.value.id) token = storedAccounts.find(
?.token; (x) => x.id === postAccount.value.id,
)?.token;
} }
posting.value = true; posting.value = true;

View file

@ -211,12 +211,12 @@ const renote = (viaKeyboard = false, ev?: MouseEvent) => {
visibility: props.note.visibility, visibility: props.note.visibility,
visibleUserIds: props.note.visibleUserIds, visibleUserIds: props.note.visibleUserIds,
localOnly: true, localOnly: true,
} }
: { : {
renoteId: props.note.id, renoteId: props.note.id,
visibility: props.note.visibility, visibility: props.note.visibility,
localOnly: true, localOnly: true,
}, },
); );
hasRenotedBefore.value = true; hasRenotedBefore.value = true;
const el = const el =

View file

@ -371,10 +371,10 @@ function onChangeUsername(): void {
const err = !username.value.match(/^[a-zA-Z0-9_]+$/) const err = !username.value.match(/^[a-zA-Z0-9_]+$/)
? "invalid-format" ? "invalid-format"
: username.value.length < 1 : username.value.length < 1
? "min-range" ? "min-range"
: username.value.length > 20 : username.value.length > 20
? "max-range" ? "max-range"
: null; : null;
if (err) { if (err) {
usernameState.value = err; usernameState.value = err;
@ -410,16 +410,16 @@ function onChangeEmail(): void {
emailState.value = result.available emailState.value = result.available
? "ok" ? "ok"
: result.reason === "used" : result.reason === "used"
? "unavailable:used" ? "unavailable:used"
: result.reason === "format" : result.reason === "format"
? "unavailable:format" ? "unavailable:format"
: result.reason === "disposable" : result.reason === "disposable"
? "unavailable:disposable" ? "unavailable:disposable"
: result.reason === "mx" : result.reason === "mx"
? "unavailable:mx" ? "unavailable:mx"
: result.reason === "smtp" : result.reason === "smtp"
? "unavailable:smtp" ? "unavailable:smtp"
: "unavailable"; : "unavailable";
}) })
.catch(() => { .catch(() => {
emailState.value = "error"; emailState.value = "error";

View file

@ -45,7 +45,7 @@ export default defineComponent({
}, },
[label], [label],
), ),
] ]
: []), : []),
h( h(
"div", "div",
@ -76,7 +76,7 @@ export default defineComponent({
}, },
[caption], [caption],
), ),
] ]
: []), : []),
], ],
); );

View file

@ -70,7 +70,7 @@ const choseAd = (): Ad | null => {
? { ? {
...ad, ...ad,
ratio: 0, ratio: 0,
} }
: ad, : ad,
); );

View file

@ -139,13 +139,13 @@ onMounted(() => {
bottom: 32, bottom: 32,
left: 32, left: 32,
right: 32, right: 32,
} }
: { : {
top: 0, top: 0,
bottom: 0, bottom: 0,
left: 0, left: 0,
right: 0, right: 0,
}, },
imageClickAction: "close", imageClickAction: "close",
tapAction: "toggle-controls", tapAction: "toggle-controls",
preloadFirstSlide: false, preloadFirstSlide: false,

View file

@ -46,7 +46,7 @@ const customEmoji = computed(() =>
isCustom.value isCustom.value
? ce.value.find( ? ce.value.find(
(x) => x.name === props.emoji.substr(1, props.emoji.length - 2), (x) => x.name === props.emoji.substr(1, props.emoji.length - 2),
) )
: null, : null,
); );
const url = computed(() => { const url = computed(() => {

View file

@ -29,11 +29,11 @@ const _time =
props.time == null props.time == null
? NaN ? NaN
: typeof props.time === "number" : typeof props.time === "number"
? props.time ? props.time
: (props.time instanceof Date : (props.time instanceof Date
? props.time ? props.time
: new Date(props.time) : new Date(props.time)
).getTime(); ).getTime();
const invalid = Number.isNaN(_time); const invalid = Number.isNaN(_time);
const absolute = !invalid ? dateTimeFormat.format(_time) : i18n.ts._ago.invalid; const absolute = !invalid ? dateTimeFormat.format(_time) : i18n.ts._ago.invalid;
@ -46,30 +46,32 @@ const relative = computed<string>(() => {
return ago >= 31536000 return ago >= 31536000
? i18n.t("_ago.yearsAgo", { n: Math.floor(ago / 31536000).toString() }) ? i18n.t("_ago.yearsAgo", { n: Math.floor(ago / 31536000).toString() })
: ago >= 2592000 : ago >= 2592000
? i18n.t("_ago.monthsAgo", { ? i18n.t("_ago.monthsAgo", {
n: Math.floor(ago / 2592000).toString(), n: Math.floor(ago / 2592000).toString(),
}) })
: ago >= 604800 : ago >= 604800
? i18n.t("_ago.weeksAgo", { ? i18n.t("_ago.weeksAgo", {
n: Math.floor(ago / 604800).toString(), n: Math.floor(ago / 604800).toString(),
}) })
: ago >= 86400 : ago >= 86400
? i18n.t("_ago.daysAgo", { ? i18n.t("_ago.daysAgo", {
n: Math.floor(ago / 86400).toString(), n: Math.floor(ago / 86400).toString(),
}) })
: ago >= 3600 : ago >= 3600
? i18n.t("_ago.hoursAgo", { ? i18n.t("_ago.hoursAgo", {
n: Math.floor(ago / 3600).toString(), n: Math.floor(ago / 3600).toString(),
}) })
: ago >= 60 : ago >= 60
? i18n.t("_ago.minutesAgo", { n: (~~(ago / 60)).toString() }) ? i18n.t("_ago.minutesAgo", {
: ago >= 10 n: (~~(ago / 60)).toString(),
? i18n.t("_ago.secondsAgo", { })
: ago >= 10
? i18n.t("_ago.secondsAgo", {
n: (~~(ago % 60)).toString(), n: (~~(ago % 60)).toString(),
}) })
: ago >= -1 : ago >= -1
? i18n.ts._ago.justNow ? i18n.ts._ago.justNow
: i18n.ts._ago.future; : i18n.ts._ago.future;
}); });
let tickId: number; let tickId: number;

View file

@ -145,13 +145,13 @@ export default defineComponent({
const direction = token.props.args.left const direction = token.props.args.left
? "reverse" ? "reverse"
: token.props.args.alternate : token.props.args.alternate
? "alternate" ? "alternate"
: "normal"; : "normal";
const anime = token.props.args.x const anime = token.props.args.x
? "mfm-spinX" ? "mfm-spinX"
: token.props.args.y : token.props.args.y
? "mfm-spinY" ? "mfm-spinY"
: "mfm-spin"; : "mfm-spin";
const speed = validTime(token.props.args.speed) || "1.5s"; const speed = validTime(token.props.args.speed) || "1.5s";
const delay = validTime(token.props.args.delay) || "0s"; const delay = validTime(token.props.args.delay) || "0s";
const loop = validNumber(token.props.args.loop) || "infinite"; const loop = validNumber(token.props.args.loop) || "infinite";
@ -200,8 +200,8 @@ export default defineComponent({
token.props.args.h && token.props.args.v token.props.args.h && token.props.args.v
? "scale(-1, -1)" ? "scale(-1, -1)"
: token.props.args.v : token.props.args.v
? "scaleY(-1)" ? "scaleY(-1)"
: "scaleX(-1)"; : "scaleX(-1)";
style = `transform: ${transform};`; style = `transform: ${transform};`;
break; break;
} }
@ -236,16 +236,16 @@ export default defineComponent({
const family = token.props.args.serif const family = token.props.args.serif
? "serif" ? "serif"
: token.props.args.monospace : token.props.args.monospace
? "monospace" ? "monospace"
: token.props.args.cursive : token.props.args.cursive
? "cursive" ? "cursive"
: token.props.args.fantasy : token.props.args.fantasy
? "fantasy" ? "fantasy"
: token.props.args.emoji : token.props.args.emoji
? "emoji" ? "emoji"
: token.props.args.math : token.props.args.math
? "math" ? "math"
: null; : null;
if (family) style = `font-family: ${family};`; if (family) style = `font-family: ${family};`;
break; break;
} }
@ -262,8 +262,8 @@ export default defineComponent({
const rotate = token.props.args.x const rotate = token.props.args.x
? "perspective(128px) rotateX" ? "perspective(128px) rotateX"
: token.props.args.y : token.props.args.y
? "perspective(128px) rotateY" ? "perspective(128px) rotateY"
: "rotate"; : "rotate";
const degrees = parseFloat(token.props.args.deg ?? "90"); const degrees = parseFloat(token.props.args.deg ?? "90");
style = `transform: ${rotate}(${degrees}deg); transform-origin: center center;`; style = `transform: ${rotate}(${degrees}deg); transform-origin: center center;`;
break; break;

View file

@ -45,7 +45,7 @@ export default defineComponent({
...(this.block.var ...(this.block.var
? { ? {
var: unref(this.hpml.vars)[this.block.var], var: unref(this.hpml.vars)[this.block.var],
} }
: {}), : {}),
}); });

View file

@ -63,12 +63,12 @@ export default {
direction: binding.modifiers.left direction: binding.modifiers.left
? "left" ? "left"
: binding.modifiers.right : binding.modifiers.right
? "right" ? "right"
: binding.modifiers.top : binding.modifiers.top
? "top" ? "top"
: binding.modifiers.bottom : binding.modifiers.bottom
? "bottom" ? "bottom"
: "top", : "top",
targetElement: el, targetElement: el,
}, },
{}, {},

View file

@ -7,7 +7,7 @@ export const i18n = markRaw(new I18n(locale));
// このファイルに書きたくないけどここに書かないと何故かVeturが認識しない // このファイルに書きたくないけどここに書かないと何故かVeturが認識しない
declare module "@vue/runtime-core" { declare module "@vue/runtime-core" {
interface ComponentCustomProperties { interface ComponentCustomProperties {
$t: typeof i18n["t"]; $t: (typeof i18n)["t"];
$ts: typeof i18n["locale"]; $ts: (typeof i18n)["locale"];
} }
} }

View file

@ -193,10 +193,10 @@ function checkForSplash() {
window.location.search === "?zen" window.location.search === "?zen"
? defineAsyncComponent(() => import("@/ui/zen.vue")) ? defineAsyncComponent(() => import("@/ui/zen.vue"))
: !$i : !$i
? defineAsyncComponent(() => import("@/ui/visitor.vue")) ? defineAsyncComponent(() => import("@/ui/visitor.vue"))
: ui === "deck" : ui === "deck"
? defineAsyncComponent(() => import("@/ui/deck.vue")) ? defineAsyncComponent(() => import("@/ui/deck.vue"))
: defineAsyncComponent(() => import("@/ui/universal.vue")), : defineAsyncComponent(() => import("@/ui/universal.vue")),
); );
if (_DEV_) { if (_DEV_) {

View file

@ -774,8 +774,8 @@ export async function cropImage(
type AwaitType<T> = T extends Promise<infer U> type AwaitType<T> = T extends Promise<infer U>
? U ? U
: T extends (...args: any[]) => Promise<infer V> : T extends (...args: any[]) => Promise<infer V>
? V ? V
: T; : T;
let openingEmojiPicker: AwaitType<ReturnType<typeof popup>> | null = null, let openingEmojiPicker: AwaitType<ReturnType<typeof popup>> | null = null,
activeTextarea: HTMLTextAreaElement | HTMLInputElement | null = null; activeTextarea: HTMLTextAreaElement | HTMLInputElement | null = null;
export async function openEmojiPicker( export async function openEmojiPicker(

View file

@ -127,18 +127,18 @@ const pagination = {
...(state.value === "federating" ...(state.value === "federating"
? { federating: true } ? { federating: true }
: state.value === "subscribing" : state.value === "subscribing"
? { subscribing: true } ? { subscribing: true }
: state.value === "publishing" : state.value === "publishing"
? { publishing: true } ? { publishing: true }
: state.value === "suspended" : state.value === "suspended"
? { suspended: true } ? { suspended: true }
: state.value === "blocked" : state.value === "blocked"
? { blocked: true } ? { blocked: true }
: state.value === "silenced" : state.value === "silenced"
? { silenced: true } ? { silenced: true }
: state.value === "notResponding" : state.value === "notResponding"
? { notResponding: true } ? { notResponding: true }
: {}), : {}),
})), })),
}; };

View file

@ -243,7 +243,7 @@ const headerTabs = computed(() => [
key: "ip", key: "ip",
title: "IP", title: "IP",
icon: `${icon("ph-receipt")}`, icon: `${icon("ph-receipt")}`,
} }
: null, : null,
{ {
key: "raw", key: "raw",

View file

@ -150,7 +150,7 @@ const calcBg = () => {
rawBg.startsWith("var(") rawBg.startsWith("var(")
? getComputedStyle(document.documentElement).getPropertyValue( ? getComputedStyle(document.documentElement).getPropertyValue(
rawBg.slice(4, -1), rawBg.slice(4, -1),
) )
: rawBg, : rawBg,
); );
tinyBg.setAlpha(0.85); tinyBg.setAlpha(0.85);

View file

@ -105,8 +105,8 @@ async function init() {
provider.value = meta.enableHcaptcha provider.value = meta.enableHcaptcha
? "hcaptcha" ? "hcaptcha"
: meta.enableRecaptcha : meta.enableRecaptcha
? "recaptcha" ? "recaptcha"
: null; : null;
} }
function save() { function save() {

View file

@ -154,7 +154,7 @@ const menuDef = computed(() => [
text: i18n.ts.invite, text: i18n.ts.invite,
action: invite, action: invite,
}, },
] ]
: []), : []),
...($i.isAdmin ...($i.isAdmin
? [ ? [
@ -164,7 +164,7 @@ const menuDef = computed(() => [
text: i18n.ts.indexPosts, text: i18n.ts.indexPosts,
action: indexPosts, action: indexPosts,
}, },
] ]
: []), : []),
], ],
}, },
@ -307,7 +307,7 @@ const menuDef = computed(() => [
}, },
], ],
}, },
] ]
: []), : []),
]); ]);

View file

@ -51,23 +51,23 @@ const label =
props.type === "process" props.type === "process"
? "Process" ? "Process"
: props.type === "active" : props.type === "active"
? "Active" ? "Active"
: props.type === "delayed" : props.type === "delayed"
? "Delayed" ? "Delayed"
: props.type === "waiting" : props.type === "waiting"
? "Waiting" ? "Waiting"
: ("?" as never); : ("?" as never);
const color = const color =
props.type === "process" props.type === "process"
? "#c4a7e7" ? "#c4a7e7"
: props.type === "active" : props.type === "active"
? "#31748f" ? "#31748f"
: props.type === "delayed" : props.type === "delayed"
? "#eb6f92" ? "#eb6f92"
: props.type === "waiting" : props.type === "waiting"
? "#f6c177" ? "#f6c177"
: ("?" as never); : ("?" as never);
onMounted(() => { onMounted(() => {
const vLineColor = defaultStore.state.darkMode const vLineColor = defaultStore.state.darkMode

View file

@ -96,23 +96,23 @@ const label =
props.type === "process" props.type === "process"
? "Process" ? "Process"
: props.type === "active" : props.type === "active"
? "Active" ? "Active"
: props.type === "delayed" : props.type === "delayed"
? "Delayed" ? "Delayed"
: props.type === "waiting" : props.type === "waiting"
? "Waiting" ? "Waiting"
: ("?" as never); : ("?" as never);
const color = const color =
props.type === "process" props.type === "process"
? "#9ccfd8" ? "#9ccfd8"
: props.type === "active" : props.type === "active"
? "#31748f" ? "#31748f"
: props.type === "delayed" : props.type === "delayed"
? "#eb6f92" ? "#eb6f92"
: props.type === "waiting" : props.type === "waiting"
? "#f6c177" ? "#f6c177"
: ("?" as never); : ("?" as never);
onMounted(() => { onMounted(() => {
chartInstance = new Chart(chartEl.value, { chartInstance = new Chart(chartEl.value, {

View file

@ -117,8 +117,8 @@ onMounted(() => {
props.domain === "inbox" props.domain === "inbox"
? "admin/queue/inbox-delayed" ? "admin/queue/inbox-delayed"
: props.domain === "deliver" : props.domain === "deliver"
? "admin/queue/deliver-delayed" ? "admin/queue/deliver-delayed"
: null, : null,
{}, {},
).then((result) => { ).then((result) => {
jobs.value = result; jobs.value = result;

View file

@ -290,14 +290,14 @@ async function init() {
meta.sensitiveMediaDetectionSensitivity === "veryLow" meta.sensitiveMediaDetectionSensitivity === "veryLow"
? 0 ? 0
: meta.sensitiveMediaDetectionSensitivity === "low" : meta.sensitiveMediaDetectionSensitivity === "low"
? 1 ? 1
: meta.sensitiveMediaDetectionSensitivity === "medium" : meta.sensitiveMediaDetectionSensitivity === "medium"
? 2 ? 2
: meta.sensitiveMediaDetectionSensitivity === "high" : meta.sensitiveMediaDetectionSensitivity === "high"
? 3 ? 3
: meta.sensitiveMediaDetectionSensitivity === "veryHigh" : meta.sensitiveMediaDetectionSensitivity === "veryHigh"
? 4 ? 4
: 0; : 0;
setSensitiveFlagAutomatically.value = meta.setSensitiveFlagAutomatically; setSensitiveFlagAutomatically.value = meta.setSensitiveFlagAutomatically;
enableSensitiveMediaDetectionForVideos.value = enableSensitiveMediaDetectionForVideos.value =
meta.enableSensitiveMediaDetectionForVideos; meta.enableSensitiveMediaDetectionForVideos;
@ -317,14 +317,14 @@ function save() {
sensitiveMediaDetectionSensitivity.value === 0 sensitiveMediaDetectionSensitivity.value === 0
? "veryLow" ? "veryLow"
: sensitiveMediaDetectionSensitivity.value === 1 : sensitiveMediaDetectionSensitivity.value === 1
? "low" ? "low"
: sensitiveMediaDetectionSensitivity.value === 2 : sensitiveMediaDetectionSensitivity.value === 2
? "medium" ? "medium"
: sensitiveMediaDetectionSensitivity.value === 3 : sensitiveMediaDetectionSensitivity.value === 3
? "high" ? "high"
: sensitiveMediaDetectionSensitivity.value === 4 : sensitiveMediaDetectionSensitivity.value === 4
? "veryHigh" ? "veryHigh"
: 0, : 0,
setSensitiveFlagAutomatically: setSensitiveFlagAutomatically.value, setSensitiveFlagAutomatically: setSensitiveFlagAutomatically.value,
enableSensitiveMediaDetectionForVideos: enableSensitiveMediaDetectionForVideos:
enableSensitiveMediaDetectionForVideos.value, enableSensitiveMediaDetectionForVideos.value,

View file

@ -107,7 +107,7 @@
user.updatedAt user.updatedAt
? `Last posted: ${new Date( ? `Last posted: ${new Date(
user.updatedAt, user.updatedAt,
).toLocaleString()}` ).toLocaleString()}`
: 'Never posted' : 'Never posted'
" "
class="user" class="user"

View file

@ -83,7 +83,7 @@ const headerActions = computed(() =>
text: i18n.ts.settings, text: i18n.ts.settings,
handler: settings, handler: settings,
}, },
] ]
: [], : [],
); );
@ -95,7 +95,7 @@ definePageMetadata(
? { ? {
title: antenna.value.name, title: antenna.value.name,
icon: `${icon("ph-flying-saucer")}`, icon: `${icon("ph-flying-saucer")}`,
} }
: null, : null,
), ),
); );

View file

@ -98,14 +98,14 @@ function onEndpointChange() {
p.type === "String" p.type === "String"
? "" ? ""
: p.type === "Number" : p.type === "Number"
? 0 ? 0
: p.type === "Boolean" : p.type === "Boolean"
? false ? false
: p.type === "Array" : p.type === "Array"
? [] ? []
: p.type === "Object" : p.type === "Object"
? {} ? {}
: null; : null;
} }
body.value = JSON5.stringify(endpointBody, null, 2); body.value = JSON5.stringify(endpointBody, null, 2);
}); });

View file

@ -133,11 +133,11 @@ definePageMetadata(
? { ? {
title: i18n.ts._channel.edit, title: i18n.ts._channel.edit,
icon: `${icon("ph-television")}`, icon: `${icon("ph-television")}`,
} }
: { : {
title: i18n.ts._channel.create, title: i18n.ts._channel.create,
icon: `${icon("ph-television")}`, icon: `${icon("ph-television")}`,
}, },
), ),
); );
</script> </script>

View file

@ -139,7 +139,7 @@ const headerActions = computed(() => [
text: i18n.ts.edit, text: i18n.ts.edit,
handler: edit, handler: edit,
}, },
] ]
: []), : []),
]); ]);
@ -151,7 +151,7 @@ definePageMetadata(
? { ? {
title: channel.value.name, title: channel.value.name,
icon: `${icon("ph-television")}`, icon: `${icon("ph-television")}`,
} }
: null, : null,
), ),
); );

View file

@ -123,7 +123,7 @@ const headerActions = computed(() =>
}); });
}, },
}, },
] ]
: null, : null,
); );
@ -133,7 +133,7 @@ definePageMetadata(
? { ? {
title: clip.value.name, title: clip.value.name,
icon: `${icon("ph-paperclip")}`, icon: `${icon("ph-paperclip")}`,
} }
: null, : null,
), ),
); );

View file

@ -161,11 +161,11 @@ definePageMetadata(
? { ? {
title: i18n.ts.edit, title: i18n.ts.edit,
icon: `${icon("ph-pencil")}`, icon: `${icon("ph-pencil")}`,
} }
: { : {
title: i18n.ts.postToGallery, title: i18n.ts.postToGallery,
icon: `${icon("ph-pencil")}`, icon: `${icon("ph-pencil")}`,
}, },
), ),
); );
</script> </script>

View file

@ -241,7 +241,7 @@ definePageMetadata(
? { ? {
title: post.value.title, title: post.value.title,
avatar: post.value.user, avatar: post.value.user,
} }
: null, : null,
), ),
); );

View file

@ -156,7 +156,7 @@ definePageMetadata(
? { ? {
title: list.value.name, title: list.value.name,
icon: `${icon("ph-list-bullets")}`, icon: `${icon("ph-list-bullets")}`,
} }
: null, : null,
), ),
); );

View file

@ -102,7 +102,7 @@ const prevPagination = {
? { ? {
userId: appearNote.value.userId, userId: appearNote.value.userId,
untilId: appearNote.value.id, untilId: appearNote.value.id,
} }
: null, : null,
), ),
}; };
@ -116,7 +116,7 @@ const nextPagination = {
? { ? {
userId: appearNote.value.userId, userId: appearNote.value.userId,
sinceId: appearNote.value.id, sinceId: appearNote.value.id,
} }
: null, : null,
), ),
}; };
@ -192,7 +192,7 @@ definePageMetadata(
}), }),
text: appearNote.value.text, text: appearNote.value.text,
}, },
} }
: null, : null,
), ),
); );

View file

@ -115,7 +115,7 @@ function setFilter(ev) {
}, },
null, null,
...typeItems, ...typeItems,
] ]
: typeItems; : typeItems;
os.popupMenu(items, ev.currentTarget ?? ev.target); os.popupMenu(items, ev.currentTarget ?? ev.target);
} }
@ -128,7 +128,7 @@ const headerActions = computed(() =>
icon: `${icon("ph-funnel")}`, icon: `${icon("ph-funnel")}`,
highlighted: includeTypes.value != null, highlighted: includeTypes.value != null,
handler: setFilter, handler: setFilter,
} }
: undefined, : undefined,
tab.value === "all" tab.value === "all"
? { ? {
@ -137,7 +137,7 @@ const headerActions = computed(() =>
handler: () => { handler: () => {
os.apiWithDialog("notifications/mark-all-as-read"); os.apiWithDialog("notifications/mark-all-as-read");
}, },
} }
: undefined, : undefined,
].filter((x) => x !== undefined), ].filter((x) => x !== undefined),
); );

View file

@ -319,7 +319,7 @@ definePageMetadata(
title: page.value.title || page.value.name, title: page.value.title || page.value.name,
text: page.value.summary, text: page.value.summary,
}, },
} }
: null, : null,
), ),
); );

View file

@ -151,7 +151,7 @@ async function install() {
}, },
"closed", "closed",
); );
}); });
installPlugin({ installPlugin({
id: uuid(), id: uuid(),

View file

@ -92,7 +92,7 @@ async function init() {
? { ? {
username: q.username, username: q.username,
host: q.host === null ? undefined : q.host, host: q.host === null ? undefined : q.host,
} }
: q, : q,
) )
.map((q) => .map((q) =>

View file

@ -90,8 +90,8 @@
color: color.forPreview color: color.forPreview
? color.forPreview ? color.forPreview
: theme.base === 'light' : theme.base === 'light'
? '#5f5f5f' ? '#5f5f5f'
: '#dadada', : '#dadada',
}" }"
> >
A A

View file

@ -233,7 +233,7 @@ const headerTabs = computed(() => [
icon: `${icon("ph-users")}`, icon: `${icon("ph-users")}`,
iconOnly: true, iconOnly: true,
}, },
] ]
: []), : []),
...(isLocalTimelineAvailable ...(isLocalTimelineAvailable
? [ ? [
@ -243,7 +243,7 @@ const headerTabs = computed(() => [
icon: `${icon("ph-handshake")}`, icon: `${icon("ph-handshake")}`,
iconOnly: true, iconOnly: true,
}, },
] ]
: []), : []),
...(isRecommendedTimelineAvailable ...(isRecommendedTimelineAvailable
? [ ? [
@ -253,7 +253,7 @@ const headerTabs = computed(() => [
icon: `${icon("ph-thumbs-up")}`, icon: `${icon("ph-thumbs-up")}`,
iconOnly: true, iconOnly: true,
}, },
] ]
: []), : []),
...(isGlobalTimelineAvailable ...(isGlobalTimelineAvailable
? [ ? [
@ -263,7 +263,7 @@ const headerTabs = computed(() => [
icon: `${icon("ph-planet")}`, icon: `${icon("ph-planet")}`,
iconOnly: true, iconOnly: true,
}, },
] ]
: []), : []),
]); ]);
@ -274,12 +274,12 @@ definePageMetadata(
src.value === "local" src.value === "local"
? "ph-users ph-lg" ? "ph-users ph-lg"
: src.value === "social" : src.value === "social"
? "ph-handshake ph-lg" ? "ph-handshake ph-lg"
: src.value === "recommended" : src.value === "recommended"
? "ph-thumbs-up ph-lg" ? "ph-thumbs-up ph-lg"
: src.value === "global" : src.value === "global"
? "ph-planet ph-lg" ? "ph-planet ph-lg"
: "ph-house ph-lg", : "ph-house ph-lg",
})), })),
); );

View file

@ -418,7 +418,7 @@ function createFetcher() {
isAdmin isAdmin
? os.api("admin/get-user-ips", { ? os.api("admin/get-user-ips", {
userId: props.userId, userId: props.userId,
}) })
: Promise.resolve(null), : Promise.resolve(null),
]).then(([_user, _info, _ips]) => { ]).then(([_user, _info, _ips]) => {
user.value = _user; user.value = _user;
@ -644,7 +644,7 @@ const headerTabs = computed(() =>
key: "moderation", key: "moderation",
title: i18n.ts.moderation, title: i18n.ts.moderation,
icon: `${icon("ph-shield")}`, icon: `${icon("ph-shield")}`,
} }
: null, : null,
{ {
key: "chart", key: "chart",

View file

@ -73,7 +73,7 @@ const headerActions = computed(() =>
text: i18n.ts.settings, text: i18n.ts.settings,
handler: settings, handler: settings,
}, },
] ]
: [], : [],
); );
@ -85,7 +85,7 @@ definePageMetadata(
? { ? {
title: list.value.name, title: list.value.name,
icon: `${icon("ph-list-bullets")}`, icon: `${icon("ph-list-bullets")}`,
} }
: null, : null,
), ),
); );

View file

@ -66,7 +66,7 @@ definePageMetadata(
subtitle: i18n.ts.followers, subtitle: i18n.ts.followers,
userName: user.value, userName: user.value,
avatar: user.value, avatar: user.value,
} }
: null, : null,
), ),
); );

View file

@ -66,7 +66,7 @@ definePageMetadata(
subtitle: i18n.ts.following, subtitle: i18n.ts.following,
userName: user.value, userName: user.value,
avatar: user.value, avatar: user.value,
} }
: null, : null,
), ),
); );

View file

@ -31,7 +31,7 @@
user.bannerUrl user.bannerUrl
? `url('${getStaticImageUrl( ? `url('${getStaticImageUrl(
user.bannerUrl, user.bannerUrl,
)}')` )}')`
: null, : null,
}" }"
></div> ></div>

View file

@ -96,7 +96,7 @@ const headerTabs = computed(() =>
title: i18n.ts.reaction, title: i18n.ts.reaction,
icon: `${icon("ph-smiley")}`, icon: `${icon("ph-smiley")}`,
}, },
] ]
: []), : []),
...(user.value.instance == null ...(user.value.instance == null
? [ ? [
@ -115,9 +115,9 @@ const headerTabs = computed(() =>
title: i18n.ts.gallery, title: i18n.ts.gallery,
icon: `${icon("ph-image-square")}`, icon: `${icon("ph-image-square")}`,
}, },
] ]
: []), : []),
] ]
: null, : null,
); );
@ -136,7 +136,7 @@ definePageMetadata(
share: { share: {
title: user.value.name, title: user.value.name,
}, },
} }
: null, : null,
), ),
); );

View file

@ -188,7 +188,7 @@ function showMenu(ev) {
action: () => { action: () => {
window.open(instance.tosUrl, "_blank"); window.open(instance.tosUrl, "_blank");
}, },
} }
: null, : null,
], ],
ev.currentTarget ?? ev.target, ev.currentTarget ?? ev.target,

View file

@ -9,7 +9,7 @@ const isSmartphone = !isTablet && /mobile|iphone|android/.test(ua);
export const deviceKind = defaultStore.state.overridedDeviceKind export const deviceKind = defaultStore.state.overridedDeviceKind
? defaultStore.state.overridedDeviceKind ? defaultStore.state.overridedDeviceKind
: isSmartphone : isSmartphone
? "smartphone" ? "smartphone"
: isTablet : isTablet
? "tablet" ? "tablet"
: "desktop"; : "desktop";

Some files were not shown because too many files have changed in this diff Show more