mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-08 13:04:34 +00:00
fix backend lint errors
This commit is contained in:
parent
9dffb13be7
commit
f9c1535147
13 changed files with 27 additions and 23 deletions
|
@ -487,7 +487,7 @@ function applyEnvOverrides(config: Source) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _step2name(step: string|number): string {
|
function _step2name(step: string | number): string {
|
||||||
return step.toString().replaceAll(/[^a-z0-9]+/gi, '').toUpperCase();
|
return step.toString().replaceAll(/[^a-z0-9]+/gi, '').toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ export class DownloadService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async downloadUrl(url: string, path: string, options: { timeout?: number, operationTimeout?: number, maxSize?: number} = {} ): Promise<{
|
public async downloadUrl(url: string, path: string, options: { timeout?: number, operationTimeout?: number, maxSize?: number } = {} ): Promise<{
|
||||||
filename: string;
|
filename: string;
|
||||||
}> {
|
}> {
|
||||||
this.logger.info(`Downloading ${chalk.cyan(url)} to ${chalk.cyanBright(path)} ...`);
|
this.logger.info(`Downloading ${chalk.cyan(url)} to ${chalk.cyanBright(path)} ...`);
|
||||||
|
|
|
@ -112,7 +112,7 @@ export interface IActivity extends IObject {
|
||||||
actor: IObject | string;
|
actor: IObject | string;
|
||||||
// ActivityPub spec allows for arrays: https://www.w3.org/TR/activitystreams-vocabulary/#properties
|
// ActivityPub spec allows for arrays: https://www.w3.org/TR/activitystreams-vocabulary/#properties
|
||||||
// Misskey can only handle one value, so we use a tuple for that case.
|
// Misskey can only handle one value, so we use a tuple for that case.
|
||||||
object: IObject | string | [IObject | string] ;
|
object: IObject | string | [IObject | string];
|
||||||
target?: IObject | string;
|
target?: IObject | string;
|
||||||
/** LD-Signature */
|
/** LD-Signature */
|
||||||
signature?: {
|
signature?: {
|
||||||
|
|
|
@ -77,7 +77,7 @@ type PackedPureRenote = PackedRenote & {
|
||||||
replyId: NonNullable<Packed<'Note'>['replyId']>;
|
replyId: NonNullable<Packed<'Note'>['replyId']>;
|
||||||
poll: NonNullable<Packed<'Note'>['poll']>;
|
poll: NonNullable<Packed<'Note'>['poll']>;
|
||||||
fileIds: NonNullable<Packed<'Note'>['fileIds']>;
|
fileIds: NonNullable<Packed<'Note'>['fileIds']>;
|
||||||
}
|
};
|
||||||
|
|
||||||
export function isRenotePacked(note: Packed<'Note'>): note is PackedRenote {
|
export function isRenotePacked(note: Packed<'Note'>): note is PackedRenote {
|
||||||
return note.renoteId != null;
|
return note.renoteId != null;
|
||||||
|
|
|
@ -83,7 +83,7 @@ export class ImportNotesProcessorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
private downloadUrl(url: string, path:string): Promise<{filename: string}> {
|
private downloadUrl(url: string, path:string): Promise<{ filename: string }> {
|
||||||
return this.downloadService.downloadUrl(url, path, { operationTimeout: this.config.import?.downloadTimeout, maxSize: this.config.import?.maxFileSize });
|
return this.downloadService.downloadUrl(url, path, { operationTimeout: this.config.import?.downloadTimeout, maxSize: this.config.import?.maxFileSize });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,4 +161,4 @@ export type ThinUser = {
|
||||||
|
|
||||||
export type ScheduleNotePostJobData = {
|
export type ScheduleNotePostJobData = {
|
||||||
scheduleNoteId: MiNote['id'];
|
scheduleNoteId: MiNote['id'];
|
||||||
}
|
};
|
||||||
|
|
|
@ -100,7 +100,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
id: string;
|
id: string;
|
||||||
note: {
|
note: {
|
||||||
text?: string;
|
text?: string;
|
||||||
cw?: string|null;
|
cw?: string | null;
|
||||||
fileIds: string[];
|
fileIds: string[];
|
||||||
visibility: typeof noteVisibilities[number];
|
visibility: typeof noteVisibilities[number];
|
||||||
visibleUsers: Packed<'UserLite'>[];
|
visibleUsers: Packed<'UserLite'>[];
|
||||||
|
|
|
@ -192,7 +192,7 @@ export class MastodonApiServerService {
|
||||||
reply.send(response);
|
reply.send(response);
|
||||||
});
|
});
|
||||||
|
|
||||||
fastify.post<{ Body: { description?: string; focus?: string }}>('/v2/media', { preHandler: upload.single('file') }, async (_request, reply) => {
|
fastify.post<{ Body: { description?: string; focus?: string } }>('/v2/media', { preHandler: upload.single('file') }, async (_request, reply) => {
|
||||||
const multipartData = await _request.file();
|
const multipartData = await _request.file();
|
||||||
if (!multipartData) {
|
if (!multipartData) {
|
||||||
reply.code(401).send({ error: 'No image' });
|
reply.code(401).send({ error: 'No image' });
|
||||||
|
@ -284,7 +284,7 @@ export class MastodonApiServerService {
|
||||||
reply.send(response);
|
reply.send(response);
|
||||||
});
|
});
|
||||||
|
|
||||||
fastify.get<{ Querystring: { limit?: string }}>('/v1/follow_requests', async (_request, reply) => {
|
fastify.get<{ Querystring: { limit?: string } }>('/v1/follow_requests', async (_request, reply) => {
|
||||||
const client = this.clientService.getClient(_request);
|
const client = this.clientService.getClient(_request);
|
||||||
|
|
||||||
const limit = _request.query.limit ? parseInt(_request.query.limit) : 20;
|
const limit = _request.query.limit ? parseInt(_request.query.limit) : 20;
|
||||||
|
|
|
@ -142,7 +142,7 @@ export class ApiAccountMastodon {
|
||||||
reply.send(response);
|
reply.send(response);
|
||||||
});
|
});
|
||||||
|
|
||||||
fastify.get<{ Querystring: { acct?: string }}>('/v1/accounts/lookup', async (_request, reply) => {
|
fastify.get<{ Querystring: { acct?: string } }>('/v1/accounts/lookup', async (_request, reply) => {
|
||||||
if (!_request.query.acct) return reply.code(400).send({ error: 'BAD_REQUEST', error_description: 'Missing required property "acct"' });
|
if (!_request.query.acct) return reply.code(400).send({ error: 'BAD_REQUEST', error_description: 'Missing required property "acct"' });
|
||||||
|
|
||||||
const client = this.clientService.getClient(_request);
|
const client = this.clientService.getClient(_request);
|
||||||
|
@ -154,7 +154,7 @@ export class ApiAccountMastodon {
|
||||||
reply.send(response);
|
reply.send(response);
|
||||||
});
|
});
|
||||||
|
|
||||||
fastify.get<ApiAccountMastodonRoute & { Querystring: { id?: string | string[] }}>('/v1/accounts/relationships', async (_request, reply) => {
|
fastify.get<ApiAccountMastodonRoute & { Querystring: { id?: string | string[] } }>('/v1/accounts/relationships', async (_request, reply) => {
|
||||||
if (!_request.query.id) return reply.code(400).send({ error: 'BAD_REQUEST', error_description: 'Missing required property "id"' });
|
if (!_request.query.id) return reply.code(400).send({ error: 'BAD_REQUEST', error_description: 'Missing required property "id"' });
|
||||||
|
|
||||||
const client = this.clientService.getClient(_request);
|
const client = this.clientService.getClient(_request);
|
||||||
|
|
|
@ -148,7 +148,7 @@ describe('Streaming', () => {
|
||||||
|
|
||||||
test('フォローしているユーザーの投稿が流れる', async () => {
|
test('フォローしているユーザーの投稿が流れる', async () => {
|
||||||
const fired = await waitFire(
|
const fired = await waitFire(
|
||||||
ayano, 'homeTimeline', // ayano:home
|
ayano, 'homeTimeline', // ayano:home
|
||||||
() => api('notes/create', { text: 'foo' }, kyoko), // kyoko posts
|
() => api('notes/create', { text: 'foo' }, kyoko), // kyoko posts
|
||||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
||||||
);
|
);
|
||||||
|
@ -158,7 +158,7 @@ describe('Streaming', () => {
|
||||||
|
|
||||||
test('フォローしているユーザーの visibility: followers な投稿が流れる', async () => {
|
test('フォローしているユーザーの visibility: followers な投稿が流れる', async () => {
|
||||||
const fired = await waitFire(
|
const fired = await waitFire(
|
||||||
ayano, 'homeTimeline', // ayano:home
|
ayano, 'homeTimeline', // ayano:home
|
||||||
() => api('notes/create', { text: 'foo', visibility: 'followers' }, kyoko), // kyoko posts
|
() => api('notes/create', { text: 'foo', visibility: 'followers' }, kyoko), // kyoko posts
|
||||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
||||||
);
|
);
|
||||||
|
@ -170,7 +170,7 @@ describe('Streaming', () => {
|
||||||
const note = await post(kyoko, { text: 'foo', visibility: 'followers' });
|
const note = await post(kyoko, { text: 'foo', visibility: 'followers' });
|
||||||
|
|
||||||
const fired = await waitFire(
|
const fired = await waitFire(
|
||||||
ayano, 'homeTimeline', // ayano:home
|
ayano, 'homeTimeline', // ayano:home
|
||||||
() => api('notes/create', { text: 'bar', visibility: 'followers', replyId: note.id }, kyoko), // kyoko posts
|
() => api('notes/create', { text: 'bar', visibility: 'followers', replyId: note.id }, kyoko), // kyoko posts
|
||||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id && msg.body.reply.text === 'foo',
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id && msg.body.reply.text === 'foo',
|
||||||
);
|
);
|
||||||
|
@ -182,7 +182,7 @@ describe('Streaming', () => {
|
||||||
const chitoseNote = await post(chitose, { text: 'followers-only post', visibility: 'followers' });
|
const chitoseNote = await post(chitose, { text: 'followers-only post', visibility: 'followers' });
|
||||||
|
|
||||||
const fired = await waitFire(
|
const fired = await waitFire(
|
||||||
ayano, 'homeTimeline', // ayano:home
|
ayano, 'homeTimeline', // ayano:home
|
||||||
() => api('notes/create', { text: 'reply to chitose\'s followers-only post', replyId: chitoseNote.id }, kyoko), // kyoko's reply to chitose's followers-only post
|
() => api('notes/create', { text: 'reply to chitose\'s followers-only post', replyId: chitoseNote.id }, kyoko), // kyoko's reply to chitose's followers-only post
|
||||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
||||||
);
|
);
|
||||||
|
@ -195,7 +195,7 @@ describe('Streaming', () => {
|
||||||
const kyokoReply = await post(kyoko, { text: 'reply to followers-only post', replyId: chitoseNote.id });
|
const kyokoReply = await post(kyoko, { text: 'reply to followers-only post', replyId: chitoseNote.id });
|
||||||
|
|
||||||
const fired = await waitFire(
|
const fired = await waitFire(
|
||||||
ayano, 'homeTimeline', // ayano:home
|
ayano, 'homeTimeline', // ayano:home
|
||||||
() => api('notes/create', { renoteId: kyokoReply.id }, kyoko), // kyoko's renote of kyoko's reply to chitose's followers-only post
|
() => api('notes/create', { renoteId: kyokoReply.id }, kyoko), // kyoko's renote of kyoko's reply to chitose's followers-only post
|
||||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
||||||
);
|
);
|
||||||
|
@ -205,7 +205,7 @@ describe('Streaming', () => {
|
||||||
|
|
||||||
test('フォローしていないユーザーの投稿は流れない', async () => {
|
test('フォローしていないユーザーの投稿は流れない', async () => {
|
||||||
const fired = await waitFire(
|
const fired = await waitFire(
|
||||||
kyoko, 'homeTimeline', // kyoko:home
|
kyoko, 'homeTimeline', // kyoko:home
|
||||||
() => api('notes/create', { text: 'foo' }, ayano), // ayano posts
|
() => api('notes/create', { text: 'foo' }, ayano), // ayano posts
|
||||||
msg => msg.type === 'note' && msg.body.userId === ayano.id, // wait ayano
|
msg => msg.type === 'note' && msg.body.userId === ayano.id, // wait ayano
|
||||||
);
|
);
|
||||||
|
@ -215,7 +215,7 @@ describe('Streaming', () => {
|
||||||
|
|
||||||
test('フォローしているユーザーのダイレクト投稿が流れる', async () => {
|
test('フォローしているユーザーのダイレクト投稿が流れる', async () => {
|
||||||
const fired = await waitFire(
|
const fired = await waitFire(
|
||||||
ayano, 'homeTimeline', // ayano:home
|
ayano, 'homeTimeline', // ayano:home
|
||||||
() => api('notes/create', { text: 'foo', visibility: 'specified', visibleUserIds: [ayano.id] }, kyoko), // kyoko dm => ayano
|
() => api('notes/create', { text: 'foo', visibility: 'specified', visibleUserIds: [ayano.id] }, kyoko), // kyoko dm => ayano
|
||||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
||||||
);
|
);
|
||||||
|
@ -225,7 +225,7 @@ describe('Streaming', () => {
|
||||||
|
|
||||||
test('フォローしているユーザーでも自分が指定されていないダイレクト投稿は流れない', async () => {
|
test('フォローしているユーザーでも自分が指定されていないダイレクト投稿は流れない', async () => {
|
||||||
const fired = await waitFire(
|
const fired = await waitFire(
|
||||||
ayano, 'homeTimeline', // ayano:home
|
ayano, 'homeTimeline', // ayano:home
|
||||||
() => api('notes/create', { text: 'foo', visibility: 'specified', visibleUserIds: [chitose.id] }, kyoko), // kyoko dm => chitose
|
() => api('notes/create', { text: 'foo', visibility: 'specified', visibleUserIds: [chitose.id] }, kyoko), // kyoko dm => chitose
|
||||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
||||||
);
|
);
|
||||||
|
@ -574,7 +574,7 @@ describe('Streaming', () => {
|
||||||
|
|
||||||
test('withReplies = falseでフォローしてる人によるリプライが流れてくる', async () => {
|
test('withReplies = falseでフォローしてる人によるリプライが流れてくる', async () => {
|
||||||
const fired = await waitFire(
|
const fired = await waitFire(
|
||||||
ayano, 'globalTimeline', // ayano:Global
|
ayano, 'globalTimeline', // ayano:Global
|
||||||
() => api('notes/create', { text: 'foo', replyId: kanakoNote.id }, kyoko), // kyoko posts
|
() => api('notes/create', { text: 'foo', replyId: kanakoNote.id }, kyoko), // kyoko posts
|
||||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
||||||
);
|
);
|
||||||
|
|
|
@ -312,7 +312,9 @@ describe('ユーザー', () => {
|
||||||
assert.strictEqual(response.name, null);
|
assert.strictEqual(response.name, null);
|
||||||
assert.strictEqual(response.username, 'zoe');
|
assert.strictEqual(response.username, 'zoe');
|
||||||
assert.strictEqual(response.host, null);
|
assert.strictEqual(response.host, null);
|
||||||
response.avatarUrl && assert.match(response.avatarUrl, /^[-a-zA-Z0-9@:%._\+~#&?=\/]+$/);
|
if (response.avatarUrl) {
|
||||||
|
assert.match(response.avatarUrl, /^[-a-zA-Z0-9@:%._\+~#&?=\/]+$/);
|
||||||
|
}
|
||||||
assert.strictEqual(response.avatarBlurhash, null);
|
assert.strictEqual(response.avatarBlurhash, null);
|
||||||
assert.deepStrictEqual(response.avatarDecorations, []);
|
assert.deepStrictEqual(response.avatarDecorations, []);
|
||||||
assert.strictEqual(response.isBot, false);
|
assert.strictEqual(response.isBot, false);
|
||||||
|
|
|
@ -54,7 +54,7 @@ class DummyFastifyReply {
|
||||||
}
|
}
|
||||||
class DummyFastifyRequest {
|
class DummyFastifyRequest {
|
||||||
public ip: string;
|
public ip: string;
|
||||||
public body: {credential: any, context: string};
|
public body: { credential: any, context: string };
|
||||||
public headers: IncomingHttpHeaders = { 'accept': 'application/json' };
|
public headers: IncomingHttpHeaders = { 'accept': 'application/json' };
|
||||||
constructor(body?: any) {
|
constructor(body?: any) {
|
||||||
this.ip = '0.0.0.0';
|
this.ip = '0.0.0.0';
|
||||||
|
|
|
@ -661,7 +661,9 @@ export async function captureWebhook<T = SystemWebhookPayload>(postAction: () =>
|
||||||
let timeoutHandle: NodeJS.Timeout | null = null;
|
let timeoutHandle: NodeJS.Timeout | null = null;
|
||||||
const result = await new Promise<string>(async (resolve, reject) => {
|
const result = await new Promise<string>(async (resolve, reject) => {
|
||||||
fastify.all('/', async (req, res) => {
|
fastify.all('/', async (req, res) => {
|
||||||
timeoutHandle && clearTimeout(timeoutHandle);
|
if (timeoutHandle) {
|
||||||
|
clearTimeout(timeoutHandle);
|
||||||
|
}
|
||||||
|
|
||||||
const body = JSON.stringify(req.body);
|
const body = JSON.stringify(req.body);
|
||||||
res.status(200).send('ok');
|
res.status(200).send('ok');
|
||||||
|
|
Loading…
Add table
Reference in a new issue