Skip to content

Commit

Permalink
cleanup: trim trailing whitespace (#11136)
Browse files Browse the repository at this point in the history
* cleanup: trim trailing whitespace

* update(`.editorconfig`)

---------

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
  • Loading branch information
okayurisotto and syuilo authored Jul 7, 2023
1 parent 4c879b3 commit d847965
Show file tree
Hide file tree
Showing 161 changed files with 615 additions and 609 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.8'

services:
app:
build:
build:
context: .
dockerfile: Dockerfile

Expand Down
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ indent_size = 2
charset = utf-8
insert_final_newline = true
end_of_line = lf
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_style = space
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ If your language is not listed in Crowdin, please open an issue.
![Crowdin](https://d322cqt584bo4o.cloudfront.net/misskey/localized.svg)

## Development
During development, it is useful to use the
During development, it is useful to use the

```
pnpm dev
Expand Down Expand Up @@ -150,7 +150,7 @@ Prepare DB/Redis for testing.
```
docker compose -f packages/backend/test/docker-compose.yml up
```
Alternatively, prepare an empty (data can be erased) DB and edit `.config/test.yml`.
Alternatively, prepare an empty (data can be erased) DB and edit `.config/test.yml`.

Run all test.
```
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<a href="https://misskey-hub.net">
<img src="./assets/title_float.svg" alt="Misskey logo" style="border-radius:50%" width="400"/>
</a>

**🌎 **[Misskey](https://misskey-hub.net/)** is an open source, decentralized social media platform that's free forever! 🚀**

---

<a href="https://misskey-hub.net/instances.html">
Expand All @@ -21,7 +21,7 @@

<a href="https://www.patreon.com/syuilo">
<img src="https://custom-icon-badges.herokuapp.com/badge/become_a-patron-F96854?logoColor=F96854&style=for-the-badge&logo=patreon&labelColor=363B40" alt="become a patron"/></a>

---

[![codecov](https://codecov.io/gh/misskey-dev/misskey/branch/develop/graph/badge.svg?token=R6IQZ3QJOL)](https://codecov.io/gh/misskey-dev/misskey)
Expand Down
4 changes: 2 additions & 2 deletions assets/title_float.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion cypress/e2e/basic.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('After setup instance', () => {
cy.get('[data-cy-signup-rules-notes-agree] [data-cy-switch-toggle]').click();
cy.get('[data-cy-signup-rules-continue]').should('not.be.disabled');
cy.get('[data-cy-signup-rules-continue]').click();

cy.get('[data-cy-signup-submit]').should('be.disabled');
cy.get('[data-cy-signup-username] input').type('alice');
cy.get('[data-cy-signup-submit]').should('be.disabled');
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/AccountMoveService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export class AccountMoveService {
* dstユーザーのalsoKnownAsをfetchPersonしていき、本当にmovedToUrlをdstに指定するユーザーが存在するのかを調べる
*
* @param dst movedToUrlを指定するユーザー
* @param check
* @param check
* @param instant checkがtrueであるユーザーが最初に見つかったら即座にreturnするかどうか
* @returns Promise<LocalUser | RemoteUser | null>
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/backend/src/core/AiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ export class AiService {
const cpuFlags = await this.getCpuFlags();
isSupportedCpu = REQUIRED_CPU_FLAGS.every(required => cpuFlags.includes(required));
}

if (!isSupportedCpu) {
console.error('This CPU cannot use TensorFlow.');
return null;
}

const tf = await import('@tensorflow/tfjs-node');

if (this.model == null) this.model = await nsfw.load(`file://${_dirname}/../../nsfw-model/`, { size: 299 });

const buffer = await fs.promises.readFile(path);
const image = await tf.node.decodeImage(buffer, 3) as any;
try {
Expand Down
30 changes: 15 additions & 15 deletions packages/backend/src/core/AntennaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class AntennaService implements OnApplicationShutdown {
'MAXLEN', '~', '200',
'*',
'note', note.id);

this.globalEventService.publishAntennaStream(antenna.id, 'note', note);
}

Expand All @@ -112,16 +112,16 @@ export class AntennaService implements OnApplicationShutdown {
public async checkHitAntenna(antenna: Antenna, note: (Note | Packed<'Note'>), noteUser: { id: User['id']; username: string; host: string | null; }): Promise<boolean> {
if (note.visibility === 'specified') return false;
if (note.visibility === 'followers') return false;

if (!antenna.withReplies && note.replyId != null) return false;

if (antenna.src === 'home') {
// TODO
} else if (antenna.src === 'list') {
const listUsers = (await this.userListJoiningsRepository.findBy({
userListId: antenna.userListId!,
})).map(x => x.userId);

if (!listUsers.includes(note.userId)) return false;
} else if (antenna.src === 'users') {
const accts = antenna.users.map(x => {
Expand All @@ -130,32 +130,32 @@ export class AntennaService implements OnApplicationShutdown {
});
if (!accts.includes(this.utilityService.getFullApAccount(noteUser.username, noteUser.host).toLowerCase())) return false;
}

const keywords = antenna.keywords
// Clean up
.map(xs => xs.filter(x => x !== ''))
.filter(xs => xs.length > 0);

if (keywords.length > 0) {
if (note.text == null && note.cw == null) return false;

const _text = (note.text ?? '') + '\n' + (note.cw ?? '');

const matched = keywords.some(and =>
and.every(keyword =>
antenna.caseSensitive
? _text.includes(keyword)
: _text.toLowerCase().includes(keyword.toLowerCase()),
));

if (!matched) return false;
}

const excludeKeywords = antenna.excludeKeywords
// Clean up
.map(xs => xs.filter(x => x !== ''))
.filter(xs => xs.length > 0);

if (excludeKeywords.length > 0) {
if (note.text == null && note.cw == null) return false;

Expand All @@ -167,16 +167,16 @@ export class AntennaService implements OnApplicationShutdown {
? _text.includes(keyword)
: _text.toLowerCase().includes(keyword.toLowerCase()),
));

if (matched) return false;
}

if (antenna.withFile) {
if (note.fileIds && note.fileIds.length === 0) return false;
}

// TODO: eval expression

return true;
}

Expand All @@ -188,7 +188,7 @@ export class AntennaService implements OnApplicationShutdown {
});
this.antennasFetched = true;
}

return this.antennas;
}

Expand Down
12 changes: 6 additions & 6 deletions packages/backend/src/core/CaptchaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ export class CaptchaService {
secret,
response,
});

const res = await this.httpRequestService.send(url, {
method: 'POST',
body: params.toString(),
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
}, { throwErrorWhenResponseNotOk: false });

if (!res.ok) {
throw new Error(`${res.status}`);
}

return await res.json() as CaptchaResponse;
}
}

@bindThis
public async verifyRecaptcha(secret: string, response: string | null | undefined): Promise<void> {
if (response == null) {
Expand Down Expand Up @@ -73,7 +73,7 @@ export class CaptchaService {
if (response == null) {
throw new Error('turnstile-failed: no response provided');
}

const result = await this.getCaptchaResponse('https://challenges.cloudflare.com/turnstile/v0/siteverify', secret, response).catch(err => {
throw new Error(`turnstile-request-failed: ${err}`);
});
Expand Down
22 changes: 11 additions & 11 deletions packages/backend/src/core/CreateSystemUserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ export class CreateSystemUserService {
@bindThis
public async createSystemUser(username: string): Promise<User> {
const password = uuid();

// Generate hash of password
const salt = await bcrypt.genSalt(8);
const hash = await bcrypt.hash(password, salt);

// Generate secret
const secret = generateNativeUserToken();

const keyPair = await genRsaKeyPair(4096);

let account!: User;

// Start transaction
await this.db.transaction(async transactionalEntityManager => {
const exist = await transactionalEntityManager.findOneBy(User, {
usernameLower: username.toLowerCase(),
host: IsNull(),
});

if (exist) throw new Error('the user is already exists');

account = await transactionalEntityManager.insert(User, {
id: this.idService.genId(),
createdAt: new Date(),
Expand All @@ -58,25 +58,25 @@ export class CreateSystemUserService {
isExplorable: false,
isBot: true,
}).then(x => transactionalEntityManager.findOneByOrFail(User, x.identifiers[0]));

await transactionalEntityManager.insert(UserKeypair, {
publicKey: keyPair.publicKey,
privateKey: keyPair.privateKey,
userId: account.id,
});

await transactionalEntityManager.insert(UserProfile, {
userId: account.id,
autoAcceptFollowed: false,
password: hash,
});

await transactionalEntityManager.insert(UsedUsername, {
createdAt: new Date(),
username: username.toLowerCase(),
});
});

return account;
}
}
6 changes: 3 additions & 3 deletions packages/backend/src/core/CustomEmojiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class CustomEmojiService implements OnApplicationShutdown {

this.globalEventService.publishBroadcastStream('emojiAdded', {
emoji: updated,
});
});
}
}

Expand Down Expand Up @@ -194,7 +194,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
}

this.localEmojisCache.refresh();

this.globalEventService.publishBroadcastStream('emojiUpdated', {
emojis: await this.emojiEntityService.packDetailedMany(ids),
});
Expand All @@ -215,7 +215,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
emojis: await this.emojiEntityService.packDetailedMany(ids),
});
}

@bindThis
public async setLicenseBulk(ids: Emoji['id'][], license: string | null) {
await this.emojisRepository.update({
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/core/DeleteAccountService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export class DeleteAccountService {

// 物理削除する前にDelete activityを送信する
await this.userSuspendService.doPostSuspend(user).catch(e => {});

this.queueService.createDeleteAccountJob(user, {
soft: false,
});

await this.usersRepository.update(user.id, {
isDeleted: true,
});
Expand Down
Loading

0 comments on commit d847965

Please sign in to comment.