cleanup: trim trailing whitespace (#11136)

* cleanup: trim trailing whitespace

* update(`.editorconfig`)

---------

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
okayurisotto 2023-07-08 07:08:16 +09:00 committed by GitHub
parent 4c879b3a33
commit d84796588c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
161 changed files with 615 additions and 609 deletions

View file

@ -40,15 +40,15 @@ export class AuthenticateService implements OnApplicationShutdown {
if (token == null) {
return [null, null];
}
if (isNativeToken(token)) {
const user = await this.cacheService.localUserByNativeTokenCache.fetch(token,
() => this.usersRepository.findOneBy({ token }) as Promise<LocalUser | null>);
if (user == null) {
throw new AuthenticationError('user not found');
}
return [user, null];
} else {
const accessToken = await this.accessTokensRepository.findOne({
@ -58,24 +58,24 @@ export class AuthenticateService implements OnApplicationShutdown {
token: token, // miauth
}],
});
if (accessToken == null) {
throw new AuthenticationError('invalid signature');
}
this.accessTokensRepository.update(accessToken.id, {
lastUsedAt: new Date(),
});
const user = await this.cacheService.localUserByIdCache.fetch(accessToken.userId,
() => this.usersRepository.findOneBy({
id: accessToken.userId,
}) as Promise<LocalUser>);
if (accessToken.appId) {
const app = await this.appCache.fetch(accessToken.appId,
() => this.appsRepository.findOneByOrFail({ id: accessToken.appId! }));
return [user, {
id: accessToken.id,
permission: app.permission,

View file

@ -38,14 +38,14 @@ export class RateLimiterService {
max: 1,
db: this.redisClient,
});
minIntervalLimiter.get((err, info) => {
if (err) {
return reject('ERR');
}
this.logger.debug(`${actor} ${limitation.key} min remaining: ${info.remaining}`);
if (info.remaining === 0) {
reject('BRIEF_REQUEST_INTERVAL');
} else {
@ -57,7 +57,7 @@ export class RateLimiterService {
}
});
};
// Long term limit
const max = (): void => {
const limiter = new Limiter({
@ -66,14 +66,14 @@ export class RateLimiterService {
max: limitation.max! / factor,
db: this.redisClient,
});
limiter.get((err, info) => {
if (err) {
return reject('ERR');
}
this.logger.debug(`${actor} ${limitation.key} max remaining: ${info.remaining}`);
if (info.remaining === 0) {
reject('RATE_LIMIT_EXCEEDED');
} else {
@ -81,13 +81,13 @@ export class RateLimiterService {
}
});
};
const hasShortTermLimit = typeof limitation.minInterval === 'number';
const hasLongTermLimit =
typeof limitation.duration === 'number' &&
typeof limitation.max === 'number';
if (hasShortTermLimit) {
min();
} else if (hasLongTermLimit) {

View file

@ -36,7 +36,7 @@ export class SigninService {
headers: request.headers as any,
success: true,
}).then(x => this.signinsRepository.findOneByOrFail(x.identifiers[0]));
// Publish signin event
this.globalEventService.publishMainStream(user.id, 'signin', await this.signinEntityService.pack(record));
});

View file

@ -34,23 +34,23 @@ export abstract class Endpoint<T extends IEndpointMeta, Ps extends Schema> {
this.exec = (params: any, user: T['requireCredential'] extends true ? LocalUser : LocalUser | null, token: AccessToken | null, file?: File, ip?: string | null, headers?: Record<string, string> | null) => {
let cleanup: undefined | (() => void) = undefined;
if (meta.requireFile) {
cleanup = () => {
if (file) fs.unlink(file.path, () => {});
};
if (file == null) return Promise.reject(new ApiError({
message: 'File required.',
code: 'FILE_REQUIRED',
id: '4267801e-70d1-416a-b011-4ee502885d8b',
}));
}
const valid = validate(params);
if (!valid) {
if (file) cleanup!();
const errors = validate.errors!;
const err = new ApiError({
message: 'Invalid param.',
@ -62,7 +62,7 @@ export abstract class Endpoint<T extends IEndpointMeta, Ps extends Schema> {
});
return Promise.reject(err);
}
return cb(params as SchemaType<Ps>, user, token, file, cleanup, ip, headers);
};
}

View file

@ -47,7 +47,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
title: ps.title,
text: ps.text,
/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- 空の文字列の場合、nullを渡すようにするため */
imageUrl: ps.imageUrl || null,
imageUrl: ps.imageUrl || null,
});
});
}

