This commit is contained in:
syuilo
2021-12-09 23:58:30 +09:00
parent 0abe2dfee0
commit c69b72e199
573 changed files with 3318 additions and 3318 deletions

View File

@ -10,7 +10,7 @@ export class Cache<T> {
public set(key: string | null, value: T): void {
this.cache.set(key, {
date: Date.now(),
value
value,
});
}

View File

@ -33,17 +33,17 @@ type CaptchaResponse = {
async function getCaptchaResponse(url: string, secret: string, response: string): Promise<CaptchaResponse> {
const params = new URLSearchParams({
secret,
response
response,
});
const res = await fetch(url, {
method: 'POST',
body: params,
headers: {
'User-Agent': config.userAgent
'User-Agent': config.userAgent,
},
timeout: 10 * 1000,
agent: getAgentByUrl
agent: getAgentByUrl,
}).catch(e => {
throw `${e.message || e}`;
});

View File

@ -24,7 +24,7 @@ export async function checkHitAntenna(antenna: Antenna, note: (Note | Packed<'No
if (antennaUserFollowing && !antennaUserFollowing.includes(note.userId)) return false;
} else if (antenna.src === 'list') {
const listUsers = (await UserListJoinings.find({
userListId: antenna.userListId!
userListId: antenna.userListId!,
})).map(x => x.userId);
if (!listUsers.includes(note.userId)) return false;
@ -32,7 +32,7 @@ export async function checkHitAntenna(antenna: Antenna, note: (Note | Packed<'No
const joining = await UserGroupJoinings.findOneOrFail(antenna.userGroupJoiningId!);
const groupUsers = (await UserGroupJoinings.find({
userGroupId: joining.userGroupId
userGroupId: joining.userGroupId,
})).map(x => x.userId);
if (!groupUsers.includes(note.userId)) return false;

View File

@ -22,7 +22,7 @@ export async function downloadUrl(url: string, path: string) {
const req = got.stream(url, {
headers: {
'User-Agent': config.userAgent
'User-Agent': config.userAgent,
},
timeout: {
lookup: timeout,

View File

@ -10,8 +10,8 @@ export async function fetchMeta(noCache = false): Promise<Meta> {
// 過去のバグでレコードが複数出来てしまっている可能性があるので新しいIDを優先する
const meta = await transactionalEntityManager.findOne(Meta, {
order: {
id: 'DESC'
}
id: 'DESC',
},
});
if (meta) {
@ -19,7 +19,7 @@ export async function fetchMeta(noCache = false): Promise<Meta> {
return meta;
} else {
const saved = await transactionalEntityManager.save(Meta, {
id: 'x'
id: 'x',
}) as Meta;
cache = saved;

View File

@ -12,9 +12,9 @@ export async function getJson(url: string, accept = 'application/json, */*', tim
method: 'GET',
headers: Object.assign({
'User-Agent': config.userAgent,
Accept: accept
Accept: accept,
}, headers || {}),
timeout
timeout,
});
return await res.json();
@ -26,9 +26,9 @@ export async function getHtml(url: string, accept = 'text/html, */*', timeout =
method: 'GET',
headers: Object.assign({
'User-Agent': config.userAgent,
Accept: accept
Accept: accept,
}, headers || {}),
timeout
timeout,
});
return await res.text();
@ -95,7 +95,7 @@ export const httpAgent = config.proxy
maxSockets,
maxFreeSockets: 256,
scheduling: 'lifo',
proxy: config.proxy
proxy: config.proxy,
})
: _http;
@ -109,7 +109,7 @@ export const httpsAgent = config.proxy
maxSockets,
maxFreeSockets: 256,
scheduling: 'lifo',
proxy: config.proxy
proxy: config.proxy,
})
: _https;

View File

@ -8,14 +8,14 @@ export async function genRsaKeyPair(modulusLength = 2048) {
modulusLength,
publicKeyEncoding: {
type: 'spki',
format: 'pem'
format: 'pem',
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'pem',
cipher: undefined,
passphrase: undefined
}
passphrase: undefined,
},
});
}
@ -24,13 +24,13 @@ export async function genEcKeyPair(namedCurve: 'prime256v1' | 'secp384r1' | 'sec
namedCurve,
publicKeyEncoding: {
type: 'spki',
format: 'pem'
format: 'pem',
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'pem',
cipher: undefined,
passphrase: undefined
}
passphrase: undefined,
},
});
}

View File

@ -26,12 +26,12 @@ export type FileInfo = {
const TYPE_OCTET_STREAM = {
mime: 'application/octet-stream',
ext: null
ext: null,
};
const TYPE_SVG = {
mime: 'image/svg+xml',
ext: 'svg'
ext: 'svg',
};
/**
@ -116,7 +116,7 @@ export async function detectType(path: string) {
return {
mime: type.mime,
ext: type.ext
ext: type.ext,
};
}

View File

@ -112,14 +112,14 @@ export function decodeReaction(str: string): DecodedReaction {
return {
reaction: `:${name}@${host || '.'}:`, // ローカル分は@以降を省略するのではなく.にする
name,
host
host,
};
}
return {
reaction: str,
name: undefined,
host: undefined
host: undefined,
};
}