From 02c3ee12dcdc7187e83436c2d435cede6ce2eccb Mon Sep 17 00:00:00 2001 From: cuteBoiButt Date: Thu, 5 Sep 2024 17:29:03 +0000 Subject: [PATCH 01/19] Use proper logging facilities in WebfingerService --- packages/backend/src/core/WebfingerService.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/core/WebfingerService.ts b/packages/backend/src/core/WebfingerService.ts index 1517dd0074..86079a115b 100644 --- a/packages/backend/src/core/WebfingerService.ts +++ b/packages/backend/src/core/WebfingerService.ts @@ -8,6 +8,8 @@ import { Injectable } from '@nestjs/common'; import { XMLParser } from 'fast-xml-parser'; import { HttpRequestService } from '@/core/HttpRequestService.js'; import { bindThis } from '@/decorators.js'; +import Logger from '@/logger.js'; +import { RemoteLoggerService } from './RemoteLoggerService.js'; export type ILink = { href: string; @@ -28,9 +30,13 @@ const defaultProtocol = process.env.MISSKEY_WEBFINGER_USE_HTTP?.toLowerCase() == @Injectable() export class WebfingerService { + private logger: Logger; + constructor( private httpRequestService: HttpRequestService, + private remoteLoggerService: RemoteLoggerService, ) { + this.logger = this.remoteLoggerService.logger.createSubLogger('webfinger'); } @bindThis @@ -103,7 +109,7 @@ export class WebfingerService { const template = (hostMeta['XRD']['Link'] as Array).filter(p => p['@_rel'] === 'lrdd')[0]['@_template']; return template.indexOf('{uri}') < 0 ? null : template; } catch (err) { - console.error(`error while request host-meta for ${url}: ${err}`); + this.logger.error(`error while request host-meta for ${url}: ${err}`); return null; } } From 6b88c4f143716544b49817c0d93e2b972ede9edf Mon Sep 17 00:00:00 2001 From: cuteBoiButt Date: Fri, 6 Sep 2024 11:45:00 +0000 Subject: [PATCH 02/19] We don't need the whole Logger class here --- packages/backend/src/core/WebfingerService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/core/WebfingerService.ts b/packages/backend/src/core/WebfingerService.ts index 86079a115b..f57e7a2c1f 100644 --- a/packages/backend/src/core/WebfingerService.ts +++ b/packages/backend/src/core/WebfingerService.ts @@ -8,7 +8,7 @@ import { Injectable } from '@nestjs/common'; import { XMLParser } from 'fast-xml-parser'; import { HttpRequestService } from '@/core/HttpRequestService.js'; import { bindThis } from '@/decorators.js'; -import Logger from '@/logger.js'; +import type Logger from '@/logger.js'; import { RemoteLoggerService } from './RemoteLoggerService.js'; export type ILink = { From 75b4bacc3323e83bf69eb80d0cffa25ce27c592d Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 13 Sep 2024 19:57:21 +0100 Subject: [PATCH 03/19] bump develop version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1ffdcb091a..98f8e6925b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sharkey", - "version": "2024.8.1", + "version": "2024.9.0-dev", "codename": "shonk", "repository": { "type": "git", From 0a8cb21e9bec7bcf227f10ed2e5165231e9e50ad Mon Sep 17 00:00:00 2001 From: 4censord Date: Sun, 8 Sep 2024 11:47:57 +0200 Subject: [PATCH 04/19] Run eslint with caching This reduces the time for subsequent lints significantly. e.g. for `package/frontend`, the first run takes ~10min. With the cache, every subsequent run takes only a few seconds. --- .gitignore | 3 +++ packages/backend/package.json | 2 +- packages/frontend/package.json | 2 +- packages/megalodon/package.json | 2 +- packages/misskey-bubble-game/package.json | 2 +- packages/misskey-js/generator/package.json | 2 +- packages/misskey-js/package.json | 2 +- packages/misskey-reversi/package.json | 2 +- packages/sw/package.json | 2 +- 9 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index a8887eab92..758d36cea4 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,9 @@ packages/sw/.yarn/cache # pnpm .pnpm-store +# eslint +**/.eslintcache + # Cypress cypress/screenshots cypress/videos diff --git a/packages/backend/package.json b/packages/backend/package.json index ff84beec67..8f07f80911 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -20,7 +20,7 @@ "restart": "pnpm build && pnpm start", "dev": "node ./scripts/dev.mjs", "typecheck": "pnpm --filter megalodon build && tsc --noEmit && tsc -p test --noEmit", - "eslint": "eslint --quiet \"src/**/*.ts\"", + "eslint": "eslint --quiet \"src/**/*.ts\" --cache", "lint": "pnpm typecheck && pnpm eslint", "jest": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --forceExit --config jest.config.unit.cjs", "jest:e2e": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --forceExit --config jest.config.e2e.cjs", diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 35cb900d3b..5da671b9b6 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -13,7 +13,7 @@ "test": "vitest --run --globals", "test-and-coverage": "vitest --run --coverage --globals", "typecheck": "vue-tsc --noEmit", - "eslint": "eslint --quiet \"src/**/*.{ts,vue}\"", + "eslint": "eslint --quiet \"src/**/*.{ts,vue}\" --cache", "lint": "pnpm typecheck && pnpm eslint" }, "dependencies": { diff --git a/packages/megalodon/package.json b/packages/megalodon/package.json index 01c5c1147c..dbb5686af2 100644 --- a/packages/megalodon/package.json +++ b/packages/megalodon/package.json @@ -6,7 +6,7 @@ "typings": "./lib/src/index.d.ts", "scripts": { "build": "tsc -p ./", - "lint": "eslint --ext .js,.ts src", + "lint": "eslint --ext .js,.ts src --cache", "doc": "typedoc --out ../docs ./src", "test": "NODE_ENV=test jest -u --maxWorkers=3" }, diff --git a/packages/misskey-bubble-game/package.json b/packages/misskey-bubble-game/package.json index 528eb00b74..acd6ab9dd2 100644 --- a/packages/misskey-bubble-game/package.json +++ b/packages/misskey-bubble-game/package.json @@ -17,7 +17,7 @@ "scripts": { "build": "node ./build.js", "watch": "nodemon -w package.json -e json --exec \"node ./build.js --watch\"", - "eslint": "eslint './**/*.{js,jsx,ts,tsx}'", + "eslint": "eslint './**/*.{js,jsx,ts,tsx}' --cache", "typecheck": "tsc --noEmit", "lint": "pnpm typecheck && pnpm eslint" }, diff --git a/packages/misskey-js/generator/package.json b/packages/misskey-js/generator/package.json index 4a02bcd8ff..f9bd0a4e5d 100644 --- a/packages/misskey-js/generator/package.json +++ b/packages/misskey-js/generator/package.json @@ -4,7 +4,7 @@ "description": "Misskey TypeGenerator", "type": "module", "scripts": { - "generate": "tsx src/generator.ts && eslint ./built/**/*.ts --fix" + "generate": "tsx src/generator.ts && eslint ./built/**/*.ts --fix --cache" }, "devDependencies": { "@readme/openapi-parser": "2.5.0", diff --git a/packages/misskey-js/package.json b/packages/misskey-js/package.json index 39e687d4af..5ba4b93411 100644 --- a/packages/misskey-js/package.json +++ b/packages/misskey-js/package.json @@ -22,7 +22,7 @@ "tsd": "tsd", "api": "pnpm api-extractor run --local --verbose", "api-prod": "pnpm api-extractor run --verbose", - "eslint": "eslint './**/*.{js,jsx,ts,tsx}'", + "eslint": "eslint './**/*.{js,jsx,ts,tsx}' --cache", "typecheck": "tsc --noEmit", "lint": "pnpm typecheck && pnpm eslint", "jest": "jest --coverage --detectOpenHandles", diff --git a/packages/misskey-reversi/package.json b/packages/misskey-reversi/package.json index c6db6e6221..f32b31d4d9 100644 --- a/packages/misskey-reversi/package.json +++ b/packages/misskey-reversi/package.json @@ -17,7 +17,7 @@ "scripts": { "build": "node ./build.js", "watch": "nodemon -w package.json -e json --exec \"node ./build.js --watch\"", - "eslint": "eslint './**/*.{js,jsx,ts,tsx}'", + "eslint": "eslint './**/*.{js,jsx,ts,tsx}' --cache", "typecheck": "tsc --noEmit", "lint": "pnpm typecheck && pnpm eslint" }, diff --git a/packages/sw/package.json b/packages/sw/package.json index 9174f50ae3..081f648f8a 100644 --- a/packages/sw/package.json +++ b/packages/sw/package.json @@ -5,7 +5,7 @@ "watch": "nodemon -w ../../package.json -e json --exec \"node build.js watch\"", "build": "node build.js", "typecheck": "tsc --noEmit", - "eslint": "eslint --quiet src/**/*.ts", + "eslint": "eslint --quiet src/**/*.ts --cache", "lint": "pnpm typecheck && pnpm eslint" }, "dependencies": { From bd586c86ecec81836b860dbd71d13700665e099c Mon Sep 17 00:00:00 2001 From: Esurio Date: Sat, 14 Sep 2024 16:41:31 +0900 Subject: [PATCH 05/19] fix: use i18n in SkSearchResultWindow --- packages/frontend/src/components/SkSearchResultWindow.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/components/SkSearchResultWindow.vue b/packages/frontend/src/components/SkSearchResultWindow.vue index 474b0d54e7..2938fdcd66 100644 --- a/packages/frontend/src/components/SkSearchResultWindow.vue +++ b/packages/frontend/src/components/SkSearchResultWindow.vue @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -18,6 +18,7 @@ import { } from 'vue'; import type { Paging } from '@/components/MkPagination.vue'; import MkNotes from '@/components/MkNotes.vue'; import MkWindow from '@/components/MkWindow.vue'; +import { i18n } from '@/i18n.js'; const props = defineProps<{ noteKey: string | number | symbol | undefined; From b7815df1343a5858dfe7037acfabf5e962516e17 Mon Sep 17 00:00:00 2001 From: Marie Date: Sun, 15 Sep 2024 20:04:29 +0200 Subject: [PATCH 06/19] upd: fetch sponsors from OC --- .../src/server/api/endpoints/sponsors.ts | 33 +++++++++---------- packages/frontend/src/pages/about-sharkey.vue | 8 ++--- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/sponsors.ts b/packages/backend/src/server/api/endpoints/sponsors.ts index b6ccb9b2f9..67712ca379 100644 --- a/packages/backend/src/server/api/endpoints/sponsors.ts +++ b/packages/backend/src/server/api/endpoints/sponsors.ts @@ -10,7 +10,7 @@ import { DI } from '@/di-symbols.js'; export const meta = { tags: ['meta'], - description: 'Get Sharkey GH Sponsors', + description: 'Get Sharkey Sponsors', requireCredential: false, requireCredentialPrivateMode: false, @@ -30,29 +30,28 @@ export default class extends Endpoint { // eslint- @Inject(DI.redis) private redisClient: Redis.Redis, ) { super(meta, paramDef, async (ps, me) => { - let sponsors; - const cachedSponsors = await this.redisClient.get('sponsors'); + let totalSponsors; + const cachedSponsors = await this.redisClient.get('sponsors'); + if (!ps.forceUpdate && cachedSponsors) { - sponsors = JSON.parse(cachedSponsors); + totalSponsors = JSON.parse(cachedSponsors); } else { - AbortSignal.timeout ??= function timeout(ms) { - const ctrl = new AbortController(); - setTimeout(() => ctrl.abort(), ms); - return ctrl.signal; - }; - try { - sponsors = await fetch('https://kaifa.ch/transfem-sponsors.json', { signal: AbortSignal.timeout(2000) }) - .then((response) => response.json()); + const backers = await fetch('https://opencollective.com/sharkey/tiers/backer/all.json').then((response) => response.json()); + const sponsorsOC = await fetch('https://opencollective.com/sharkey/tiers/sponsor/all.json').then((response) => response.json()); - await this.redisClient.set('sponsors', JSON.stringify(sponsors), 'EX', 3600); + // Merge both together into one array and make sure it only has Active subscriptions + const allSponsors = [...backers, ...sponsorsOC].filter(sponsor => sponsor.isActive == true); + + // Remove possible duplicates + totalSponsors = [...new Map(allSponsors.map(v => [v.profile, v])).values()]; + + await this.redisClient.set('sponsors', JSON.stringify(totalSponsors), 'EX', 3600); } catch (error) { - sponsors = { - sponsors: [], - }; + totalSponsors = []; } } - return { sponsor_data: sponsors['sponsors'] }; + return { sponsor_data: totalSponsors }; }); } } diff --git a/packages/frontend/src/pages/about-sharkey.vue b/packages/frontend/src/pages/about-sharkey.vue index 2d1a3111c2..938786949c 100644 --- a/packages/frontend/src/pages/about-sharkey.vue +++ b/packages/frontend/src/pages/about-sharkey.vue @@ -170,9 +170,9 @@ SPDX-License-Identifier: AGPL-3.0-only :key="sponsor" style="margin-bottom: 0.5rem;" > - - - {{ sponsor.details.name }} + + + {{ sponsor.name }} @@ -209,7 +209,7 @@ const easterEggEngine = ref(null); const sponsors = ref([]); const containerEl = shallowRef(); -await misskeyApi('sponsors', { forceUpdate: true }).then((res) => sponsors.value.push(res.sponsor_data)); +await misskeyApi('sponsors', { forceUpdate: false }).then((res) => sponsors.value.push(res.sponsor_data)); function iconLoaded() { const emojis = defaultStore.state.reactions; From 2e18359dadff0d6d26710b6275c7dffb1cbefbc0 Mon Sep 17 00:00:00 2001 From: Marie Date: Sun, 15 Sep 2024 18:17:35 +0000 Subject: [PATCH 07/19] chore: lint --- packages/backend/src/server/api/endpoints/sponsors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/endpoints/sponsors.ts b/packages/backend/src/server/api/endpoints/sponsors.ts index 67712ca379..06c3c0d620 100644 --- a/packages/backend/src/server/api/endpoints/sponsors.ts +++ b/packages/backend/src/server/api/endpoints/sponsors.ts @@ -41,7 +41,7 @@ export default class extends Endpoint { // eslint- const sponsorsOC = await fetch('https://opencollective.com/sharkey/tiers/sponsor/all.json').then((response) => response.json()); // Merge both together into one array and make sure it only has Active subscriptions - const allSponsors = [...backers, ...sponsorsOC].filter(sponsor => sponsor.isActive == true); + const allSponsors = [...backers, ...sponsorsOC].filter(sponsor => sponsor.isActive === true); // Remove possible duplicates totalSponsors = [...new Map(allSponsors.map(v => [v.profile, v])).values()]; From 62a81bed9b76dda5e30b0a2ae8aff98c48830712 Mon Sep 17 00:00:00 2001 From: Marie Date: Mon, 16 Sep 2024 19:02:06 +0200 Subject: [PATCH 08/19] upd: change sorting of supporters --- packages/backend/src/server/api/endpoints/sponsors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/endpoints/sponsors.ts b/packages/backend/src/server/api/endpoints/sponsors.ts index 06c3c0d620..99414e739a 100644 --- a/packages/backend/src/server/api/endpoints/sponsors.ts +++ b/packages/backend/src/server/api/endpoints/sponsors.ts @@ -41,7 +41,7 @@ export default class extends Endpoint { // eslint- const sponsorsOC = await fetch('https://opencollective.com/sharkey/tiers/sponsor/all.json').then((response) => response.json()); // Merge both together into one array and make sure it only has Active subscriptions - const allSponsors = [...backers, ...sponsorsOC].filter(sponsor => sponsor.isActive === true); + const allSponsors = [...sponsorsOC, ...backers].filter(sponsor => sponsor.isActive === true); // Remove possible duplicates totalSponsors = [...new Map(allSponsors.map(v => [v.profile, v])).values()]; From cc51f7038e35003ccb0807dc9a6218ca0699200f Mon Sep 17 00:00:00 2001 From: Esurio Date: Thu, 19 Sep 2024 12:37:56 +0000 Subject: [PATCH 09/19] fix: use i18n in settings --- locales/en-US.yml | 3 +++ locales/index.d.ts | 12 ++++++++++++ locales/ja-JP.yml | 3 +++ packages/frontend/src/pages/settings/general.vue | 6 +++--- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index 58712657e8..6d24bb5b41 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -776,6 +776,7 @@ noCrawleDescription: "Ask search engines to not index your profile page, notes, lockedAccountInfo: "Unless you set your note visiblity to \"Followers only\", your notes will be visible to anyone, even if you require followers to be manually approved." alwaysMarkSensitive: "Mark as sensitive by default" loadRawImages: "Load original images instead of showing thumbnails" +showTickerOnReplies: "Show instance ticker on replies" searchEngine: "Search Engine For Search MFM" searchEngineOther: "Other" searchEngineCustomURIDescription: "The custom URI must be input in the format like \"https://www.google.com/search?q=\\{query}\" or \"https://www.google.com/search?q=%s\"." @@ -1089,6 +1090,8 @@ collapseRenotes: "Collapse boosts you've already seen" collapseRenotesDescription: "Collapse boosts that you have boosted or reacted to" collapseNotesRepliedTo: "Collapse notes replied to" collapseFiles: "Collapse files" +uncollapseCW: "Uncollapse CWs on notes" +expandLongNote: "Always expand long notes" autoloadConversation: "Load conversation on replies" internalServerError: "Internal Server Error" internalServerErrorDescription: "The server has run into an unexpected error." diff --git a/locales/index.d.ts b/locales/index.d.ts index 55a95f8fd9..177a3c8160 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -3120,6 +3120,10 @@ export interface Locale extends ILocale { * 添付画像のサムネイルをオリジナル画質にする */ "loadRawImages": string; + /** + * 返信にサーバー情報を表示する + */ + "showTickerOnReplies": string; /** * 検索MFMの検索エンジン */ @@ -4373,6 +4377,14 @@ export interface Locale extends ILocale { * ファイルを折りたたむ */ "collapseFiles": string; + /** + * CWを展開する + */ + "uncollapseCW": string; + /** + * 長い投稿を常に展開する + */ + "expandLongNote": string; /** * 会話スレッドを自動で読み込む */ diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index da208147a1..b4d47a449c 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -776,6 +776,7 @@ noCrawleDescription: "外部の検索エンジンにあなたのユーザーペ lockedAccountInfo: "フォローを承認制にしても、ノートの公開範囲を「フォロワー」にしない限り、誰でもあなたのノートを見ることができます。" alwaysMarkSensitive: "デフォルトでメディアをセンシティブ設定にする" loadRawImages: "添付画像のサムネイルをオリジナル画質にする" +showTickerOnReplies: "返信にサーバー情報を表示する" searchEngine: "検索MFMの検索エンジン" searchEngineOther: "カスタム" searchEngineCustomURIDescription: "カスタム検索エンジンのURIは、\"https://www.google.com/search?q=\\{query}\" や \"https://www.google.com/search?q=%s\" のような形式で入力する必要があります。" @@ -1089,6 +1090,8 @@ collapseRenotes: "ブーストのスマート省略" collapseRenotesDescription: "リアクションやブーストをしたことがあるノートをたたんで表示します。" collapseNotesRepliedTo: "返信元のノートを折りたたむ" collapseFiles: "ファイルを折りたたむ" +uncollapseCW: "CWを展開する" +expandLongNote: "長い投稿を常に展開する" autoloadConversation: "会話スレッドを自動で読み込む" internalServerError: "サーバー内部エラー" internalServerErrorDescription: "サーバー内部で予期しないエラーが発生しました。" diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index 75afe67be7..637c1b24b9 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -56,8 +56,8 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.collapseNotesRepliedTo }} {{ i18n.ts.collapseFiles }} - Uncollapse CWs on notes - Always expand long notes + {{ i18n.ts.uncollapseCW }} + {{ i18n.ts.expandLongNote }} {{ i18n.ts.showNoteActionsOnlyHover }} {{ i18n.ts.showClipButtonInNoteFooter }} {{ i18n.ts.autoloadConversation }} @@ -67,7 +67,7 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.showReactionsCount }} {{ i18n.ts.showGapBetweenNotesInTimeline }} {{ i18n.ts.loadRawImages }} - Show instance ticker on replies + {{ i18n.ts.showTickerOnReplies }}