View file

@ -90,7 +90,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
const queryarry = ps.query.match(/\:([a-z0-9_]*)\:/g);
if (queryarry) {
emojis = emojis.filter(emoji =>
emojis = emojis.filter(emoji =>
queryarry.includes(`:${emoji.name}:`)
);
} else {

View file

@ -70,7 +70,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
driveFile = await this.driveFilesRepository.findOneBy({ id: ps.fileId });
if (driveFile == null) throw new ApiError(meta.errors.noSuchFile);
}
await this.customEmojiService.update(ps.id, {
driveFile,
name: ps.name,

View file

@ -36,7 +36,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
await queue.promote();
}
break;
case 'inbox':
delayedQueues = await this.queueService.inboxQueue.getDelayed();
for (let queueIndex = 0; queueIndex < delayedQueues.length; queueIndex++) {

View file

@ -136,7 +136,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (Array.isArray(ps.sensitiveWords)) {
set.sensitiveWords = ps.sensitiveWords.filter(Boolean);
}
if (ps.themeColor !== undefined) {
set.themeColor = ps.themeColor;
}

View file

@ -77,7 +77,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
const limit = ps.limit + (ps.untilId ? 1 : 0); // untilIdに指定したものも含まれるため+1
let noteIdsRes: [string, string[]][] = [];
if (!ps.sinceId && !ps.sinceDate) {
noteIdsRes = await this.redisClient.xrevrange(
`channelTimeline:${channel.id}`,

View file

@ -40,7 +40,7 @@ export const meta = {
code: 'NO_SUCH_FOLDER',
id: 'ea8fb7a5-af77-4a08-b608-c0218176cd73',
},
restrictedByRole: {
message: 'This feature is restricted by your role.',
code: 'RESTRICTED_BY_ROLE',

View file

@ -36,7 +36,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
constructor(
@Inject(DI.config)
private config: Config,
@Inject(DI.emojisRepository)
private emojisRepository: EmojisRepository,

View file

@ -43,7 +43,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
constructor(
@Inject(DI.config)
private config: Config,
@Inject(DI.emojisRepository)
private emojisRepository: EmojisRepository,

View file

@ -39,7 +39,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
constructor(
@Inject(DI.usersRepository)
private usersRepository: UsersRepository,
private userEntityService: UserEntityService,
) {
super(meta, paramDef, async (ps, me) => {

View file

@ -68,7 +68,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
});
userProfile.loggedInDates = [...userProfile.loggedInDates, today];
}
return await this.userEntityService.pack<true, true>(userProfile.user!, userProfile.user!, {
detail: true,
includeSecrets: isSecure,

View file

@ -61,7 +61,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (key.userId !== me.id) {
throw new ApiError(meta.errors.accessDenied);
}
await this.userSecurityKeysRepository.update(key.id, {
name: ps.name,
});

View file

@ -250,7 +250,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
constructor(
@Inject(DI.config)
private config: Config,
@Inject(DI.usersRepository)
private usersRepository: UsersRepository,

View file

@ -53,34 +53,34 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
if (ps.local) {
query.andWhere('note.userHost IS NULL');
}
if (ps.reply !== undefined) {
query.andWhere(ps.reply ? 'note.replyId IS NOT NULL' : 'note.replyId IS NULL');
}
if (ps.renote !== undefined) {
query.andWhere(ps.renote ? 'note.renoteId IS NOT NULL' : 'note.renoteId IS NULL');
}
if (ps.withFiles !== undefined) {
query.andWhere(ps.withFiles ? 'note.fileIds != \'{}\'' : 'note.fileIds = \'{}\'');
}
if (ps.poll !== undefined) {
query.andWhere(ps.poll ? 'note.hasPoll = TRUE' : 'note.hasPoll = FALSE');
}
// TODO
//if (bot != undefined) {
// query.isBot = bot;
//}
const notes = await query.take(ps.limit).getMany();
return await this.noteEntityService.packMany(notes);
});
}

View file

@ -58,7 +58,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
constructor(
@Inject(DI.config)
private config: Config,
private noteEntityService: NoteEntityService,
private searchService: SearchService,
private roleService: RoleService,
@ -68,7 +68,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (!policies.canSearchNotes) {
throw new ApiError(meta.errors.unavailable);
}
const notes = await this.searchService.searchNote(ps.query, me, {
userId: ps.userId,
channelId: ps.channelId,

View file

@ -44,7 +44,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
constructor(
@Inject(DI.config)
private config: Config,
@Inject(DI.notesRepository)
private notesRepository: NotesRepository,

View file

@ -71,7 +71,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (role == null) {
throw new ApiError(meta.errors.noSuchRole);
}
if (!role.isExplorable) {
if (!role.isExplorable) {
return [];
}
const limit = ps.limit + (ps.untilId ? 1 : 0) + (ps.sinceId ? 1 : 0); // untilIdに指定したものも含まれるため+1

View file

@ -95,7 +95,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (currentCount > (await this.roleService.getUserPolicies(me.id)).userListLimit) {
throw new ApiError(meta.errors.tooManyUserLists);
}
const userList = await this.userListsRepository.insert({
id: this.idService.genId(),
createdAt: new Date(),
@ -127,7 +127,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
userListId: userList.id,
userId: currentUser.id,
});
if (exist) {
throw new ApiError(meta.errors.alreadyAdded);
}

View file

@ -41,7 +41,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
private idService: IdService,
) {
super(meta, paramDef, async (ps, me) => {
const userList = await this.userListsRepository.findOneBy({
const userList = await this.userListsRepository.findOneBy({
id: ps.listId,
isPublic: true,
});

View file

@ -78,7 +78,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.getMany();
} else {
const nameQuery = this.usersRepository.createQueryBuilder('user')
.where(new Brackets(qb => {
.where(new Brackets(qb => {
qb.where('user.name ILIKE :query', { query: '%' + sqlLikeEscape(ps.query) + '%' });
// Also search username if it qualifies as username

View file

@ -52,7 +52,7 @@ export class ChannelsService {
case 'serverStats': return this.serverStatsChannelService;
case 'queueStats': return this.queueStatsChannelService;
case 'admin': return this.adminChannelService;
default:
throw new Error(`no such channel: ${name}`);
}

View file

@ -49,7 +49,7 @@ class HashtagChannel extends Channel {
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
if (isUserRelated(note, this.userIdsWhoBlockingMe)) return;
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
this.connection.cacheNote(note);

View file

@ -26,7 +26,7 @@ class HomeTimelineChannel extends Channel {
@bindThis
public async init(params: any) {
this.withReplies = params.withReplies as boolean;
this.subscriber.on('notesStream', this.onNote);
}

View file

@ -12,7 +12,7 @@ class RoleTimelineChannel extends Channel {
public static shouldShare = false;
public static requireCredential = false;
private roleId: string;
constructor(
private noteEntityService: NoteEntityService,
private roleservice: RoleService,

View file

@ -20,7 +20,7 @@ class UserListChannel extends Channel {
private userListsRepository: UserListsRepository,
private userListJoiningsRepository: UserListJoiningsRepository,
private noteEntityService: NoteEntityService,
id: string,
connection: Channel['connection'],
) {

View file

@ -38,9 +38,9 @@ export class FeedService {
link: `${this.config.url}/@${user.username}`,
name: user.name ?? user.username,
};
const profile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id });
const notes = await this.notesRepository.find({
where: {
userId: user.id,
@ -50,7 +50,7 @@ export class FeedService {
order: { createdAt: -1 },
take: 20,
});
const feed = new Feed({
id: author.link,
title: `${author.name} (@${user.username}@${this.config.host})`,
@ -66,13 +66,13 @@ export class FeedService {
author,
copyright: user.name ?? user.username,
});
for (const note of notes) {
const files = note.fileIds.length > 0 ? await this.driveFilesRepository.findBy({
id: In(note.fileIds),
}) : [];
const file = files.find(file => file.type.startsWith('image/'));
feed.addItem({
title: `New note by ${author.name}`,
link: `${this.config.url}/notes/${note.id}`,
@ -82,7 +82,7 @@ export class FeedService {
image: file ? this.driveFileEntityService.getPublicUrl(file) ?? undefined : undefined,
});
}
return feed;
}
}

View file

@ -8,7 +8,7 @@ window.onload = async () => {
const promise = new Promise((resolve, reject) => {
// Append a credential
if (i) data.i = i;
// Send request
window.fetch(endpoint.indexOf('://') > -1 ? endpoint : `/api/${endpoint}`, {
method: 'POST',
@ -17,7 +17,7 @@ window.onload = async () => {
cache: 'no-cache'
}).then(async (res) => {
const body = res.status === 204 ? null : await res.json();
if (res.status === 200) {
resolve(body);
} else if (res.status === 204) {
@ -27,7 +27,7 @@ window.onload = async () => {
}
}).catch(reject);
});
return promise;
};

View file

@ -8,7 +8,7 @@ window.onload = async () => {
const promise = new Promise((resolve, reject) => {
// Append a credential
if (i) data.i = i;
// Send request
fetch(endpoint.indexOf('://') > -1 ? endpoint : `/api/${endpoint}`, {
headers: {
@ -20,7 +20,7 @@ window.onload = async () => {
cache: 'no-cache'
}).then(async (res) => {
const body = res.status === 204 ? null : await res.json();
if (res.status === 200) {
resolve(body);
} else if (res.status === 204) {
@ -30,7 +30,7 @@ window.onload = async () => {
}
}).catch(reject);
});
return promise;
};

View file

@ -55,8 +55,8 @@ html
block meta
block og
meta(property='og:title' content= title || 'Misskey')
meta(property='og:description' content= desc || '✨🌎✨ A interplanetary communication platform ✨🚀✨')
meta(property='og:title' content= title || 'Misskey')
meta(property='og:description' content= desc || '✨🌎✨ A interplanetary communication platform ✨🚀✨')
meta(property='og:image' content= img)
meta(property='twitter:card' content='summary')

View file

@ -32,12 +32,12 @@ body
path(stroke="none", d="M0 0h24v24H0z", fill="none")
path(d="M12 9v2m0 4v.01")
path(d="M5 19h14a2 2 0 0 0 1.84 -2.75l-7.1 -12.25a2 2 0 0 0 -3.5 0l-7.1 12.25a2 2 0 0 0 1.75 2.75")
h1 An error has occurred!
button.button-big(onclick="location.reload();")
span.button-label-big Refresh
p.dont-worry Don't worry, it's (probably) not your fault.
p If reloading after a period of time does not resolve the problem, contact the server administrator with the following ERROR ID.

View file

@ -43,7 +43,7 @@ block meta
meta(name='misskey:user-username' content=user.username)
meta(name='misskey:user-id' content=user.id)
meta(name='misskey:note-id' content=note.id)
// todo
if user.twitter
meta(name='twitter:creator' content=`@${user.twitter.screenName}`)