From abef030a247d1677a2429cc994056f124fc134b8 Mon Sep 17 00:00:00 2001 From: Michcio Date: Tue, 6 Sep 2022 23:18:15 +0200 Subject: [PATCH 001/152] build: Move resolutions sections to workspace package.json Yarn throws a warning on every `yarn install` that the resolutions from respective packages' manifests are ignored. --- package.json | 4 + packages/backend/package.json | 4 - packages/client/package.json | 4 - yarn.lock | 145 ++-------------------------------- 4 files changed, 12 insertions(+), 145 deletions(-) diff --git a/package.json b/package.json index 2433eacb5..96ee5e71a 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,10 @@ "clean-all": "yarn workspaces foreach run clean-all && rm -rf built/ node_modules/", "cleanall": "yarn clean-all" }, + "resolutions": { + "chokidar": "^3.3.1", + "lodash": "^4.17.21" + }, "dependencies": { "execa": "5.1.1", "gulp": "4.0.2", diff --git a/packages/backend/package.json b/packages/backend/package.json index d42f83f4a..878f54593 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -16,10 +16,6 @@ "start:test": "cross-env NODE_ENV=test node --experimental-json-modules ./built/index.js", "test": "npm run mocha" }, - "resolutions": { - "chokidar": "^3.3.1", - "lodash": "^4.17.21" - }, "dependencies": { "@bull-board/api": "^4.2.2", "@bull-board/koa": "4.0.0", diff --git a/packages/client/package.json b/packages/client/package.json index a50ebfd67..5c041a3bf 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -9,10 +9,6 @@ "clean": "rm -rf built/", "clean-all": "yarn clean && rm -rf node_modules/" }, - "resolutions": { - "chokidar": "^3.3.1", - "lodash": "^4.17.21" - }, "dependencies": { "@discordapp/twemoji": "14.0.2", "@fortawesome/fontawesome-free": "6.1.1", diff --git a/yarn.lock b/yarn.lock index 7c48ae565..5bd65edf3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3041,7 +3041,7 @@ __metadata: languageName: node linkType: hard -"anymatch@npm:^3.0.3, anymatch@npm:~3.1.2": +"anymatch@npm:^3.0.3": version: 3.1.2 resolution: "anymatch@npm:3.1.2" dependencies: @@ -3368,13 +3368,6 @@ __metadata: languageName: node linkType: hard -"async-each@npm:^1.0.1": - version: 1.0.3 - resolution: "async-each@npm:1.0.3" - checksum: 868651cfeb209970b367fbb96df1e1c8dc0b22c681cda7238417005ab2a5fbd944ee524b43f2692977259a57b7cc2547e03ff68f2b5113dbdf953d48cc078dc3 - languageName: node - linkType: hard - "async-settle@npm:^1.0.0": version: 1.0.0 resolution: "async-settle@npm:1.0.0" @@ -3846,13 +3839,6 @@ __metadata: languageName: node linkType: hard -"binary-extensions@npm:^1.0.0": - version: 1.13.1 - resolution: "binary-extensions@npm:1.13.1" - checksum: ad7747f33c07e94ba443055de130b50c8b8b130a358bca064c580d91769ca6a69c7ac65ca008ff044ed4541d2c6ad45496e1fadbef5218a68770996b6a2194d7 - languageName: node - linkType: hard - "binary-extensions@npm:^2.0.0": version: 2.0.0 resolution: "binary-extensions@npm:2.0.0" @@ -3877,15 +3863,6 @@ __metadata: languageName: node linkType: hard -"bindings@npm:^1.5.0": - version: 1.5.0 - resolution: "bindings@npm:1.5.0" - dependencies: - file-uri-to-path: 1.0.0 - checksum: 65b6b48095717c2e6105a021a7da4ea435aa8d3d3cd085cb9e85bcb6e5773cf318c4745c3f7c504412855940b585bdf9b918236612a1c7a7942491de176f1ae7 - languageName: node - linkType: hard - "bl@npm:^4.0.3": version: 4.1.0 resolution: "bl@npm:4.1.0" @@ -3958,7 +3935,7 @@ __metadata: languageName: node linkType: hard -"braces@npm:^2.3.1, braces@npm:^2.3.2": +"braces@npm:^2.3.1": version: 2.3.2 resolution: "braces@npm:2.3.2" dependencies: @@ -4544,26 +4521,7 @@ __metadata: languageName: node linkType: hard -"chokidar@npm:3.5.3, chokidar@npm:^3.5.3": - version: 3.5.3 - resolution: "chokidar@npm:3.5.3" - dependencies: - anymatch: ~3.1.2 - braces: ~3.0.2 - fsevents: ~2.3.2 - glob-parent: ~5.1.2 - is-binary-path: ~2.1.0 - is-glob: ~4.0.1 - normalize-path: ~3.0.0 - readdirp: ~3.6.0 - dependenciesMeta: - fsevents: - optional: true - checksum: b49fcde40176ba007ff361b198a2d35df60d9bb2a5aab228279eb810feae9294a6b4649ab15981304447afe1e6ffbf4788ad5db77235dc770ab777c6e771980c - languageName: node - linkType: hard - -"chokidar@npm:>=3.0.0 <4.0.0, chokidar@npm:^3.3.1": +"chokidar@npm:^3.3.1": version: 3.3.1 resolution: "chokidar@npm:3.3.1" dependencies: @@ -4582,29 +4540,6 @@ __metadata: languageName: node linkType: hard -"chokidar@npm:^2.0.0": - version: 2.1.8 - resolution: "chokidar@npm:2.1.8" - dependencies: - anymatch: ^2.0.0 - async-each: ^1.0.1 - braces: ^2.3.2 - fsevents: ^1.2.7 - glob-parent: ^3.1.0 - inherits: ^2.0.3 - is-binary-path: ^1.0.0 - is-glob: ^4.0.0 - normalize-path: ^3.0.0 - path-is-absolute: ^1.0.0 - readdirp: ^2.2.1 - upath: ^1.1.1 - dependenciesMeta: - fsevents: - optional: true - checksum: 0c43e89cbf0268ef1e1f41ce8ec5233c7ba022c6f3282c2ef6530e351d42396d389a1148c5a040f291cf1f4083a4c6b2f51dad3f31c726442ea9a337de316bcf - languageName: node - linkType: hard - "chownr@npm:^1.1.1": version: 1.1.4 resolution: "chownr@npm:1.1.4" @@ -7639,13 +7574,6 @@ __metadata: languageName: node linkType: hard -"file-uri-to-path@npm:1.0.0": - version: 1.0.0 - resolution: "file-uri-to-path@npm:1.0.0" - checksum: b648580bdd893a008c92c7ecc96c3ee57a5e7b6c4c18a9a09b44fb5d36d79146f8e442578bc0e173dc027adf3987e254ba1dfd6e3ec998b7c282873010502144 - languageName: node - linkType: hard - "filelist@npm:^1.0.1": version: 1.0.4 resolution: "filelist@npm:1.0.4" @@ -8030,17 +7958,6 @@ __metadata: languageName: node linkType: hard -"fsevents@npm:^1.2.7": - version: 1.2.13 - resolution: "fsevents@npm:1.2.13" - dependencies: - bindings: ^1.5.0 - nan: ^2.12.1 - checksum: ae855aa737aaa2f9167e9f70417cf6e45a5cd11918e1fee9923709a0149be52416d765433b4aeff56c789b1152e718cd1b13ddec6043b78cdda68260d86383c1 - conditions: os=darwin - languageName: node - linkType: hard - "fsevents@npm:^2.3.2, fsevents@npm:~2.3.2": version: 2.3.2 resolution: "fsevents@npm:2.3.2" @@ -8061,16 +7978,6 @@ __metadata: languageName: node linkType: hard -"fsevents@patch:fsevents@^1.2.7#~builtin": - version: 1.2.13 - resolution: "fsevents@patch:fsevents@npm%3A1.2.13#~builtin::version=1.2.13&hash=18f3a7" - dependencies: - bindings: ^1.5.0 - nan: ^2.12.1 - conditions: os=darwin - languageName: node - linkType: hard - "fsevents@patch:fsevents@^2.3.2#~builtin, fsevents@patch:fsevents@~2.3.2#~builtin": version: 2.3.2 resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7" @@ -8287,7 +8194,7 @@ __metadata: languageName: node linkType: hard -"glob-parent@npm:^5.1.2, glob-parent@npm:~5.1.2": +"glob-parent@npm:^5.1.2": version: 5.1.2 resolution: "glob-parent@npm:5.1.2" dependencies: @@ -9383,15 +9290,6 @@ __metadata: languageName: node linkType: hard -"is-binary-path@npm:^1.0.0": - version: 1.0.1 - resolution: "is-binary-path@npm:1.0.1" - dependencies: - binary-extensions: ^1.0.0 - checksum: a803c99e9d898170c3b44a86fbdc0736d3d7fcbe737345433fb78e810b9fe30c982657782ad0e676644ba4693ddf05601a7423b5611423218663d6b533341ac9 - languageName: node - linkType: hard - "is-binary-path@npm:~2.1.0": version: 2.1.0 resolution: "is-binary-path@npm:2.1.0" @@ -11509,7 +11407,7 @@ __metadata: languageName: node linkType: hard -"lodash@npm:^4.17.11, lodash@npm:^4.17.21, lodash@npm:^4.7.0, lodash@npm:~4.17.15": +"lodash@npm:^4.17.21": version: 4.17.21 resolution: "lodash@npm:4.17.21" checksum: eb835a2e51d381e561e508ce932ea50a8e5a68f4ebdd771ea240d3048244a8d13658acbd502cd4829768c56f2e16bdd4340b9ea141297d472517b83868e677f7 @@ -11779,7 +11677,7 @@ __metadata: languageName: node linkType: hard -"micromatch@npm:^3.0.4, micromatch@npm:^3.1.10, micromatch@npm:^3.1.4": +"micromatch@npm:^3.0.4, micromatch@npm:^3.1.4": version: 3.1.10 resolution: "micromatch@npm:3.1.10" dependencies: @@ -12228,7 +12126,7 @@ __metadata: languageName: node linkType: hard -"nan@npm:^2.12.1, nan@npm:^2.16.0": +"nan@npm:^2.16.0": version: 2.16.0 resolution: "nan@npm:2.16.0" dependencies: @@ -13325,7 +13223,7 @@ __metadata: languageName: node linkType: hard -"picomatch@npm:^2.2.1, picomatch@npm:^2.2.2, picomatch@npm:^2.3.1": +"picomatch@npm:^2.2.2, picomatch@npm:^2.3.1": version: 2.3.1 resolution: "picomatch@npm:2.3.1" checksum: 050c865ce81119c4822c45d3c84f1ced46f93a0126febae20737bd05ca20589c564d6e9226977df859ed5e03dc73f02584a2b0faad36e896936238238b0446cf @@ -14474,17 +14372,6 @@ __metadata: languageName: node linkType: hard -"readdirp@npm:^2.2.1": - version: 2.2.1 - resolution: "readdirp@npm:2.2.1" - dependencies: - graceful-fs: ^4.1.11 - micromatch: ^3.1.10 - readable-stream: ^2.0.2 - checksum: 3879b20f1a871e0e004a14fbf1776e65ee0b746a62f5a416010808b37c272ac49b023c47042c7b1e281cba75a449696635bc64c397ed221ea81d853a8f2ed79a - languageName: node - linkType: hard - "readdirp@npm:~3.3.0": version: 3.3.0 resolution: "readdirp@npm:3.3.0" @@ -14494,15 +14381,6 @@ __metadata: languageName: node linkType: hard -"readdirp@npm:~3.6.0": - version: 3.6.0 - resolution: "readdirp@npm:3.6.0" - dependencies: - picomatch: ^2.2.1 - checksum: 1ced032e6e45670b6d7352d71d21ce7edf7b9b928494dcaba6f11fba63180d9da6cd7061ebc34175ffda6ff529f481818c962952004d273178acd70f7059b320 - languageName: node - linkType: hard - "rechoir@npm:^0.6.2": version: 0.6.2 resolution: "rechoir@npm:0.6.2" @@ -17184,13 +17062,6 @@ __metadata: languageName: node linkType: hard -"upath@npm:^1.1.1": - version: 1.2.0 - resolution: "upath@npm:1.2.0" - checksum: 4c05c094797cb733193a0784774dbea5b1889d502fc9f0572164177e185e4a59ba7099bf0b0adf945b232e2ac60363f9bf18aac9b2206fb99cbef971a8455445 - languageName: node - linkType: hard - "update-browserslist-db@npm:^1.0.5": version: 1.0.5 resolution: "update-browserslist-db@npm:1.0.5" From 026941ce776876cc328b005eeb73a55146d380fc Mon Sep 17 00:00:00 2001 From: Michcio Date: Tue, 6 Sep 2022 23:24:23 +0200 Subject: [PATCH 002/152] sw: Remove fetch handler from service worker In current state, service worker overloads every "connection error" kind of reaction to a plaintext 200 saying "Offline.", which leads to terribly undebuggable situations as the browser decides to cache this as an image, and then someone's pfp is broken literally forever unless you Ctrl+Shift+R every time you reload frontend. This change removes the handler, because it is unclear how we even benefit from it being there. --- packages/sw/src/sw.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/sw/src/sw.ts b/packages/sw/src/sw.ts index 0ba6a6e4a..cc9fabdf1 100644 --- a/packages/sw/src/sw.ts +++ b/packages/sw/src/sw.ts @@ -23,13 +23,6 @@ self.addEventListener('activate', ev => { ); }); -self.addEventListener('fetch', ev => { - ev.respondWith( - fetch(ev.request) - .catch(() => new Response(`Offline. Service Worker @${_VERSION_}`, { status: 200 })) - ); -}); - self.addEventListener('push', ev => { // クライアント取得 ev.waitUntil(self.clients.matchAll({ From 7b4ebd27157d906e22f40cb44c63b18573e3a870 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Tue, 6 Sep 2022 14:50:48 -0400 Subject: [PATCH 003/152] backend: remove room data from user Rooms were remove a while back in upstream Misskey. This removes the associated data left over in the database. Changelog: Removed --- .../backend/migration/1662489803045-remove-rooms.js | 11 +++++++++++ packages/backend/src/models/entities/user-profile.ts | 7 ------- 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 packages/backend/migration/1662489803045-remove-rooms.js diff --git a/packages/backend/migration/1662489803045-remove-rooms.js b/packages/backend/migration/1662489803045-remove-rooms.js new file mode 100644 index 000000000..77ea85bac --- /dev/null +++ b/packages/backend/migration/1662489803045-remove-rooms.js @@ -0,0 +1,11 @@ +export class removeRooms1662489803045 { + name = 'removeRooms1662489803045' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "room"`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "user_profile" ADD "room" jsonb NOT NULL DEFAULT '{}'`); + } +} diff --git a/packages/backend/src/models/entities/user-profile.ts b/packages/backend/src/models/entities/user-profile.ts index 251b998be..224bbe3cd 100644 --- a/packages/backend/src/models/entities/user-profile.ts +++ b/packages/backend/src/models/entities/user-profile.ts @@ -124,13 +124,6 @@ export class UserProfile { }) public clientData: Record; - // TODO: そのうち消す - @Column('jsonb', { - default: {}, - comment: 'The room data of the User.', - }) - public room: Record; - @Column('boolean', { default: false, }) From f94ed5e8a6f7227c9bcdbba1d1c9459ce50a793a Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Tue, 6 Sep 2022 14:51:20 -0400 Subject: [PATCH 004/152] foundkey-js: remove room api endpoints Changelog: Removed --- packages/foundkey-js/src/api.types.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/foundkey-js/src/api.types.ts b/packages/foundkey-js/src/api.types.ts index 2a08af7d6..8f81fc2d1 100644 --- a/packages/foundkey-js/src/api.types.ts +++ b/packages/foundkey-js/src/api.types.ts @@ -544,10 +544,6 @@ export type Endpoints = { // reset-password 'reset-password': { req: { token: string; password: string; }; res: null; }; - // room - 'room/show': { req: TODO; res: TODO; }; - 'room/update': { req: TODO; res: TODO; }; - // stats 'stats': { req: NoParams; res: Stats; }; From 3bdbbcadd9772818c00339faa17e0f4a71dda6bc Mon Sep 17 00:00:00 2001 From: Johann150 Date: Wed, 24 Aug 2022 23:16:53 +0200 Subject: [PATCH 005/152] adjust MFM to HTML conversion Removed the misc/get-note-html module which was only used in one place. Instead of it, the general MFM to HTML functionality has been improved to take care of the use cases of that module as well. Co-authored-by: Francis Dinh --- packages/backend/src/mfm/to-html.ts | 45 +++++++++++++------ .../remote/activitypub/misc/get-note-html.ts | 8 ---- .../src/remote/activitypub/renderer/note.ts | 8 ++-- .../src/remote/activitypub/renderer/person.ts | 3 +- 4 files changed, 35 insertions(+), 29 deletions(-) delete mode 100644 packages/backend/src/remote/activitypub/misc/get-note-html.ts diff --git a/packages/backend/src/mfm/to-html.ts b/packages/backend/src/mfm/to-html.ts index b1429f184..af399e81f 100644 --- a/packages/backend/src/mfm/to-html.ts +++ b/packages/backend/src/mfm/to-html.ts @@ -1,17 +1,29 @@ import { JSDOM } from 'jsdom'; import * as mfm from 'mfm-js'; import config from '@/config/index.js'; +import { UserProfiles } from '@/models/index.js'; +import { extractMentions } from '@/misc/extract-mentions.js'; import { intersperse } from '@/prelude/array.js'; -import { IMentionedRemoteUsers } from '@/models/entities/note.js'; -export function toHtml(nodes: mfm.MfmNode[] | null, mentionedRemoteUsers: IMentionedRemoteUsers = []) { +// Transforms MFM to HTML, given the MFM text and a list of user IDs that are +// mentioned in the text. If the list of mentions is not given, all mentions +// from the text will be extracted. +export async function toHtml(mfmText: string, mentions?: string[]): string | null { + const nodes = mfm.parse(mfmText); if (nodes == null) { return null; } - const { window } = new JSDOM(''); + const mentionedUsers = await UserProfiles.createQueryBuilder("user_profiles") + .leftJoin('user_profile.user', 'user') + .select('user.username') + .addSelect('user.host') + // links should preferably use user friendly urls, only fall back to AP ids + .addSelect('COALESCE(user_profile.url, user.uri)', 'url') + .where('userId IN (:...ids)', { ids: mentions ?? extractMentions(nodes) }) + .getManyRaw(); - const doc = window.document; + const doc = new JSDOM('').window.document; function appendChildren(children: mfm.MfmNode[], targetElement: any): void { if (children) { @@ -106,18 +118,23 @@ export function toHtml(nodes: mfm.MfmNode[] | null, mentionedRemoteUsers: IMenti }, mention(node) { - // Mastodon microformat: span.h-card > a.u-url.mention - const a = doc.createElement('a'); const { username, host, acct } = node.props; - const remoteUserInfo = mentionedRemoteUsers.find(remoteUser => remoteUser.username === username && remoteUser.host === host); - a.href = remoteUserInfo?.url ?? remoteUserInfo?.uri ?? `${config.url}/${acct}`; - a.className = 'u-url mention'; - a.textContent = acct; + const userInfo = mentionedUsers.find(user => user.username === username && user.host === host); + if (userInfo != null) { + // Mastodon microformat: span.h-card > a.u-url.mention + const a = doc.createElement('a'); + a.href = userInfo.url ?? `${config.url}/${acct}`; + a.className = 'u-url mention'; + a.textContent = acct; - const card = doc.createElement('span'); - card.className = 'h-card'; - card.appendChild(a); - return card; + const card = doc.createElement('span'); + card.className = 'h-card'; + card.appendChild(a); + return card; + } else { + // this user does not actually exist + return doc.createTextNode(acct); + } }, quote(node) { diff --git a/packages/backend/src/remote/activitypub/misc/get-note-html.ts b/packages/backend/src/remote/activitypub/misc/get-note-html.ts deleted file mode 100644 index 389039ebe..000000000 --- a/packages/backend/src/remote/activitypub/misc/get-note-html.ts +++ /dev/null @@ -1,8 +0,0 @@ -import * as mfm from 'mfm-js'; -import { Note } from '@/models/entities/note.js'; -import { toHtml } from '../../../mfm/to-html.js'; - -export default function(note: Note) { - if (!note.text) return ''; - return toHtml(mfm.parse(note.text), JSON.parse(note.mentionedRemoteUsers)); -} diff --git a/packages/backend/src/remote/activitypub/renderer/note.ts b/packages/backend/src/remote/activitypub/renderer/note.ts index f705aabac..e662c0e92 100644 --- a/packages/backend/src/remote/activitypub/renderer/note.ts +++ b/packages/backend/src/remote/activitypub/renderer/note.ts @@ -5,7 +5,7 @@ import { DriveFile } from '@/models/entities/drive-file.js'; import { DriveFiles, Notes, Users, Emojis, Polls } from '@/models/index.js'; import { Emoji } from '@/models/entities/emoji.js'; import { Poll } from '@/models/entities/poll.js'; -import toHtml from '../misc/get-note-html.js'; +import { toHtml } from '@/mfm/to-html.js'; import renderEmoji from './emoji.js'; import renderMention from './mention.js'; import renderHashtag from './hashtag.js'; @@ -97,9 +97,7 @@ export default async function renderNote(note: Note, dive = true, isTalk = false const summary = note.cw === '' ? String.fromCharCode(0x200B) : note.cw; - const content = toHtml(Object.assign({}, note, { - text: apText, - })); + const content = await toHtml(apText, note.mentions); const emojis = await getEmojis(note.emojis); const apemojis = emojis.map(emoji => renderEmoji(emoji)); @@ -112,7 +110,7 @@ export default async function renderNote(note: Note, dive = true, isTalk = false const asPoll = poll ? { type: 'Question', - content: toHtml(Object.assign({}, note, { text })), + content: await toHtml(text, note.mentions), [poll.expiresAt && poll.expiresAt < new Date() ? 'closed' : 'endTime']: poll.expiresAt, [poll.multiple ? 'anyOf' : 'oneOf']: poll.choices.map((text, i) => ({ type: 'Note', diff --git a/packages/backend/src/remote/activitypub/renderer/person.ts b/packages/backend/src/remote/activitypub/renderer/person.ts index 213741143..7de957882 100644 --- a/packages/backend/src/remote/activitypub/renderer/person.ts +++ b/packages/backend/src/remote/activitypub/renderer/person.ts @@ -1,5 +1,4 @@ import { URL } from 'node:url'; -import * as mfm from 'mfm-js'; import config from '@/config/index.js'; import { ILocalUser } from '@/models/entities/user.js'; import { toHtml } from '@/mfm/to-html.js'; @@ -66,7 +65,7 @@ export async function renderPerson(user: ILocalUser) { url: `${config.url}/@${user.username}`, preferredUsername: user.username, name: user.name, - summary: profile.description ? toHtml(mfm.parse(profile.description)) : null, + summary: profile.description ? await toHtml(profile.description) : null, icon: avatar ? renderImage(avatar) : null, image: banner ? renderImage(banner) : null, tag, From 7a981de88331de83152fe0224f9332fffe8a43bb Mon Sep 17 00:00:00 2001 From: Johann150 Date: Wed, 24 Aug 2022 23:57:34 +0200 Subject: [PATCH 006/152] refactor: remove note.mentionedRemoteUsers column The column mentionedRemoteUsers on the note table in the database is firstly in the wrong type since it contains JSON data but is typed as text. Secondly it seems redundant, since that data can be acquired by using the note.mentions column to fetch the respective data instead. Co-authored-by: Francis Dinh --- ...00-remove-mentioned-remote-users-column.js | 12 ++++++++++ packages/backend/src/models/entities/note.ts | 12 ---------- .../src/remote/activitypub/renderer/note.ts | 23 +++++++++++-------- .../backend/src/services/messages/create.ts | 5 ---- packages/backend/src/services/note/create.ts | 12 +--------- packages/backend/src/services/note/delete.ts | 15 ++++++------ 6 files changed, 34 insertions(+), 45 deletions(-) create mode 100644 packages/backend/migration/1661376843000-remove-mentioned-remote-users-column.js diff --git a/packages/backend/migration/1661376843000-remove-mentioned-remote-users-column.js b/packages/backend/migration/1661376843000-remove-mentioned-remote-users-column.js new file mode 100644 index 000000000..42d79b5b5 --- /dev/null +++ b/packages/backend/migration/1661376843000-remove-mentioned-remote-users-column.js @@ -0,0 +1,12 @@ +export class removeMentionedRemoteUsersColumn1661376843000 { + name = 'removeMentionedRemoteUsersColumn1661376843000'; + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "note" DROP COLUMN "mentionedRemoteUsers"`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "note" ADD "mentionedRemoteUsers" TEXT NOT NULL DEFAULT '[]'::text`); + await queryRunner.query(`UPDATE "note" SET "mentionedRemoteUsers" = (SELECT COALESCE(json_agg(row_to_json("data"))::text, '[]') FROM (SELECT "url", "uri", "username", "host" FROM "user" JOIN "user_profile" ON "user"."id" = "user_profile". "userId" WHERE "user"."host" IS NOT NULL AND "user"."id" = ANY("note"."mentions")) AS "data")`); + } +} diff --git a/packages/backend/src/models/entities/note.ts b/packages/backend/src/models/entities/note.ts index ee7cbec43..d1e6b9f93 100644 --- a/packages/backend/src/models/entities/note.ts +++ b/packages/backend/src/models/entities/note.ts @@ -155,11 +155,6 @@ export class Note { }) public mentions: User['id'][]; - @Column('text', { - default: '[]', - }) - public mentionedRemoteUsers: string; - @Column('varchar', { length: 128, array: true, default: '{}', }) @@ -233,10 +228,3 @@ export class Note { } } } - -export type IMentionedRemoteUsers = { - uri: string; - url?: string; - username: string; - host: string; -}[]; diff --git a/packages/backend/src/remote/activitypub/renderer/note.ts b/packages/backend/src/remote/activitypub/renderer/note.ts index e662c0e92..1bcb5eae2 100644 --- a/packages/backend/src/remote/activitypub/renderer/note.ts +++ b/packages/backend/src/remote/activitypub/renderer/note.ts @@ -1,6 +1,6 @@ import { In, IsNull } from 'typeorm'; import config from '@/config/index.js'; -import { Note, IMentionedRemoteUsers } from '@/models/entities/note.js'; +import { Note } from '@/models/entities/note.js'; import { DriveFile } from '@/models/entities/drive-file.js'; import { DriveFiles, Notes, Users, Emojis, Polls } from '@/models/index.js'; import { Emoji } from '@/models/entities/emoji.js'; @@ -55,28 +55,31 @@ export default async function renderNote(note: Note, dive = true, isTalk = false const attributedTo = `${config.url}/users/${note.userId}`; - const mentions = (JSON.parse(note.mentionedRemoteUsers) as IMentionedRemoteUsers).map(x => x.uri); + const mentionedUsers = note.mentions.length > 0 ? await Users.findBy({ + id: In(note.mentions), + }) : []; + + const mentionUris = mentionedUsers + // only remote users + .filter(user => Users.isRemoteUser(user)) + .map(user => user.uri); let to: string[] = []; let cc: string[] = []; if (note.visibility === 'public') { to = ['https://www.w3.org/ns/activitystreams#Public']; - cc = [`${attributedTo}/followers`].concat(mentions); + cc = [`${attributedTo}/followers`].concat(mentionUris); } else if (note.visibility === 'home') { to = [`${attributedTo}/followers`]; - cc = ['https://www.w3.org/ns/activitystreams#Public'].concat(mentions); + cc = ['https://www.w3.org/ns/activitystreams#Public'].concat(mentionUris); } else if (note.visibility === 'followers') { to = [`${attributedTo}/followers`]; - cc = mentions; + cc = mentionUris; } else { - to = mentions; + to = mentionUris; } - const mentionedUsers = note.mentions.length > 0 ? await Users.findBy({ - id: In(note.mentions), - }) : []; - const hashtagTags = (note.tags || []).map(tag => renderHashtag(tag)); const mentionTags = mentionedUsers.map(u => renderMention(u)); diff --git a/packages/backend/src/services/messages/create.ts b/packages/backend/src/services/messages/create.ts index b5892a891..4a0ea53a8 100644 --- a/packages/backend/src/services/messages/create.ts +++ b/packages/backend/src/services/messages/create.ts @@ -93,11 +93,6 @@ export async function createMessage(user: { id: User['id']; host: User['host']; userId: message.userId, visibility: 'specified', mentions: [ recipientUser.id ], - mentionedRemoteUsers: JSON.stringify([ recipientUser ].map(u => ({ - uri: u.uri, - username: u.username, - host: u.host, - }))), } as Note; const activity = renderActivity(renderCreate(await renderNote(note, false, true), note)); diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 84bfa89eb..9761de0e5 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -15,7 +15,7 @@ import { insertNoteUnread } from '@/services/note/unread.js'; import { extractMentions } from '@/misc/extract-mentions.js'; import { extractCustomEmojisFromMfm } from '@/misc/extract-custom-emojis-from-mfm.js'; import { extractHashtags } from '@/misc/extract-hashtags.js'; -import { Note, IMentionedRemoteUsers } from '@/models/entities/note.js'; +import { Note } from '@/models/entities/note.js'; import { Mutings, Users, NoteWatchings, Notes, Instances, UserProfiles, MutedNotes, Channels, ChannelFollowings, NoteThreadMutings } from '@/models/index.js'; import { DriveFile } from '@/models/entities/drive-file.js'; import { App } from '@/models/entities/app.js'; @@ -537,16 +537,6 @@ async function insertNote(user: { id: User['id']; host: User['host']; }, data: O // Append mentions data if (mentionedUsers.length > 0) { insert.mentions = mentionedUsers.map(u => u.id); - const profiles = await UserProfiles.findBy({ userId: In(insert.mentions) }); - insert.mentionedRemoteUsers = JSON.stringify(mentionedUsers.filter(u => Users.isRemoteUser(u)).map(u => { - const profile = profiles.find(p => p.userId === u.id); - return { - uri: u.uri, - url: profile?.url, - username: u.username, - host: u.host, - } as IMentionedRemoteUsers[0]; - })); } // 投稿を作成 diff --git a/packages/backend/src/services/note/delete.ts b/packages/backend/src/services/note/delete.ts index fc156b584..61b75c963 100644 --- a/packages/backend/src/services/note/delete.ts +++ b/packages/backend/src/services/note/delete.ts @@ -1,4 +1,4 @@ -import { Brackets, In } from 'typeorm'; +import { Brackets, In, IsNull, Not } from 'typeorm'; import { publishNoteStream } from '@/services/stream.js'; import renderDelete from '@/remote/activitypub/renderer/delete.js'; import renderAnnounce from '@/remote/activitypub/renderer/announce.js'; @@ -7,7 +7,7 @@ import { renderActivity } from '@/remote/activitypub/renderer/index.js'; import renderTombstone from '@/remote/activitypub/renderer/tombstone.js'; import config from '@/config/index.js'; import { User, ILocalUser, IRemoteUser } from '@/models/entities/user.js'; -import { Note, IMentionedRemoteUsers } from '@/models/entities/note.js'; +import { Note } from '@/models/entities/note.js'; import { Notes, Users, Instances } from '@/models/index.js'; import { notesChart, perUserNotesChart, instanceChart } from '@/services/chart/index.js'; import { deliverToFollowers, deliverToUser } from '@/remote/activitypub/deliver-manager.js'; @@ -109,11 +109,12 @@ async function getMentionedRemoteUsers(note: Note): Promise { const where = [] as any[]; // mention / reply / dm - const uris = (JSON.parse(note.mentionedRemoteUsers) as IMentionedRemoteUsers).map(x => x.uri); - if (uris.length > 0) { - where.push( - { uri: In(uris) }, - ); + if (note.mentions > 0) { + where.push({ + id: In(note.mentions), + // only remote users, local users are on the server and do not need to be notified + host: Not(IsNull()), + }); } // renote / quote From 0d02914de4942a0bfbbda639a46dcec262ede77d Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Wed, 7 Sep 2022 12:57:39 -0400 Subject: [PATCH 007/152] client: fix lints in general.vue Removed some unused variables and added return type to reloadAsk --- packages/client/src/pages/settings/general.vue | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index 9be40bdd8..f97487f33 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -121,7 +121,7 @@ const lang = ref(localStorage.getItem('lang')); const fontSize = ref(localStorage.getItem('fontSize')); const useSystemFont = ref(localStorage.getItem('useSystemFont') != null); -async function reloadAsk() { +async function reloadAsk(): Promise { const { canceled } = await os.confirm({ type: 'info', text: i18n.ts.reloadToApplySetting, @@ -190,10 +190,6 @@ watch([ await reloadAsk(); }); -const headerActions = $computed(() => []); - -const headerTabs = $computed(() => []); - definePageMetadata({ title: i18n.ts.general, icon: 'fas fa-cogs', From ad73d019861a6def98afa3a8696e56f5e978bf7b Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Wed, 7 Sep 2022 13:06:21 -0400 Subject: [PATCH 008/152] client: remove "Disable AiScript on Pages" setting In #49, the AiScript functionality was removed from pages as they've been simplified to a simple textarea. This setting now effectively does nothing as a result. Changelog: Removed --- locales/ar-SA.yml | 1 - locales/bn-BD.yml | 1 - locales/de-DE.yml | 1 - locales/en-US.yml | 1 - locales/es-ES.yml | 1 - locales/fr-FR.yml | 1 - locales/id-ID.yml | 1 - locales/it-IT.yml | 1 - locales/ja-JP.yml | 1 - locales/ja-KS.yml | 1 - locales/ko-KR.yml | 1 - locales/pl-PL.yml | 1 - locales/ro-RO.yml | 1 - locales/ru-RU.yml | 1 - locales/sk-SK.yml | 1 - locales/uk-UA.yml | 1 - locales/vi-VN.yml | 1 - locales/zh-CN.yml | 1 - locales/zh-TW.yml | 1 - packages/client/src/pages/settings/general.vue | 2 -- packages/client/src/store.ts | 4 ---- 21 files changed, 25 deletions(-) diff --git a/locales/ar-SA.yml b/locales/ar-SA.yml index 8e30b5d99..19b7833a0 100644 --- a/locales/ar-SA.yml +++ b/locales/ar-SA.yml @@ -504,7 +504,6 @@ sort: "ترتيب حسب" ascendingOrder: "تصاعدي" descendingOrder: "تنازلي" output: "الخارجة" -disablePagesScript: "عطّل AiScript في الصفحات" updateRemoteUser: "تحديث المعلومات عن المستخدم البعيد" deleteAllFiles: "حذف كافة الملفات" deleteAllFilesConfirm: "أتريد حذف كل الملفات؟" diff --git a/locales/bn-BD.yml b/locales/bn-BD.yml index 2d520a2e3..7229eac85 100644 --- a/locales/bn-BD.yml +++ b/locales/bn-BD.yml @@ -522,7 +522,6 @@ scratchpad: "স্ক্র্যাচপ্যাড" scratchpadDescription: "স্ক্র্যাচপ্যাড AiScript-এর জন্য একটি পরীক্ষামূলক পরিবেশ প্রদান করে। আপনি মিস্কির সাথে ইন্টারঅ্যাক্ট করে এমন কোড লিখতে, চালাতে এবং তার ফলাফল দেখতে পারেন।" output: "আউটপুট" script: "স্ক্রিপ্ট" -disablePagesScript: "পেজগুলোতে AiScript অক্ষম করুন" updateRemoteUser: "রিমোট ব্যবহারকারীর তথ্য আপডেট করুন" deleteAllFiles: "সকল ফাইল ডিলিট করুন" deleteAllFilesConfirm: "সকল ফাইল ডিলিট করতে চান?" diff --git a/locales/de-DE.yml b/locales/de-DE.yml index c84f6621f..1e10c5e98 100644 --- a/locales/de-DE.yml +++ b/locales/de-DE.yml @@ -523,7 +523,6 @@ scratchpad: "Testumgebung" scratchpadDescription: "Die Testumgebung bietet einen Bereich für AiScript-Experimente. Dort kannst du AiScript schreiben, ausführen sowie dessen Auswirkungen auf Misskey überprüfen." output: "Ausgabe" script: "Skript" -disablePagesScript: "AiScript auf Seiten deaktivieren" updateRemoteUser: "Benutzerinformationen aktualisieren" deleteAllFiles: "Alle Dateien löschen" deleteAllFilesConfirm: "Möchtest du wirklich alle Dateien löschen?" diff --git a/locales/en-US.yml b/locales/en-US.yml index 2c8734f87..ca99048bc 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -523,7 +523,6 @@ scratchpad: "Scratchpad" scratchpadDescription: "The Scratchpad provides an environment for AiScript experiments. You can write, execute, and check the results of it interacting with Misskey in it." output: "Output" script: "Script" -disablePagesScript: "Disable AiScript on Pages" updateRemoteUser: "Update remote user information" deleteAllFiles: "Delete all files" deleteAllFilesConfirm: "Are you sure that you want to delete all files?" diff --git a/locales/es-ES.yml b/locales/es-ES.yml index 60d709ed6..002a3b305 100644 --- a/locales/es-ES.yml +++ b/locales/es-ES.yml @@ -522,7 +522,6 @@ scratchpad: "Scratch pad" scratchpadDescription: "Scratchpad proporciona un entorno experimental para AiScript. Puede escribir, ejecutar y verificar los resultados que interactúan con Misskey." output: "Salida" script: "Script" -disablePagesScript: "Deshabilitar AiScript en Páginas" updateRemoteUser: "Actualizar información de usuario remoto" deleteAllFiles: "Borrar todos los archivos" deleteAllFilesConfirm: "¿Desea borrar todos los archivos?" diff --git a/locales/fr-FR.yml b/locales/fr-FR.yml index f6835903f..0ae13945d 100644 --- a/locales/fr-FR.yml +++ b/locales/fr-FR.yml @@ -519,7 +519,6 @@ scratchpad: "ScratchPad" scratchpadDescription: "ScratchPad fournit un environnement expérimental pour AiScript. Vous pouvez vérifier la rédaction de votre code, sa bonne exécution et le résultat de son interaction avec Misskey." output: "Sortie" script: "Script" -disablePagesScript: "Désactiver AiScript sur les Pages" updateRemoteUser: "Mettre à jour les informations de l’utilisateur·rice distant·e" deleteAllFiles: "Supprimer tous les fichiers" deleteAllFilesConfirm: "Êtes-vous sûr·e de vouloir supprimer tous les fichiers ?" diff --git a/locales/id-ID.yml b/locales/id-ID.yml index 3f465e9b3..ff439ceb4 100644 --- a/locales/id-ID.yml +++ b/locales/id-ID.yml @@ -522,7 +522,6 @@ scratchpad: "Scratchpad" scratchpadDescription: "Scratchpad menyediakan lingkungan eksperimen untuk AiScript. Kamu bisa menulis, mengeksuksi, serta mengecek hasil yang berinteraksi dengan Misskey." output: "Keluaran" script: "Script" -disablePagesScript: "Nonaktifkan script pada halaman" updateRemoteUser: "Perbaharui informasi pengguna luar" deleteAllFiles: "Hapus semua berkas" deleteAllFilesConfirm: "Apakah kamu yakin ingin menghapus semua berkas?" diff --git a/locales/it-IT.yml b/locales/it-IT.yml index a15660565..3da0d0fb4 100644 --- a/locales/it-IT.yml +++ b/locales/it-IT.yml @@ -518,7 +518,6 @@ scratchpad: "ScratchPad" scratchpadDescription: "Lo Scratchpad offre un ambiente per esperimenti di AiScript. È possibile scrivere, eseguire e confermare i risultati dell'interazione del codice con Misskey." output: "Uscita" script: "Script" -disablePagesScript: "Disabilita AiScript nelle pagine" updateRemoteUser: "Aggiornare le informazioni di utente remot@" deleteAllFiles: "Elimina tutti i file" deleteAllFilesConfirm: "Vuoi davvero eliminare tutti i file?" diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 95d2868ed..acf0fff4f 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -523,7 +523,6 @@ scratchpad: "スクラッチパッド" scratchpadDescription: "スクラッチパッドは、AiScriptの実験環境を提供します。Misskeyと対話するコードの記述、実行、結果の確認ができます。" output: "出力" script: "スクリプト" -disablePagesScript: "Pagesのスクリプトを無効にする" updateRemoteUser: "リモートユーザー情報の更新" deleteAllFiles: "すべてのファイルを削除" deleteAllFilesConfirm: "すべてのファイルを削除しますか?" diff --git a/locales/ja-KS.yml b/locales/ja-KS.yml index 384cc6d52..cc19369e5 100644 --- a/locales/ja-KS.yml +++ b/locales/ja-KS.yml @@ -507,7 +507,6 @@ scratchpad: "スクラッチパッド" scratchpadDescription: "スクラッチパッドではAiScriptを色々試すことができるんや。Misskeyに対して色々できるコードを書いて動かしてみたり、結果を見たりできるで。" output: "出力" script: "スクリプト" -disablePagesScript: "Pagesのスクリプトを無効にしてや" updateRemoteUser: "リモートユーザー情報の更新してくれん?" deleteAllFiles: "すべてのファイルを削除" deleteAllFilesConfirm: "ホンマにすべてのファイルを削除するん?消したもんはもう戻ってこんのやで?" diff --git a/locales/ko-KR.yml b/locales/ko-KR.yml index 3f8a46bba..da3977d91 100644 --- a/locales/ko-KR.yml +++ b/locales/ko-KR.yml @@ -522,7 +522,6 @@ scratchpad: "스크래치 패드" scratchpadDescription: "스크래치 패드는 AiScript 의 테스트 환경을 제공합니다. Misskey 와 상호 작용하는 코드를 작성, 실행 및 결과를 확인할 수 있습니다." output: "출력" script: "스크립트" -disablePagesScript: "Pages 에서 AiScript 를 사용하지 않음" updateRemoteUser: "리모트 유저 정보 갱신" deleteAllFiles: "모든 파일 삭제" deleteAllFilesConfirm: "모든 파일을 삭제하시겠습니까?" diff --git a/locales/pl-PL.yml b/locales/pl-PL.yml index a9945b481..79e64b055 100644 --- a/locales/pl-PL.yml +++ b/locales/pl-PL.yml @@ -513,7 +513,6 @@ scratchpad: "Brudnopis" scratchpadDescription: "Brudnopis zawiera eksperymentalne środowisko dla AiScript. Możesz pisać, wykonywać i sprawdzać wyniki w interakcji z Misskey." output: "Wyjście" script: "Skrypt" -disablePagesScript: "Wyłącz AiScript na Stronach" updateRemoteUser: "Aktualizuj zdalne dane o użytkowniku" deleteAllFiles: "Usuń wszystkie pliki" deleteAllFilesConfirm: "Czy na pewno chcesz usunąć wszystkie pliki?" diff --git a/locales/ro-RO.yml b/locales/ro-RO.yml index 1655185d8..3d4d0e727 100644 --- a/locales/ro-RO.yml +++ b/locales/ro-RO.yml @@ -522,7 +522,6 @@ scratchpad: "Scratchpad" scratchpadDescription: "Scratchpad-ul oferă un mediu de experimentare în AiScript. Poți scrie, executa și verifica rezultatele acestuia interacționând cu Misskey în el." output: "Ieșire" script: "Script" -disablePagesScript: "Dezactivează AiScript în Pagini" updateRemoteUser: "Actualizează informațiile utilizatorului extern" deleteAllFiles: "Șterge toate fișierele" deleteAllFilesConfirm: "Ești sigur că vrei să ștergi toate fișierele?" diff --git a/locales/ru-RU.yml b/locales/ru-RU.yml index 640500e2b..ac26d88ee 100644 --- a/locales/ru-RU.yml +++ b/locales/ru-RU.yml @@ -522,7 +522,6 @@ scratchpad: "Когтеточка" scratchpadDescription: "«Когтеточка» — это место для опытов с AiScript. Здесь можно писать программы, взаимодействующие с Misskey, запускать и смотреть что из этого получается." output: "Выходы" script: "Скрипт" -disablePagesScript: "Отключить скрипты на «Страницах»" updateRemoteUser: "Обновить данные пользователя с его сервера" deleteAllFiles: "Удалить все файлы" deleteAllFilesConfirm: "Вы хотите удалить все файлы?" diff --git a/locales/sk-SK.yml b/locales/sk-SK.yml index b7f4aba5e..267e0967b 100644 --- a/locales/sk-SK.yml +++ b/locales/sk-SK.yml @@ -522,7 +522,6 @@ scratchpad: "Zápisník" scratchpadDescription: "Zápisník poskytuje prostredia pre experimenty s AiScriptom. Môžete písať, spúšťať a skúšať vysledky pri interakcii s Misskey." output: "Výstup" script: "Skript" -disablePagesScript: "Vypnúť AiScript na stránkach" updateRemoteUser: "Aktualizovať informácie o vzdialenom účte" deleteAllFiles: "Odstrániť všetky súbory" deleteAllFilesConfirm: "Naozaj chcete odstrániť všetky súbory" diff --git a/locales/uk-UA.yml b/locales/uk-UA.yml index 9bffdf5a7..309e114af 100644 --- a/locales/uk-UA.yml +++ b/locales/uk-UA.yml @@ -522,7 +522,6 @@ scratchpad: "Чернетка" scratchpadDescription: "Scratchpad надає середовище для експериментів з AiScript. Ви можете писати, виконувати його і тестувати взаємодію з Misskey." output: "Вихід" script: "Скрипт" -disablePagesScript: "Вимкнути AiScript на Сторінках" updateRemoteUser: "Оновити інформацію про віддаленого користувача" deleteAllFiles: "Видалити всі файли" deleteAllFilesConfirm: "Ви дійсно хочете видалити всі файли?" diff --git a/locales/vi-VN.yml b/locales/vi-VN.yml index 02ac99856..1b0b342e8 100644 --- a/locales/vi-VN.yml +++ b/locales/vi-VN.yml @@ -522,7 +522,6 @@ scratchpad: "Scratchpad" scratchpadDescription: "Scratchpad cung cấp môi trường cho các thử nghiệm AiScript. Bạn có thể viết, thực thi và kiểm tra kết quả tương tác với Misskey trong đó." output: "Nguồn ra" script: "Kịch bản" -disablePagesScript: "Tắt AiScript trên Trang" updateRemoteUser: "Cập nhật thông tin người dùng ở máy chủ khác" deleteAllFiles: "Xóa toàn bộ tập tin" deleteAllFilesConfirm: "Bạn có chắc xóa toàn bộ tập tin?" diff --git a/locales/zh-CN.yml b/locales/zh-CN.yml index a85cee466..3a11ef032 100644 --- a/locales/zh-CN.yml +++ b/locales/zh-CN.yml @@ -522,7 +522,6 @@ scratchpad: "AiScript控制台" scratchpadDescription: "AiScript控制台为AiScript提供了实验环境。您可以编写代码以与Misskey交互,运行它并查看结果。" output: "输出" script: "脚本" -disablePagesScript: "禁用页面脚本" updateRemoteUser: "更新远程用户信息" deleteAllFiles: "删除所有文件" deleteAllFilesConfirm: "要删除所有文件吗?" diff --git a/locales/zh-TW.yml b/locales/zh-TW.yml index dae242b3c..c0091bcfc 100644 --- a/locales/zh-TW.yml +++ b/locales/zh-TW.yml @@ -522,7 +522,6 @@ scratchpad: "暫存記憶體" scratchpadDescription: "AiScript控制台為AiScript提供了實驗環境。您可以在此編寫、執行和確認代碼與Misskey互動的结果。" output: "輸出" script: "腳本" -disablePagesScript: "停用頁面的AiScript腳本" updateRemoteUser: "更新遠端使用者資訊" deleteAllFiles: "刪除所有檔案" deleteAllFilesConfirm: "要删除所有檔案嗎?" diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index f97487f33..7400c6fd0 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -27,7 +27,6 @@ {{ i18n.ts.openImageInNewTab }} {{ i18n.ts.enableInfiniteScroll }} {{ i18n.ts.useReactionPickerForContextMenu }} - {{ i18n.ts.disablePagesScript }} @@ -146,7 +145,6 @@ const disableShowingAnimatedImages = computed(defaultStore.makeGetterSetter('dis const loadRawImages = computed(defaultStore.makeGetterSetter('loadRawImages')); const imageNewTab = computed(defaultStore.makeGetterSetter('imageNewTab')); const nsfw = computed(defaultStore.makeGetterSetter('nsfw')); -const disablePagesScript = computed(defaultStore.makeGetterSetter('disablePagesScript')); const showFixedPostForm = computed(defaultStore.makeGetterSetter('showFixedPostForm')); const numberOfPageCache = computed(defaultStore.makeGetterSetter('numberOfPageCache')); const instanceTicker = computed(defaultStore.makeGetterSetter('instanceTicker')); diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index a592184fe..7f0855c5b 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -140,10 +140,6 @@ export const defaultStore = markRaw(new Storage('base', { where: 'device', default: false, }, - disablePagesScript: { - where: 'device', - default: false, - }, useOsNativeEmojis: { where: 'device', default: false, From f21e1afaa4c676bffc4af8444cb380c2d1f6c350 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Wed, 7 Sep 2022 13:34:38 -0400 Subject: [PATCH 009/152] backend: fix query for mentionedUsers --- packages/backend/src/mfm/to-html.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/mfm/to-html.ts b/packages/backend/src/mfm/to-html.ts index af399e81f..c208ad765 100644 --- a/packages/backend/src/mfm/to-html.ts +++ b/packages/backend/src/mfm/to-html.ts @@ -8,20 +8,20 @@ import { intersperse } from '@/prelude/array.js'; // Transforms MFM to HTML, given the MFM text and a list of user IDs that are // mentioned in the text. If the list of mentions is not given, all mentions // from the text will be extracted. -export async function toHtml(mfmText: string, mentions?: string[]): string | null { +export async function toHtml(mfmText: string, mentions?: string[]): Promise { const nodes = mfm.parse(mfmText); if (nodes == null) { return null; } - const mentionedUsers = await UserProfiles.createQueryBuilder("user_profiles") + const mentionedUsers = await UserProfiles.createQueryBuilder('user_profiles') .leftJoin('user_profile.user', 'user') .select('user.username') .addSelect('user.host') // links should preferably use user friendly urls, only fall back to AP ids .addSelect('COALESCE(user_profile.url, user.uri)', 'url') .where('userId IN (:...ids)', { ids: mentions ?? extractMentions(nodes) }) - .getManyRaw(); + .getMany(); const doc = new JSDOM('').window.document; @@ -119,7 +119,7 @@ export async function toHtml(mfmText: string, mentions?: string[]): string | nul mention(node) { const { username, host, acct } = node.props; - const userInfo = mentionedUsers.find(user => user.username === username && user.host === host); + const userInfo = mentionedUsers.find(user => user.user?.username === username && user.userHost === host); if (userInfo != null) { // Mastodon microformat: span.h-card > a.u-url.mention const a = doc.createElement('a'); From bd11b9d818fc0a4476837380e18091be54380856 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Wed, 7 Sep 2022 14:02:45 -0400 Subject: [PATCH 010/152] Revert "ci: combine install and lint/build tasks" This reverts commit 759d031a5f84c0b4765c6c6a6c2ec3dc5dd28014. This was originally to solve some issues with builds during the workspace refactor in https://akkoma.dev/FoundKeyGang/FoundKey/pulls/86 but this didn't end up being the root cause, so it may actually be better to split these tasks again. --- .woodpecker/build.yml | 8 +++++++- .woodpecker/lint-backend.yml | 8 +++++++- .woodpecker/lint-client.yml | 8 +++++++- .woodpecker/lint-foundkey-js.yml | 8 +++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml index cb35c390c..e93473fe8 100644 --- a/.woodpecker/build.yml +++ b/.woodpecker/build.yml @@ -6,11 +6,17 @@ clone: recursive: true pipeline: - build: + install: when: event: - pull_request image: node:18.6.0 commands: - yarn install + build: + when: + event: + - pull_request + image: node:18.6.0 + commands: - yarn build diff --git a/.woodpecker/lint-backend.yml b/.woodpecker/lint-backend.yml index 8042733ac..5690d99ae 100644 --- a/.woodpecker/lint-backend.yml +++ b/.woodpecker/lint-backend.yml @@ -6,11 +6,17 @@ clone: recursive: true pipeline: - lint: + install: when: event: - pull_request image: node:18.6.0 commands: - yarn install + lint: + when: + event: + - pull_request + image: node:18.6.0 + commands: - yarn workspace backend run lint diff --git a/.woodpecker/lint-client.yml b/.woodpecker/lint-client.yml index 0248297e2..feb910081 100644 --- a/.woodpecker/lint-client.yml +++ b/.woodpecker/lint-client.yml @@ -6,11 +6,17 @@ clone: recursive: true pipeline: - lint: + install: when: event: - pull_request image: node:18.6.0 commands: - yarn install + lint: + when: + event: + - pull_request + image: node:18.6.0 + commands: - yarn workspace client run lint diff --git a/.woodpecker/lint-foundkey-js.yml b/.woodpecker/lint-foundkey-js.yml index 071a90e8c..ce8162209 100644 --- a/.woodpecker/lint-foundkey-js.yml +++ b/.woodpecker/lint-foundkey-js.yml @@ -6,11 +6,17 @@ clone: recursive: true pipeline: - lint: + install: when: event: - pull_request image: node:18.6.0 commands: - yarn install + lint: + when: + event: + - pull_request + image: node:18.6.0 + commands: - yarn workspace foundkey-js run lint From 0e49c726ec89dfc8a165a5097a370845fdbfa382 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Wed, 7 Sep 2022 14:19:03 -0400 Subject: [PATCH 011/152] backend: add @types/pg for pg type definitions --- packages/backend/package.json | 1 + yarn.lock | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/backend/package.json b/packages/backend/package.json index 878f54593..0b77f4b95 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -27,6 +27,7 @@ "@peertube/http-signature": "1.7.0", "@sinonjs/fake-timers": "9.1.2", "@syuilo/aiscript": "0.11.1", + "@types/pg": "^8.6.5", "abort-controller": "3.0.0", "ajv": "8.11.0", "archiver": "5.3.1", diff --git a/yarn.lock b/yarn.lock index 5bd65edf3..99c8d8934 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2231,6 +2231,17 @@ __metadata: languageName: node linkType: hard +"@types/pg@npm:^8.6.5": + version: 8.6.5 + resolution: "@types/pg@npm:8.6.5" + dependencies: + "@types/node": "*" + pg-protocol: "*" + pg-types: ^2.2.0 + checksum: 49ef858d95e84a6c1be193d367996581c991cf383d8628449507cc4ce67ef43b75acb18a0f9f49f870594cdec3501ddf4d2ac3fbe0dcdaab35c295c038d47199 + languageName: node + linkType: hard + "@types/prettier@npm:^2.1.5": version: 2.7.0 resolution: "@types/prettier@npm:2.7.0" @@ -3644,6 +3655,7 @@ __metadata: "@types/node-fetch": 3.0.3 "@types/nodemailer": 6.4.5 "@types/oauth": ^0.9.1 + "@types/pg": ^8.6.5 "@types/pug": 2.0.6 "@types/punycode": 2.1.0 "@types/qrcode": 1.5.0 @@ -13153,14 +13165,14 @@ __metadata: languageName: node linkType: hard -"pg-protocol@npm:^1.5.0": +"pg-protocol@npm:*, pg-protocol@npm:^1.5.0": version: 1.5.0 resolution: "pg-protocol@npm:1.5.0" checksum: b839d12cafe942ef9cbc5b13c174eb2356804fb4fe8ead8279f46a36be90722d19a91409955beb8a3d5301639c44854e49749de4aef02dc361fee3e2a61fb1e4 languageName: node linkType: hard -"pg-types@npm:^2.1.0": +"pg-types@npm:^2.1.0, pg-types@npm:^2.2.0": version: 2.2.0 resolution: "pg-types@npm:2.2.0" dependencies: From 4ad53f232a257af968ee1ffd695ae041b9123bfb Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Wed, 7 Sep 2022 14:20:22 -0400 Subject: [PATCH 012/152] backend: move @types/pg to devDependencies --- packages/backend/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/package.json b/packages/backend/package.json index 0b77f4b95..9539ac054 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -27,7 +27,6 @@ "@peertube/http-signature": "1.7.0", "@sinonjs/fake-timers": "9.1.2", "@syuilo/aiscript": "0.11.1", - "@types/pg": "^8.6.5", "abort-controller": "3.0.0", "ajv": "8.11.0", "archiver": "5.3.1", @@ -150,6 +149,7 @@ "@types/node-fetch": "3.0.3", "@types/nodemailer": "6.4.5", "@types/oauth": "^0.9.1", + "@types/pg": "^8.6.5", "@types/pug": "2.0.6", "@types/punycode": "2.1.0", "@types/qrcode": "1.5.0", From 058d414fff72be7116d53b92df654315223cf3a9 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Fri, 2 Sep 2022 23:31:22 -0400 Subject: [PATCH 013/152] docs: add migration guide Includes tag-merge workflow from @toast 's post at https://mk.toast.cafe/notes/93o9n4tfsi --- docs/migrating.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 docs/migrating.md diff --git a/docs/migrating.md b/docs/migrating.md new file mode 100644 index 000000000..1d2ea5573 --- /dev/null +++ b/docs/migrating.md @@ -0,0 +1,59 @@ +# Migrating to FoundKey + +Migrating from Misskey to FoundKey is relatively straightforward. However, additional steps are required as there are significant changes between the two projects. + +## Backup +The process will take some time and it's possible something will go wrong. It's highly suggested to make a database dump using `pgdump` and backing up `.config/default.yml` and the `files/` directory before proceeding any further. + +## Reverting migrations +If you're migrating from Misskey 12.112.0 or higher, you'll need to revert some database migrations as they have diverged from that point. Specifically, you'll need to revert `nsfwDetection1655368940105` and newer migrations. + +Run the following to revert those migrations: +```sh +cd packages/backend + +LINE_NUM="$(npx typeorm migration:show -d ormconfig.js | grep -n nsfwDetection1655368940105 | cut -d ':' -f 1)" +NUM_MIGRATIONS="$(npx typeorm migration:show -d ormconfig.js | tail -n+"$LINE_NUM" | grep '\[X\]' | nl)" + +for i in $(seq 1 $NUM_MIGRAIONS); do + npx typeorm migration:revert -d ormconfig.js +done +``` + +## Switching repositories +To switch to the FoundKey repository, do the following in your Misskey install location: +```sh +git remote set-url origin https://akkoma.dev/FoundKeyGang/FoundKey.git +git fetch origin +``` +We recommend using a local branch and merging in upstream releases as they get tagged. This allows for easy local customization of your install. + +For example, say your local branch is `toast.cafe` and you want to use release `v13.0.0-preview1`. To create that branch: +```sh +git checkout tags/v13.0.0-preview1 -b toast.cafe +``` + +When a new release comes out, simply fetch and merge in the new tag. Here we opt to squash upstream commits as it allows for easy reverts in case something goes wrong. +```sh +git fetch -t +git merge tags/v13.0.0-preview2 --squash + # you are now on the "next" release +``` + +## Rebuilding and running database migrations +This will be pretty much the same as a regular update of Misskey. Note that `yarn install` may take a while since dependency versions have been updated or removed and we use a newer version of Yarn. +```sh +yarn install +NODE_ENV=production yarn build +yarn migrate +``` + +## Restarting your instance +To let the changes take effect restart your instance as usual: +```sh +# Systemd +systemctl restart misskey + +# OpenRC +rc-service misskey restart +``` From 55d20a72b70eb1dae2fd304db5aa3bce7fd54260 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Wed, 7 Sep 2022 16:19:18 -0400 Subject: [PATCH 014/152] backend: add types and use named exports for daemons --- packages/backend/src/boot/master.ts | 6 +++--- packages/backend/src/daemons/janitor.ts | 4 ++-- packages/backend/src/daemons/queue-stats.ts | 4 ++-- packages/backend/src/daemons/server-stats.ts | 19 +++++++++++-------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts index 67cfcca63..ef5520749 100644 --- a/packages/backend/src/boot/master.ts +++ b/packages/backend/src/boot/master.ts @@ -74,9 +74,9 @@ export async function masterMain(): Promise { bootLogger.succ(`Now listening on port ${config.port} on ${config.url}`, null, true); if (!envOption.noDaemons) { - import('../daemons/server-stats.js').then(x => x.default()); - import('../daemons/queue-stats.js').then(x => x.default()); - import('../daemons/janitor.js').then(x => x.default()); + import('../daemons/server-stats.js').then(x => x.serverStats()); + import('../daemons/queue-stats.js').then(x => x.queueStats()); + import('../daemons/janitor.js').then(x => x.janitor()); } } diff --git a/packages/backend/src/daemons/janitor.ts b/packages/backend/src/daemons/janitor.ts index 4f56ecd98..06f32814f 100644 --- a/packages/backend/src/daemons/janitor.ts +++ b/packages/backend/src/daemons/janitor.ts @@ -8,8 +8,8 @@ const interval = 30 * 60 * 1000; /** * Clean up database occasionally */ -export default function() { - async function tick() { +export function janitor(): void { + async function tick(): Promise { await AttestationChallenges.delete({ createdAt: LessThan(new Date(new Date().getTime() - 5 * 60 * 1000)), }); diff --git a/packages/backend/src/daemons/queue-stats.ts b/packages/backend/src/daemons/queue-stats.ts index 1535abc6a..8d7736058 100644 --- a/packages/backend/src/daemons/queue-stats.ts +++ b/packages/backend/src/daemons/queue-stats.ts @@ -8,7 +8,7 @@ const interval = 10000; /** * Report queue stats regularly */ -export default function() { +export function queueStats(): void { const log = [] as any[]; ev.on('requestQueueStatsLog', x => { @@ -26,7 +26,7 @@ export default function() { activeInboxJobs++; }); - async function tick() { + async function tick(): Promise { const deliverJobCounts = await deliverQueue.getJobCounts(); const inboxJobCounts = await inboxQueue.getJobCounts(); diff --git a/packages/backend/src/daemons/server-stats.ts b/packages/backend/src/daemons/server-stats.ts index faf4e6e4a..29546d6ab 100644 --- a/packages/backend/src/daemons/server-stats.ts +++ b/packages/backend/src/daemons/server-stats.ts @@ -6,20 +6,20 @@ const ev = new Xev(); const interval = 2000; -const roundCpu = (num: number) => Math.round(num * 1000) / 1000; -const round = (num: number) => Math.round(num * 10) / 10; +const roundCpu = (num: number): number => Math.round(num * 1000) / 1000; +const round = (num: number): number => Math.round(num * 10) / 10; /** * Report server stats regularly */ -export default function() { +export function serverStats(): void { const log = [] as any[]; ev.on('requestServerStatsLog', x => { ev.emit(`serverStatsLog:${x.id}`, log.slice(0, x.length || 50)); }); - async function tick() { + async function tick(): Promise { const cpu = await cpuUsage(); const memStats = await mem(); const netStats = await net(); @@ -60,20 +60,23 @@ function cpuUsage(): Promise { } // MEMORY STAT -async function mem() { +async function mem(): Promise { const data = await si.mem(); return data; } // NETWORK STAT -async function net() { +async function net(): Promise { const iface = await si.networkInterfaceDefault(); const data = await si.networkStats(iface); return data[0]; } // FS STAT -async function fs() { +async function fs(): Promise { const data = await si.disksIO().catch(() => ({ rIO_sec: 0, wIO_sec: 0 })); - return data || { rIO_sec: 0, wIO_sec: 0 }; + return data; } From c469a176235feadf8292d8c3415c364e9b029db4 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Thu, 8 Sep 2022 04:10:28 -0400 Subject: [PATCH 015/152] client: refactor info.vue to composition api --- packages/client/src/components/ui/info.vue | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/packages/client/src/components/ui/info.vue b/packages/client/src/components/ui/info.vue index c972f6690..6ffaf6199 100644 --- a/packages/client/src/components/ui/info.vue +++ b/packages/client/src/components/ui/info.vue @@ -6,21 +6,11 @@ - From c33655bc4fdb975fa8af70b11ca13de149e29f21 Mon Sep 17 00:00:00 2001 From: Norm Date: Thu, 8 Sep 2022 17:14:23 +0000 Subject: [PATCH 016/152] backend: fix table name used in toHtml --- packages/backend/src/mfm/to-html.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/mfm/to-html.ts b/packages/backend/src/mfm/to-html.ts index c208ad765..117f8b278 100644 --- a/packages/backend/src/mfm/to-html.ts +++ b/packages/backend/src/mfm/to-html.ts @@ -14,7 +14,7 @@ export async function toHtml(mfmText: string, mentions?: string[]): Promise Date: Thu, 8 Sep 2022 16:17:35 -0400 Subject: [PATCH 017/152] backend: move mentionedUsers query to mention handler The mentionedUsers query was being run on every post, regardless of whether a mention was in it or not. This resulted in an SQL query ending in `WHERE userId IN ()` which is not allowed in PostgreSQL. Reference: https://akkoma.dev/FoundKeyGang/FoundKey/issues/132 Changelog: Fixed --- packages/backend/src/mfm/to-html.ts | 37 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/packages/backend/src/mfm/to-html.ts b/packages/backend/src/mfm/to-html.ts index 117f8b278..9b72b98c6 100644 --- a/packages/backend/src/mfm/to-html.ts +++ b/packages/backend/src/mfm/to-html.ts @@ -14,23 +14,8 @@ export async function toHtml(mfmText: string, mentions?: string[]): Promise (handlers as any)[x.type](x))) targetElement.appendChild(child); - } - } - const handlers: { [K in mfm.MfmNode['type']]: (node: mfm.NodeType) => any } = { bold(node) { const el = doc.createElement('b'); @@ -117,8 +102,17 @@ export async function toHtml(mfmText: string, mentions?: string[]): Promise { const { username, host, acct } = node.props; + const ids = mentions ?? extractMentions(nodes); + const mentionedUsers = await UserProfiles.createQueryBuilder('user_profile') + .leftJoin('user_profile.user', 'user') + .select('user.username') + .addSelect('user.host') + // links should preferably use user friendly urls, only fall back to AP ids + .addSelect('COALESCE(user_profile.url, user.uri)', 'url') + .where('userId IN (:...ids)', { ids }) + .getMany(); const userInfo = mentionedUsers.find(user => user.user?.username === username && user.userHost === host); if (userInfo != null) { // Mastodon microformat: span.h-card > a.u-url.mention @@ -131,10 +125,9 @@ export async function toHtml(mfmText: string, mentions?: string[]): Promise 0) { + for (const child of children.map(x => (handlers as any)[x.type](x))) targetElement.appendChild(child); + } + } + appendChildren(nodes, doc.body); return `

${doc.body.innerHTML}

`; From aa62c1d7a756050733c0dc92cc991b5cd8ec14c9 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Thu, 8 Sep 2022 22:27:27 +0200 Subject: [PATCH 018/152] refactor(backend): use foundkey-js constants --- packages/backend/src/models/entities/muted-note.ts | 2 +- packages/backend/src/models/entities/note.ts | 2 +- packages/backend/src/models/entities/notification.ts | 2 +- packages/backend/src/models/entities/poll.ts | 2 +- packages/backend/src/models/entities/user-profile.ts | 2 +- packages/backend/src/models/schema/notification.ts | 2 +- packages/backend/src/server/api/endpoints/i/notifications.ts | 2 +- packages/backend/src/server/api/endpoints/i/update.ts | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/models/entities/muted-note.ts b/packages/backend/src/models/entities/muted-note.ts index c75262ece..649b26879 100644 --- a/packages/backend/src/models/entities/muted-note.ts +++ b/packages/backend/src/models/entities/muted-note.ts @@ -1,5 +1,5 @@ import { Entity, Index, JoinColumn, Column, ManyToOne, PrimaryColumn } from 'typeorm'; -import { mutedNoteReasons } from '@/types.js'; +import { mutedNoteReasons } from 'foundkey-js'; import { id } from '../id.js'; import { Note } from './note.js'; import { User } from './user.js'; diff --git a/packages/backend/src/models/entities/note.ts b/packages/backend/src/models/entities/note.ts index d1e6b9f93..0e15921b7 100644 --- a/packages/backend/src/models/entities/note.ts +++ b/packages/backend/src/models/entities/note.ts @@ -1,5 +1,5 @@ import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm'; -import { noteVisibilities } from '@/types.js'; +import { noteVisibilities } from 'foundkey-js'; import { id } from '../id.js'; import { User } from './user.js'; import { DriveFile } from './drive-file.js'; diff --git a/packages/backend/src/models/entities/notification.ts b/packages/backend/src/models/entities/notification.ts index 1fd69d5e8..a757548bd 100644 --- a/packages/backend/src/models/entities/notification.ts +++ b/packages/backend/src/models/entities/notification.ts @@ -1,5 +1,5 @@ import { Entity, Index, JoinColumn, ManyToOne, Column, PrimaryColumn } from 'typeorm'; -import { notificationTypes } from '@/types.js'; +import { notificationTypes } from 'foundkey-js'; import { id } from '../id.js'; import { User } from './user.js'; import { Note } from './note.js'; diff --git a/packages/backend/src/models/entities/poll.ts b/packages/backend/src/models/entities/poll.ts index de40ee719..ece6c8a3b 100644 --- a/packages/backend/src/models/entities/poll.ts +++ b/packages/backend/src/models/entities/poll.ts @@ -1,5 +1,5 @@ import { PrimaryColumn, Entity, Index, JoinColumn, Column, OneToOne } from 'typeorm'; -import { noteVisibilities } from '@/types.js'; +import { noteVisibilities } from 'foundkey-js'; import { id } from '../id.js'; import { Note } from './note.js'; import { User } from './user.js'; diff --git a/packages/backend/src/models/entities/user-profile.ts b/packages/backend/src/models/entities/user-profile.ts index 224bbe3cd..58ab00d01 100644 --- a/packages/backend/src/models/entities/user-profile.ts +++ b/packages/backend/src/models/entities/user-profile.ts @@ -1,5 +1,5 @@ import { Entity, Column, Index, OneToOne, JoinColumn, PrimaryColumn } from 'typeorm'; -import { ffVisibility, notificationTypes } from '@/types.js'; +import { ffVisibility, notificationTypes } from 'foundkey-js'; import { id } from '../id.js'; import { User } from './user.js'; import { Page } from './page.js'; diff --git a/packages/backend/src/models/schema/notification.ts b/packages/backend/src/models/schema/notification.ts index d3f2405cd..75634dc56 100644 --- a/packages/backend/src/models/schema/notification.ts +++ b/packages/backend/src/models/schema/notification.ts @@ -1,4 +1,4 @@ -import { notificationTypes } from '@/types.js'; +import { notificationTypes } from 'foundkey-js'; export const packedNotificationSchema = { type: 'object', diff --git a/packages/backend/src/server/api/endpoints/i/notifications.ts b/packages/backend/src/server/api/endpoints/i/notifications.ts index a2249803e..237d76da8 100644 --- a/packages/backend/src/server/api/endpoints/i/notifications.ts +++ b/packages/backend/src/server/api/endpoints/i/notifications.ts @@ -1,6 +1,6 @@ import { Brackets } from 'typeorm'; +import { notificationTypes } from 'foundkey-js'; import { Notifications, Followings, Mutings, Users, UserProfiles } from '@/models/index.js'; -import { notificationTypes } from '@/types.js'; import read from '@/services/note/read.js'; import { readNotification } from '../../common/read-notification.js'; import define from '../../define.js'; diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index fd2437b3a..c9557eadd 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -1,5 +1,6 @@ import RE2 from 're2'; import * as mfm from 'mfm-js'; +import { notificationTypes } from 'foundkey-js'; import { publishMainStream, publishUserEvent } from '@/services/stream.js'; import acceptAllFollowRequests from '@/services/following/requests/accept-all.js'; import { publishToFollowers } from '@/services/i/update.js'; @@ -9,7 +10,6 @@ import { updateUsertags } from '@/services/update-hashtag.js'; import { Users, DriveFiles, UserProfiles, Pages } from '@/models/index.js'; import { User } from '@/models/entities/user.js'; import { UserProfile } from '@/models/entities/user-profile.js'; -import { notificationTypes } from '@/types.js'; import { normalizeForSearch } from '@/misc/normalize-for-search.js'; import { langmap } from '@/misc/langmap.js'; import define from '../../define.js'; From 42132963cfe387fdc5e3da371deb287aa8bd4468 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Thu, 8 Sep 2022 23:27:25 +0200 Subject: [PATCH 019/152] refactor(backend): remove types.ts in favour of foundkey-js --- .../backend/src/server/api/endpoints/notes/create.ts | 2 +- packages/backend/src/types.ts | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 packages/backend/src/types.ts diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index 8d13fb483..9c22ca2e0 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -1,4 +1,5 @@ import { In } from 'typeorm'; +import { noteVisibilities } from 'foundkey-js'; import create from '@/services/note/create.js'; import { User } from '@/models/entities/user.js'; import { Users, DriveFiles, Notes, Channels, Blockings } from '@/models/index.js'; @@ -7,7 +8,6 @@ import { Note } from '@/models/entities/note.js'; import { Channel } from '@/models/entities/channel.js'; import { MAX_NOTE_TEXT_LENGTH, HOUR } from '@/const.js'; import { isPureRenote } from '@/misc/renote.js'; -import { noteVisibilities } from '../../../../types.js'; import { ApiError } from '../../error.js'; import define from '../../define.js'; import { getNote } from '../../common/getters.js'; diff --git a/packages/backend/src/types.ts b/packages/backend/src/types.ts deleted file mode 100644 index 5ca4a966a..000000000 --- a/packages/backend/src/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const notificationTypes = ['follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app'] as const; - -/** - * Note visibilities, ordered from most to least open. - */ -export const noteVisibilities = ['public', 'home', 'followers', 'specified'] as const; - -export const mutedNoteReasons = ['word', 'manual', 'spam', 'other'] as const; - -export const ffVisibility = ['public', 'followers', 'private'] as const; From 29c7e7e859c051fb290cc819be54e8ff2532ee94 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Wed, 7 Sep 2022 16:45:44 -0400 Subject: [PATCH 020/152] backend: fix types in boot/{master, worker}.ts --- packages/backend/src/boot/master.ts | 15 ++++++++------- packages/backend/src/boot/worker.ts | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts index 67cfcca63..d823569e4 100644 --- a/packages/backend/src/boot/master.ts +++ b/packages/backend/src/boot/master.ts @@ -32,7 +32,7 @@ function greet(): void { console.log(themeColor(' | |_|___ ___| |_ ___ _ _ ')); console.log(themeColor(' | | | | |_ -|_ -| \'_| -_| | |')); console.log(themeColor(' |_|_|_|_|___|___|_,_|___|_ |')); - console.log(' ' + chalk.gray(v) + themeColor(' |___|\n'.substr(v.length))); + console.log(' ' + chalk.gray(v) + themeColor(' |___|\n'.slice(v.length))); //#endregion console.log(' Misskey is an open-source decentralized microblogging platform.'); @@ -61,7 +61,7 @@ export async function masterMain(): Promise { config = loadConfigBoot(); await connectDb(); } catch (e) { - bootLogger.error('Fatal error occurred during initialization', null, true); + bootLogger.error('Fatal error occurred during initialization', {}, true); process.exit(1); } @@ -87,7 +87,7 @@ function showEnvironment(): void { if (env !== 'production') { logger.warn('The environment is not in production mode.'); - logger.warn('DO NOT USE FOR PRODUCTION PURPOSE!', null, true); + logger.warn('DO NOT USE FOR PRODUCTION PURPOSE!', {}, true); } } @@ -110,8 +110,9 @@ function loadConfigBoot(): Config { try { config = loadConfig(); } catch (exception) { - if (exception.code === 'ENOENT') { - configLogger.error('Configuration file not found', null, true); + const e = exception as Partial | Error; + if ('code' in e && e.code === 'ENOENT') { + configLogger.error('Configuration file not found', {}, true); process.exit(1); } else if (e instanceof Error) { configLogger.error(e.message); @@ -135,8 +136,8 @@ async function connectDb(): Promise { const v = await db.query('SHOW server_version').then(x => x[0].server_version); dbLogger.succ(`Connected: v${v}`); } catch (e) { - dbLogger.error('Cannot connect', null, true); - dbLogger.error(e); + dbLogger.error('Cannot connect', {}, true); + dbLogger.error(e as Error | string); process.exit(1); } } diff --git a/packages/backend/src/boot/worker.ts b/packages/backend/src/boot/worker.ts index af2df4471..7c4885126 100644 --- a/packages/backend/src/boot/worker.ts +++ b/packages/backend/src/boot/worker.ts @@ -15,6 +15,6 @@ export async function workerMain(): Promise { if (cluster.isWorker) { // Send a 'ready' message to parent process - process.send!('ready'); + process.send?.('ready'); } } From 199622b41548110a2dee84983b93fe68388b20b8 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Thu, 8 Sep 2022 17:45:03 -0400 Subject: [PATCH 021/152] add check if ids.length > 0 before executing query --- packages/backend/src/mfm/to-html.ts | 40 +++++++++++++++-------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/packages/backend/src/mfm/to-html.ts b/packages/backend/src/mfm/to-html.ts index 9b72b98c6..c32363574 100644 --- a/packages/backend/src/mfm/to-html.ts +++ b/packages/backend/src/mfm/to-html.ts @@ -105,26 +105,28 @@ export async function toHtml(mfmText: string, mentions?: string[]): Promise { const { username, host, acct } = node.props; const ids = mentions ?? extractMentions(nodes); - const mentionedUsers = await UserProfiles.createQueryBuilder('user_profile') - .leftJoin('user_profile.user', 'user') - .select('user.username') - .addSelect('user.host') - // links should preferably use user friendly urls, only fall back to AP ids - .addSelect('COALESCE(user_profile.url, user.uri)', 'url') - .where('userId IN (:...ids)', { ids }) - .getMany(); - const userInfo = mentionedUsers.find(user => user.user?.username === username && user.userHost === host); - if (userInfo != null) { - // Mastodon microformat: span.h-card > a.u-url.mention - const a = doc.createElement('a'); - a.href = userInfo.url ?? `${config.url}/${acct}`; - a.className = 'u-url mention'; - a.textContent = acct; + if (ids.length > 0) { + const mentionedUsers = await UserProfiles.createQueryBuilder('user_profile') + .leftJoin('user_profile.user', 'user') + .select('user.username') + .addSelect('user.host') + // links should preferably use user friendly urls, only fall back to AP ids + .addSelect('COALESCE(user_profile.url, user.uri)', 'url') + .where('"userId" IN (:...ids)', { ids }) + .getMany(); + const userInfo = mentionedUsers.find(user => user.user?.username === username && user.userHost === host); + if (userInfo != null) { + // Mastodon microformat: span.h-card > a.u-url.mention + const a = doc.createElement('a'); + a.href = userInfo.url ?? `${config.url}/${acct}`; + a.className = 'u-url mention'; + a.textContent = acct; - const card = doc.createElement('span'); - card.className = 'h-card'; - card.appendChild(a); - return card; + const card = doc.createElement('span'); + card.className = 'h-card'; + card.appendChild(a); + return card; + } } // this user does not actually exist return doc.createTextNode(acct); From 106c643f8501221d6e8f801adc06a5dcd5e9eac4 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Thu, 8 Sep 2022 20:51:41 -0400 Subject: [PATCH 022/152] foundkey-js: use file extensions in imports Technically, ESM modules require imports to include file extensions. For whatever reason this didn't seem to be required when importing into the client, but it does seem to be required for use in the backend. --- packages/foundkey-js/src/api.ts | 2 +- packages/foundkey-js/src/api.types.ts | 2 +- packages/foundkey-js/src/index.ts | 10 +++++----- packages/foundkey-js/src/streaming.ts | 2 +- packages/foundkey-js/src/streaming.types.ts | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/foundkey-js/src/api.ts b/packages/foundkey-js/src/api.ts index 2cf848810..923fbd304 100644 --- a/packages/foundkey-js/src/api.ts +++ b/packages/foundkey-js/src/api.ts @@ -1,4 +1,4 @@ -import { Endpoints } from './api.types'; +import { Endpoints } from './api.types.js'; const MK_API_ERROR = Symbol(); diff --git a/packages/foundkey-js/src/api.types.ts b/packages/foundkey-js/src/api.types.ts index 8f81fc2d1..51028c805 100644 --- a/packages/foundkey-js/src/api.types.ts +++ b/packages/foundkey-js/src/api.types.ts @@ -3,7 +3,7 @@ import { LiteInstanceMetadata, MeDetailed, Note, NoteFavorite, OriginType, Page, ServerInfo, Stats, User, UserDetailed, UserGroup, UserList, UserSorting, Notification, NoteReaction, Signin, MessagingMessage, -} from './entities'; +} from './entities.js'; type TODO = Record | null; diff --git a/packages/foundkey-js/src/index.ts b/packages/foundkey-js/src/index.ts index f431d65cc..6e7ec7db8 100644 --- a/packages/foundkey-js/src/index.ts +++ b/packages/foundkey-js/src/index.ts @@ -1,8 +1,8 @@ -import { Endpoints } from './api.types'; -import Stream, { Connection } from './streaming'; -import { Channels } from './streaming.types'; -import { Acct } from './acct'; -import * as consts from './consts'; +import { Endpoints } from './api.types.js'; +import Stream, { Connection } from './streaming.js'; +import { Channels } from './streaming.types.js'; +import { Acct } from './acct.js'; +import * as consts from './consts.js'; export { Endpoints, diff --git a/packages/foundkey-js/src/streaming.ts b/packages/foundkey-js/src/streaming.ts index 92b83192c..98ed22d6d 100644 --- a/packages/foundkey-js/src/streaming.ts +++ b/packages/foundkey-js/src/streaming.ts @@ -1,7 +1,7 @@ import autobind from 'autobind-decorator'; import { EventEmitter } from 'eventemitter3'; import ReconnectingWebsocket from 'reconnecting-websocket'; -import { BroadcastEvents, Channels } from './streaming.types'; +import { BroadcastEvents, Channels } from './streaming.types.js'; export function urlQuery(obj: Record): string { const params = Object.entries(obj) diff --git a/packages/foundkey-js/src/streaming.types.ts b/packages/foundkey-js/src/streaming.types.ts index f711b8d6e..84c948538 100644 --- a/packages/foundkey-js/src/streaming.types.ts +++ b/packages/foundkey-js/src/streaming.types.ts @@ -1,4 +1,4 @@ -import { Antenna, CustomEmoji, DriveFile, MeDetailed, MessagingMessage, Note, Notification, PageEvent, User, UserGroup } from './entities'; +import { Antenna, CustomEmoji, DriveFile, MeDetailed, MessagingMessage, Note, Notification, PageEvent, User, UserGroup } from './entities.js'; type FIXME = any; From 674f91109f536b527cf3324914105911e6b29af3 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Thu, 8 Sep 2022 21:00:57 -0400 Subject: [PATCH 023/152] foundkey-js: add remaining file extensions to local imports --- packages/foundkey-js/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/foundkey-js/src/index.ts b/packages/foundkey-js/src/index.ts index 6e7ec7db8..3768fdda5 100644 --- a/packages/foundkey-js/src/index.ts +++ b/packages/foundkey-js/src/index.ts @@ -21,6 +21,6 @@ export const ffVisibility = consts.ffVisibility; // api extractor not supported yet //export * as api from './api'; //export * as entities from './entities'; -import * as api from './api'; -import * as entities from './entities'; +import * as api from './api.js'; +import * as entities from './entities.js'; export { api, entities }; From dde4086811f0bcf001f7477f5f010e99e55ca94a Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Thu, 8 Sep 2022 21:06:38 -0400 Subject: [PATCH 024/152] fix(foundkey-js): use default import for eventemitter3 --- packages/foundkey-js/src/streaming.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/foundkey-js/src/streaming.ts b/packages/foundkey-js/src/streaming.ts index 98ed22d6d..465f546f3 100644 --- a/packages/foundkey-js/src/streaming.ts +++ b/packages/foundkey-js/src/streaming.ts @@ -1,5 +1,5 @@ import autobind from 'autobind-decorator'; -import { EventEmitter } from 'eventemitter3'; +import EventEmitter from 'eventemitter3'; import ReconnectingWebsocket from 'reconnecting-websocket'; import { BroadcastEvents, Channels } from './streaming.types.js'; From 3d789c82519ff14995e88d8cb060e3294e3b27f4 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Thu, 8 Sep 2022 21:52:45 -0400 Subject: [PATCH 025/152] update vue to 3.2.39 --- packages/client/package.json | 4 +- yarn.lock | 142 +++++++++++++++++------------------ 2 files changed, 73 insertions(+), 73 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index 5c041a3bf..80e02412b 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -17,7 +17,7 @@ "@rollup/pluginutils": "^4.2.1", "@syuilo/aiscript": "0.11.1", "@vitejs/plugin-vue": "^3.1.0", - "@vue/compiler-sfc": "3.2.38", + "@vue/compiler-sfc": "3.2.39", "abort-controller": "3.0.0", "autobind-decorator": "2.4.0", "autosize": "5.0.1", @@ -73,7 +73,7 @@ "v-debounce": "0.1.2", "vanilla-tilt": "1.7.2", "vite": "3.1.0", - "vue": "3.2.38", + "vue": "3.2.39", "vue-prism-editor": "2.0.0-alpha.2", "vuedraggable": "4.0.1", "websocket": "1.0.34", diff --git a/yarn.lock b/yarn.lock index 99c8d8934..007a7dc20 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2674,115 +2674,115 @@ __metadata: languageName: node linkType: hard -"@vue/compiler-core@npm:3.2.38": - version: 3.2.38 - resolution: "@vue/compiler-core@npm:3.2.38" +"@vue/compiler-core@npm:3.2.39": + version: 3.2.39 + resolution: "@vue/compiler-core@npm:3.2.39" dependencies: "@babel/parser": ^7.16.4 - "@vue/shared": 3.2.38 + "@vue/shared": 3.2.39 estree-walker: ^2.0.2 source-map: ^0.6.1 - checksum: fd1049aa14f93ac167d5cff2c867c12aca3a57b6070ca07b45930549a3643296fd07ad0b2e3799a3cabdbc08609325431b475b6d504b47bfe098ebaca61a120d + checksum: dd70ed60b14faba2f46a2a99ddf20819db7dff124dd49ec15ba76ea3c6d8311feca4256d4dac8e8316c6670434cbb7c0c6a2cb5f6e97b321ba42ff454102c3be languageName: node linkType: hard -"@vue/compiler-dom@npm:3.2.38": - version: 3.2.38 - resolution: "@vue/compiler-dom@npm:3.2.38" +"@vue/compiler-dom@npm:3.2.39": + version: 3.2.39 + resolution: "@vue/compiler-dom@npm:3.2.39" dependencies: - "@vue/compiler-core": 3.2.38 - "@vue/shared": 3.2.38 - checksum: 21ee60938a9a4e81365be3cb29f336a1b7be8878ad750f8f9735ee04d00d51f3c11b3ce60136491abf3a9c7fb714c1c58561e859bde83dc1e0759d0f3488a50f + "@vue/compiler-core": 3.2.39 + "@vue/shared": 3.2.39 + checksum: 505a8f8515f8551795e3a01859d451645e0bd77be2d70d5c48f6edd02ebc255d911230c66ccfc478fd0218ab8a7b69bd99e2c12b406db4889285058f52d13363 languageName: node linkType: hard -"@vue/compiler-sfc@npm:3.2.38": - version: 3.2.38 - resolution: "@vue/compiler-sfc@npm:3.2.38" +"@vue/compiler-sfc@npm:3.2.39": + version: 3.2.39 + resolution: "@vue/compiler-sfc@npm:3.2.39" dependencies: "@babel/parser": ^7.16.4 - "@vue/compiler-core": 3.2.38 - "@vue/compiler-dom": 3.2.38 - "@vue/compiler-ssr": 3.2.38 - "@vue/reactivity-transform": 3.2.38 - "@vue/shared": 3.2.38 + "@vue/compiler-core": 3.2.39 + "@vue/compiler-dom": 3.2.39 + "@vue/compiler-ssr": 3.2.39 + "@vue/reactivity-transform": 3.2.39 + "@vue/shared": 3.2.39 estree-walker: ^2.0.2 magic-string: ^0.25.7 postcss: ^8.1.10 source-map: ^0.6.1 - checksum: 1d72cc4f1c643db455a0034d11ede23c83a3ff4fd4e2ffcfdb85805c99fc7a4227faddc8994b41a41d5abbf3e9edf7b87557378f13c141f920b9b12dd180d285 + checksum: b82755eec28c03800e38b99603a90b85af03d670558c845f9916650fea5cac8c2eb1511d66aa71e602ca9af8d2795e9f6a16fc867efce8c8694a6ea106f0ac95 languageName: node linkType: hard -"@vue/compiler-ssr@npm:3.2.38": - version: 3.2.38 - resolution: "@vue/compiler-ssr@npm:3.2.38" +"@vue/compiler-ssr@npm:3.2.39": + version: 3.2.39 + resolution: "@vue/compiler-ssr@npm:3.2.39" dependencies: - "@vue/compiler-dom": 3.2.38 - "@vue/shared": 3.2.38 - checksum: f457245a43d8290dbdb8f782fd873557041798801be61e8c3e52d88784232a7545dc23532c4552ed3fd74c1dfdfd07531ab83be3e5b5441dda4c4b282055043a + "@vue/compiler-dom": 3.2.39 + "@vue/shared": 3.2.39 + checksum: 27323a548df3696d38a8b029b55e136fc94195f1a9e12a25161a8d524cc779dbcc5f69db525a8d86f6ed28326f9f8595db5ba94ccaa7c8f127f752be36bffe5f languageName: node linkType: hard -"@vue/reactivity-transform@npm:3.2.38": - version: 3.2.38 - resolution: "@vue/reactivity-transform@npm:3.2.38" +"@vue/reactivity-transform@npm:3.2.39": + version: 3.2.39 + resolution: "@vue/reactivity-transform@npm:3.2.39" dependencies: "@babel/parser": ^7.16.4 - "@vue/compiler-core": 3.2.38 - "@vue/shared": 3.2.38 + "@vue/compiler-core": 3.2.39 + "@vue/shared": 3.2.39 estree-walker: ^2.0.2 magic-string: ^0.25.7 - checksum: 84b665185ed60b21195992b33b6cc068fe8c6c68ffa526f3aa1334ffdeac94daf07a74fc6dda6ef40230bcb940ec6607aa5ae0ae0309942a71717c7b22639d8a + checksum: b609d9367d875bf326ca8f31779407723cad2b2b4a26e7fb8860089c720e1b0bb8d5fe19604e8baff1d9ffc1fdbafb21a43db9063a24ae4ad30cb70b1c712de3 languageName: node linkType: hard -"@vue/reactivity@npm:3.2.38": - version: 3.2.38 - resolution: "@vue/reactivity@npm:3.2.38" +"@vue/reactivity@npm:3.2.39": + version: 3.2.39 + resolution: "@vue/reactivity@npm:3.2.39" dependencies: - "@vue/shared": 3.2.38 - checksum: c9afb0184603c93a450553d8280a4e32b4e327ab90cadb94d020d8118d6214bee820db4312d26d0570679ede18e9b8d4ca696eab012abd0839a346c30b5ca07e + "@vue/shared": 3.2.39 + checksum: c4d440a53b2196e46129271affdb22182586a8123bc44d082468cd089242023890bccd6eaa1acc72919ea2c1febad979504be737720632afefee6ec6b75370a9 languageName: node linkType: hard -"@vue/runtime-core@npm:3.2.38": - version: 3.2.38 - resolution: "@vue/runtime-core@npm:3.2.38" +"@vue/runtime-core@npm:3.2.39": + version: 3.2.39 + resolution: "@vue/runtime-core@npm:3.2.39" dependencies: - "@vue/reactivity": 3.2.38 - "@vue/shared": 3.2.38 - checksum: d3936ca50b3eabc3eae575bb9e3b8219c4a0d6ebcde0e111fefe0b154d9aba827a87cc939ce9be626a9fa92b408b000287fb57ca97126186a8c7ef2b7f9c4844 + "@vue/reactivity": 3.2.39 + "@vue/shared": 3.2.39 + checksum: 13f6b92d70fb3bc8b12caef9eaf9cc1fb3aa1f1bd07e2392013f02d65c74b09d4121e62d149d7f7c316ef2c6b3496c9ec828795286480f08e5f45e910b0f2671 languageName: node linkType: hard -"@vue/runtime-dom@npm:3.2.38": - version: 3.2.38 - resolution: "@vue/runtime-dom@npm:3.2.38" +"@vue/runtime-dom@npm:3.2.39": + version: 3.2.39 + resolution: "@vue/runtime-dom@npm:3.2.39" dependencies: - "@vue/runtime-core": 3.2.38 - "@vue/shared": 3.2.38 + "@vue/runtime-core": 3.2.39 + "@vue/shared": 3.2.39 csstype: ^2.6.8 - checksum: d1d889c3e85b6b1a12efd432160c57d8b5eff4889717d36d27dae39094578bdcceefa536e991bf040e32e4baf3dc096f579aa14af1077eb91a79772843755fca + checksum: 0c47f941148a000ac0cb93add51edb08eca5ae16fa7898dd070300f22e4ba77533c85342f0ceca0cab8637b80b1f92cfab10adb2160e4c6dd4be4a5b27ae1ff3 languageName: node linkType: hard -"@vue/server-renderer@npm:3.2.38": - version: 3.2.38 - resolution: "@vue/server-renderer@npm:3.2.38" +"@vue/server-renderer@npm:3.2.39": + version: 3.2.39 + resolution: "@vue/server-renderer@npm:3.2.39" dependencies: - "@vue/compiler-ssr": 3.2.38 - "@vue/shared": 3.2.38 + "@vue/compiler-ssr": 3.2.39 + "@vue/shared": 3.2.39 peerDependencies: - vue: 3.2.38 - checksum: d7d8458e6913f0c6cd517cd2b3b673ebd28b3d85fdb4a004896c0da68a9e58eb69d30141b403b8afaa2f341029aa00c2860b845363f75ed5e1116787283bcc1c + vue: 3.2.39 + checksum: ae6ccd08b85ad8c18cae461404ad8c4b3b602c779fe07ab3a69e0a9a4cef274ea8dcd662fa365f3717f67d4ba02a9eac88dd2ebf5194072ae43dd5db99c2cb2c languageName: node linkType: hard -"@vue/shared@npm:3.2.38": - version: 3.2.38 - resolution: "@vue/shared@npm:3.2.38" - checksum: c1aa5ec1320fff7431297c594cb976908b5ff240a16384930b4b16dc2a0d663aa09706337dee6910db260c5bb24fb31359006637d01de98009247a68acde5eae +"@vue/shared@npm:3.2.39": + version: 3.2.39 + resolution: "@vue/shared@npm:3.2.39" + checksum: 0bf9f5b4851b634cfae92c08d64173c2db674bd817424473d28fc58af7c17c54a255f9b3e837d3857e1e62f9092ab1d74b4714237e45c94fcd46f92155ef653f languageName: node linkType: hard @@ -4693,7 +4693,7 @@ __metadata: "@typescript-eslint/eslint-plugin": ^5.36.2 "@typescript-eslint/parser": ^5.36.2 "@vitejs/plugin-vue": ^3.1.0 - "@vue/compiler-sfc": 3.2.38 + "@vue/compiler-sfc": 3.2.39 abort-controller: 3.0.0 autobind-decorator: 2.4.0 autosize: 5.0.1 @@ -4755,7 +4755,7 @@ __metadata: v-debounce: 0.1.2 vanilla-tilt: 1.7.2 vite: 3.1.0 - vue: 3.2.38 + vue: 3.2.39 vue-prism-editor: 2.0.0-alpha.2 vuedraggable: 4.0.1 websocket: 1.0.34 @@ -17407,16 +17407,16 @@ __metadata: languageName: node linkType: hard -"vue@npm:3.2.38": - version: 3.2.38 - resolution: "vue@npm:3.2.38" +"vue@npm:3.2.39": + version: 3.2.39 + resolution: "vue@npm:3.2.39" dependencies: - "@vue/compiler-dom": 3.2.38 - "@vue/compiler-sfc": 3.2.38 - "@vue/runtime-dom": 3.2.38 - "@vue/server-renderer": 3.2.38 - "@vue/shared": 3.2.38 - checksum: 9b82cb893018d6fae601823bdf1523a600c90f38bb690f92a2f2ec56d536beb2a86bf3bc0c0e6252ca0daddb86f46ead38dfbb546078f4c18281eb7bc5b7366e + "@vue/compiler-dom": 3.2.39 + "@vue/compiler-sfc": 3.2.39 + "@vue/runtime-dom": 3.2.39 + "@vue/server-renderer": 3.2.39 + "@vue/shared": 3.2.39 + checksum: f096a3f0a5f72c65d26246ff7989729eda2b996dc30c63fd8cd7ccda07e9c318d478e3e24661ff01e49bcf5fed6f330142fcf29d6ad46c13423f36b3ae1a54cc languageName: node linkType: hard From 9a34e0b2b16950f16f8295dfa2c76a103baade1b Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Thu, 8 Sep 2022 23:00:36 -0400 Subject: [PATCH 026/152] build: update typescript and related packages --- package.json | 2 +- packages/backend/package.json | 6 ++-- packages/client/package.json | 4 +-- packages/foundkey-js/package.json | 4 +-- yarn.lock | 48 +++++++++++++++---------------- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 96ee5e71a..a73030bbe 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "cross-env": "7.0.3", "cypress": "10.3.0", "start-server-and-test": "1.14.0", - "typescript": "4.8.2" + "typescript": "4.8.3" }, "packageManager": "yarn@3.2.3" } diff --git a/packages/backend/package.json b/packages/backend/package.json index 9539ac054..5d06d6fc3 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -111,7 +111,7 @@ "ts-loader": "9.3.1", "ts-node": "10.9.1", "tsc-alias": "1.7.0", - "tsconfig-paths": "4.0.0", + "tsconfig-paths": "4.1.0", "twemoji-parser": "14.0.0", "typeorm": "0.3.7", "unzipper": "0.10.11", @@ -145,7 +145,7 @@ "@types/koa__multer": "2.0.4", "@types/koa__router": "8.0.11", "@types/mocha": "9.1.1", - "@types/node": "18.7.15", + "@types/node": "18.7.16", "@types/node-fetch": "3.0.3", "@types/nodemailer": "6.4.5", "@types/oauth": "^0.9.1", @@ -175,6 +175,6 @@ "eslint-plugin-import": "^2.26.0", "execa": "6.1.0", "form-data": "^4.0.0", - "typescript": "^4.8.2" + "typescript": "^4.8.3" } } diff --git a/packages/client/package.json b/packages/client/package.json index 80e02412b..b895aca31 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -66,9 +66,9 @@ "throttle-debounce": "5.0.0", "tinycolor2": "1.4.2", "tsc-alias": "1.7.0", - "tsconfig-paths": "4.0.0", + "tsconfig-paths": "4.1.0", "twemoji-parser": "14.0.0", - "typescript": "4.8.2", + "typescript": "4.8.3", "uuid": "8.3.2", "v-debounce": "0.1.2", "vanilla-tilt": "1.7.2", diff --git a/packages/foundkey-js/package.json b/packages/foundkey-js/package.json index b1f4f6185..6fae7d8cf 100644 --- a/packages/foundkey-js/package.json +++ b/packages/foundkey-js/package.json @@ -21,7 +21,7 @@ "devDependencies": { "@microsoft/api-extractor": "^7.19.3", "@types/jest": "^27.4.0", - "@types/node": "18.7.15", + "@types/node": "18.7.16", "@typescript-eslint/eslint-plugin": "5.36.2", "@typescript-eslint/parser": "^5.36.2", "eslint": "^8.23.0", @@ -32,7 +32,7 @@ "ts-jest": "^27.1.5", "ts-node": "10.9.1", "tsd": "^0.23.0", - "typescript": "4.8.2" + "typescript": "4.8.3" }, "files": [ "built" diff --git a/yarn.lock b/yarn.lock index 007a7dc20..d2875513d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2176,10 +2176,10 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:18.7.15": - version: 18.7.15 - resolution: "@types/node@npm:18.7.15" - checksum: 1435fc7fe44744467a3ba8ace646455be228516530dbb3db64a03cca6abcfdc5ba2e48a3eafc71f25f836d2ca871132361c58a5e760237a53674cb09151147d9 +"@types/node@npm:18.7.16": + version: 18.7.16 + resolution: "@types/node@npm:18.7.16" + checksum: 01a3d35c764a3f0e7370b56e1ad4203731131883c65784e020009014171b3f53c4649cde6c7aa4f1026b907ee87ef6ae6ece2bc518151dc7b81100fe8b1db3ad languageName: node linkType: hard @@ -3651,7 +3651,7 @@ __metadata: "@types/koa__multer": 2.0.4 "@types/koa__router": 8.0.11 "@types/mocha": 9.1.1 - "@types/node": 18.7.15 + "@types/node": 18.7.16 "@types/node-fetch": 3.0.3 "@types/nodemailer": 6.4.5 "@types/oauth": ^0.9.1 @@ -3765,10 +3765,10 @@ __metadata: ts-loader: 9.3.1 ts-node: 10.9.1 tsc-alias: 1.7.0 - tsconfig-paths: 4.0.0 + tsconfig-paths: 4.1.0 twemoji-parser: 14.0.0 typeorm: 0.3.7 - typescript: ^4.8.2 + typescript: ^4.8.3 unzipper: 0.10.11 uuid: 8.3.2 web-push: 3.5.0 @@ -4748,9 +4748,9 @@ __metadata: throttle-debounce: 5.0.0 tinycolor2: 1.4.2 tsc-alias: 1.7.0 - tsconfig-paths: 4.0.0 + tsconfig-paths: 4.1.0 twemoji-parser: 14.0.0 - typescript: 4.8.2 + typescript: 4.8.3 uuid: 8.3.2 v-debounce: 0.1.2 vanilla-tilt: 1.7.2 @@ -7841,7 +7841,7 @@ __metadata: dependencies: "@microsoft/api-extractor": ^7.19.3 "@types/jest": ^27.4.0 - "@types/node": 18.7.15 + "@types/node": 18.7.16 "@typescript-eslint/eslint-plugin": 5.36.2 "@typescript-eslint/parser": ^5.36.2 autobind-decorator: ^2.4.0 @@ -7855,7 +7855,7 @@ __metadata: ts-jest: ^27.1.5 ts-node: 10.9.1 tsd: ^0.23.0 - typescript: 4.8.2 + typescript: 4.8.3 languageName: unknown linkType: soft @@ -7876,7 +7876,7 @@ __metadata: gulp-terser: 2.1.0 js-yaml: 4.1.0 start-server-and-test: 1.14.0 - typescript: 4.8.2 + typescript: 4.8.3 languageName: unknown linkType: soft @@ -16567,14 +16567,14 @@ __metadata: languageName: node linkType: hard -"tsconfig-paths@npm:4.0.0": - version: 4.0.0 - resolution: "tsconfig-paths@npm:4.0.0" +"tsconfig-paths@npm:4.1.0": + version: 4.1.0 + resolution: "tsconfig-paths@npm:4.1.0" dependencies: json5: ^2.2.1 minimist: ^1.2.6 strip-bom: ^3.0.0 - checksum: a8cf746ffe438513a71c70c1bcdee8da7d62ab2af286efbe2728ff55c4d4c92c2aea80a0822982ded6d0a13c7686c24632934d7c0f4f564be9e1b2cdc3d65eea + checksum: e4b101f81b2abd95499d8145e0aa73144e857c2c359191058486cef101b7accae22a69114e5d5814a13d5ab3b0bae70dd0c85bcdb7e829bbe1bfda5c9067c9b1 languageName: node linkType: hard @@ -16857,13 +16857,13 @@ __metadata: languageName: node linkType: hard -"typescript@npm:4.8.2, typescript@npm:^4.8.2": - version: 4.8.2 - resolution: "typescript@npm:4.8.2" +"typescript@npm:4.8.3, typescript@npm:^4.8.3": + version: 4.8.3 + resolution: "typescript@npm:4.8.3" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 7f5b81d0d558c9067f952c7af52ab7f19c2e70a916817929e4a5b256c93990bf3178eccb1ac8a850bc75df35f6781b6f4cb3370ce20d8b1ded92ed462348f628 + checksum: 8286a5edcaf3d68e65c451aa1e7150ad1cf53ee0813c07ec35b7abdfdb10f355ecaa13c6a226a694ae7a67785fd7eeebf89f845da0b4f7e4a35561ddc459aba0 languageName: node linkType: hard @@ -16877,13 +16877,13 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@4.8.2#~builtin, typescript@patch:typescript@^4.8.2#~builtin": - version: 4.8.2 - resolution: "typescript@patch:typescript@npm%3A4.8.2#~builtin::version=4.8.2&hash=a1c5e5" +"typescript@patch:typescript@4.8.3#~builtin, typescript@patch:typescript@^4.8.3#~builtin": + version: 4.8.3 + resolution: "typescript@patch:typescript@npm%3A4.8.3#~builtin::version=4.8.3&hash=a1c5e5" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 5cb0f02f414f5405f4b0e7ee1fd7fa9177b6a8783c9017b6cad85f56ce4c4f93e0e6f2ce37e863cb597d44227cd009474c9fbd85bf7a50004e5557426cb58079 + checksum: 2222d2382fb3146089b1d27ce2b55e9d1f99cc64118f1aba75809b693b856c5d3c324f052f60c75b577947fc538bc1c27bad0eb76cbdba9a63a253489504ba7e languageName: node linkType: hard From dde6f5eb55e6b37ec367b8de6a23036e6a55f738 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Fri, 9 Sep 2022 00:04:26 -0400 Subject: [PATCH 027/152] foundkey-js: fix build errors The use of `"moduleResolution": "Node16"` is to make TS use the same module resolution as Node does when using ESM modules. `reconnecting-websocket`'s TS definition files were copied over but wrapped in a `declare module` block to make TS properly accept using the default import directly without using `.default`. I also decided to look into `autobind-decorator`'s source code and figured that I could use the `boundMethod` annotation directly instead of using the `autobind` default export. --- .../src/@types/reconnecting-websocket.d.ts | 144 ++++++++++++++++++ packages/foundkey-js/src/streaming.ts | 50 +++--- packages/foundkey-js/tsconfig.json | 2 +- 3 files changed, 170 insertions(+), 26 deletions(-) create mode 100644 packages/foundkey-js/src/@types/reconnecting-websocket.d.ts diff --git a/packages/foundkey-js/src/@types/reconnecting-websocket.d.ts b/packages/foundkey-js/src/@types/reconnecting-websocket.d.ts new file mode 100644 index 000000000..96fc45c25 --- /dev/null +++ b/packages/foundkey-js/src/@types/reconnecting-websocket.d.ts @@ -0,0 +1,144 @@ +/*! + * Reconnecting WebSocket + * by Pedro Ladaria + * https://github.com/pladaria/reconnecting-websocket + * License MIT + */ + +declare module 'reconnecting-websocket' { + import * as Events from './events'; + export declare type Event = Events.Event; + export declare type ErrorEvent = Events.ErrorEvent; + export declare type CloseEvent = Events.CloseEvent; + export declare type Options = { + WebSocket?: any; + maxReconnectionDelay?: number; + minReconnectionDelay?: number; + reconnectionDelayGrowFactor?: number; + minUptime?: number; + connectionTimeout?: number; + maxRetries?: number; + maxEnqueuedMessages?: number; + startClosed?: boolean; + debug?: boolean; + }; + export declare type UrlProvider = string | (() => string) | (() => Promise); + export declare type Message = string | ArrayBuffer | Blob | ArrayBufferView; + export declare type ListenersMap = { + error: Array; + message: Array; + open: Array; + close: Array; + }; + export default class ReconnectingWebSocket { + private _ws?; + private _listeners; + private _retryCount; + private _uptimeTimeout; + private _connectTimeout; + private _shouldReconnect; + private _connectLock; + private _binaryType; + private _closeCalled; + private _messageQueue; + private readonly _url; + private readonly _protocols?; + private readonly _options; + constructor(url: UrlProvider, protocols?: string | string[], options?: Options); + static readonly CONNECTING: number; + static readonly OPEN: number; + static readonly CLOSING: number; + static readonly CLOSED: number; + readonly CONNECTING: number; + readonly OPEN: number; + readonly CLOSING: number; + readonly CLOSED: number; + binaryType: BinaryType; + /** + * Returns the number or connection retries + */ + readonly retryCount: number; + /** + * The number of bytes of data that have been queued using calls to send() but not yet + * transmitted to the network. This value resets to zero once all queued data has been sent. + * This value does not reset to zero when the connection is closed; if you keep calling send(), + * this will continue to climb. Read only + */ + readonly bufferedAmount: number; + /** + * The extensions selected by the server. This is currently only the empty string or a list of + * extensions as negotiated by the connection + */ + readonly extensions: string; + /** + * A string indicating the name of the sub-protocol the server selected; + * this will be one of the strings specified in the protocols parameter when creating the + * WebSocket object + */ + readonly protocol: string; + /** + * The current state of the connection; this is one of the Ready state constants + */ + readonly readyState: number; + /** + * The URL as resolved by the constructor + */ + readonly url: string; + /** + * An event listener to be called when the WebSocket connection's readyState changes to CLOSED + */ + onclose: ((event: Events.CloseEvent) => void) | null; + /** + * An event listener to be called when an error occurs + */ + onerror: ((event: Events.ErrorEvent) => void) | null; + /** + * An event listener to be called when a message is received from the server + */ + onmessage: ((event: MessageEvent) => void) | null; + /** + * An event listener to be called when the WebSocket connection's readyState changes to OPEN; + * this indicates that the connection is ready to send and receive data + */ + onopen: ((event: Event) => void) | null; + /** + * Closes the WebSocket connection or connection attempt, if any. If the connection is already + * CLOSED, this method does nothing + */ + close(code?: number, reason?: string): void; + /** + * Closes the WebSocket connection or connection attempt and connects again. + * Resets retry counter; + */ + reconnect(code?: number, reason?: string): void; + /** + * Enqueue specified data to be transmitted to the server over the WebSocket connection + */ + send(data: Message): void; + /** + * Register an event handler of a specific event type + */ + addEventListener(type: T, listener: Events.WebSocketEventListenerMap[T]): void; + dispatchEvent(event: Event): boolean; + /** + * Removes an event listener + */ + removeEventListener(type: T, listener: Events.WebSocketEventListenerMap[T]): void; + private _debug; + private _getNextDelay; + private _wait; + private _getNextUrl; + private _connect; + private _handleTimeout; + private _disconnect; + private _acceptOpen; + private _callEventListener; + private _handleOpen; + private _handleMessage; + private _handleError; + private _handleClose; + private _removeListeners; + private _addListeners; + private _clearTimeouts; + } +} diff --git a/packages/foundkey-js/src/streaming.ts b/packages/foundkey-js/src/streaming.ts index 465f546f3..0892db9d9 100644 --- a/packages/foundkey-js/src/streaming.ts +++ b/packages/foundkey-js/src/streaming.ts @@ -1,6 +1,6 @@ -import autobind from 'autobind-decorator'; +import { boundMethod } from 'autobind-decorator'; import EventEmitter from 'eventemitter3'; -import ReconnectingWebsocket from 'reconnecting-websocket'; +import ReconnectingWebSocket from 'reconnecting-websocket'; import { BroadcastEvents, Channels } from './streaming.types.js'; export function urlQuery(obj: Record): string { @@ -25,7 +25,7 @@ type StreamEvents = { * Misskey stream connection */ export default class Stream extends EventEmitter { - private stream: ReconnectingWebsocket; + private stream: ReconnectingWebSocket; public state: 'initializing' | 'reconnecting' | 'connected' = 'initializing'; private sharedConnectionPools: Pool[] = []; private sharedConnections: SharedConnection[] = []; @@ -47,7 +47,7 @@ export default class Stream extends EventEmitter { const wsOrigin = origin.replace('http://', 'ws://').replace('https://', 'wss://'); - this.stream = new ReconnectingWebsocket(`${wsOrigin}/streaming?${query}`, '', { + this.stream = new ReconnectingWebSocket(`${wsOrigin}/streaming?${query}`, '', { minReconnectionDelay: 1, // https://github.com/pladaria/reconnecting-websocket/issues/91 WebSocket: options.WebSocket, }); @@ -56,12 +56,12 @@ export default class Stream extends EventEmitter { this.stream.addEventListener('message', this.onMessage); } - @autobind + @boundMethod private genId(): string { return (++this.idCounter).toString(); } - @autobind + @boundMethod public useChannel(channel: C, params?: Channels[C]['params'], name?: string): Connection { if (params) { return this.connectToChannel(channel, params); @@ -70,7 +70,7 @@ export default class Stream extends EventEmitter { } } - @autobind + @boundMethod private useSharedConnection(channel: C, name?: string): SharedConnection { let pool = this.sharedConnectionPools.find(p => p.channel === channel); @@ -84,24 +84,24 @@ export default class Stream extends EventEmitter { return connection; } - @autobind + @boundMethod public removeSharedConnection(connection: SharedConnection): void { this.sharedConnections = this.sharedConnections.filter(c => c !== connection); } - @autobind + @boundMethod public removeSharedConnectionPool(pool: Pool): void { this.sharedConnectionPools = this.sharedConnectionPools.filter(p => p !== pool); } - @autobind + @boundMethod private connectToChannel(channel: C, params: Channels[C]['params']): NonSharedConnection { const connection = new NonSharedConnection(this, channel, this.genId(), params); this.nonSharedConnections.push(connection); return connection; } - @autobind + @boundMethod public disconnectToChannel(connection: NonSharedConnection): void { this.nonSharedConnections = this.nonSharedConnections.filter(c => c !== connection); } @@ -109,7 +109,7 @@ export default class Stream extends EventEmitter { /** * Callback of when open connection */ - @autobind + @boundMethod private onOpen(): void { const isReconnect = this.state === 'reconnecting'; @@ -126,7 +126,7 @@ export default class Stream extends EventEmitter { /** * Callback of when close connection */ - @autobind + @boundMethod private onClose(): void { if (this.state === 'connected') { this.state = 'reconnecting'; @@ -137,7 +137,7 @@ export default class Stream extends EventEmitter { /** * Callback of when received a message from connection */ - @autobind + @boundMethod private onMessage(message: { data: string; }): void { const { type, body } = JSON.parse(message.data); @@ -167,7 +167,7 @@ export default class Stream extends EventEmitter { /** * Send a message to connection */ - @autobind + @boundMethod public send(typeOrPayload: any, payload?: any): void { const data = payload === undefined ? typeOrPayload : { type: typeOrPayload, @@ -180,7 +180,7 @@ export default class Stream extends EventEmitter { /** * Close this connection */ - @autobind + @boundMethod public close(): void { this.stream.close(); } @@ -204,12 +204,12 @@ class Pool { this.stream.on('_disconnected_', this.onStreamDisconnected); } - @autobind + @boundMethod private onStreamDisconnected(): void { this.isConnected = false; } - @autobind + @boundMethod public inc(): void { if (this.users === 0 && !this.isConnected) { this.connect(); @@ -224,7 +224,7 @@ class Pool { } } - @autobind + @boundMethod public dec(): void { this.users--; @@ -238,7 +238,7 @@ class Pool { } } - @autobind + @boundMethod public connect(): void { if (this.isConnected) return; this.isConnected = true; @@ -248,7 +248,7 @@ class Pool { }); } - @autobind + @boundMethod private disconnect(): void { this.stream.off('_disconnected_', this.onStreamDisconnected); this.stream.send('disconnect', { id: this.id }); @@ -273,7 +273,7 @@ export abstract class Connection = any> extends this.name = name; } - @autobind + @boundMethod public send(type: T, body: Channel['receives'][T]): void { this.stream.send('ch', { id: this.id, @@ -301,7 +301,7 @@ class SharedConnection = any> extends Connection this.pool.inc(); } - @autobind + @boundMethod public dispose(): void { this.pool.dec(); this.removeAllListeners(); @@ -322,7 +322,7 @@ class NonSharedConnection = any> extends Connect this.connect(); } - @autobind + @boundMethod public connect(): void { this.stream.send('connect', { channel: this.channel, @@ -331,7 +331,7 @@ class NonSharedConnection = any> extends Connect }); } - @autobind + @boundMethod public dispose(): void { this.removeAllListeners(); this.stream.send('disconnect', { id: this.id }); diff --git a/packages/foundkey-js/tsconfig.json b/packages/foundkey-js/tsconfig.json index 6813e1f57..83de431b1 100644 --- a/packages/foundkey-js/tsconfig.json +++ b/packages/foundkey-js/tsconfig.json @@ -15,7 +15,7 @@ "experimentalDecorators": true, "noImplicitReturns": true, "esModuleInterop": true, - "moduleResolution": "node" + "moduleResolution": "Node16" }, "include": [ "src/**/*" From f0a2d368a3ebc6fbbd7dca229ea614fb2aedba47 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Sat, 10 Sep 2022 02:05:56 -0400 Subject: [PATCH 028/152] foundkey-js: use re-export syntax --- packages/foundkey-js/src/index.ts | 35 +++++++++++-------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/packages/foundkey-js/src/index.ts b/packages/foundkey-js/src/index.ts index 3768fdda5..ba4d356af 100644 --- a/packages/foundkey-js/src/index.ts +++ b/packages/foundkey-js/src/index.ts @@ -1,26 +1,15 @@ -import { Endpoints } from './api.types.js'; -import Stream, { Connection } from './streaming.js'; -import { Channels } from './streaming.types.js'; -import { Acct } from './acct.js'; -import * as consts from './consts.js'; - +export { Endpoints } from './api.types.js'; +export { default as Stream, Connection as ChannelConnection } from './streaming.js'; +export { Channels } from './streaming.types.js'; +export { Acct } from './acct.js'; export { - Endpoints, - Stream, - Connection as ChannelConnection, - Channels, - Acct, -}; - -export const permissions = consts.permissions; -export const notificationTypes = consts.notificationTypes; -export const noteVisibilities = consts.noteVisibilities; -export const mutedNoteReasons = consts.mutedNoteReasons; -export const ffVisibility = consts.ffVisibility; + permissions, + notificationTypes, + noteVisibilities, + mutedNoteReasons, + ffVisibility, +} from './consts.js'; // api extractor not supported yet -//export * as api from './api'; -//export * as entities from './entities'; -import * as api from './api.js'; -import * as entities from './entities.js'; -export { api, entities }; +export * as api from './api.js'; +export * as entities from './entities.js'; From d65b0731927c108b163b12afaca94bb96325bbc4 Mon Sep 17 00:00:00 2001 From: Michcio Date: Sat, 10 Sep 2022 09:13:19 +0200 Subject: [PATCH 029/152] foundkey-js: Sync possible endpoints from backend I noticed while trying to pick up work on mkbread on a train that the translate endpoint was missing so here it is now. I just copy-pasted the list of endpoints in the order that they were in in the backend and copied back the existing type annotations. It doesn't feel reasonable to invest more time in the typings if we might have a chance at creating the one-source-of-truth elseway. --- packages/foundkey-js/src/api.types.ts | 205 +++++++++----------------- 1 file changed, 67 insertions(+), 138 deletions(-) diff --git a/packages/foundkey-js/src/api.types.ts b/packages/foundkey-js/src/api.types.ts index 51028c805..df1c98879 100644 --- a/packages/foundkey-js/src/api.types.ts +++ b/packages/foundkey-js/src/api.types.ts @@ -12,17 +12,48 @@ type NoParams = Record; type ShowUserReq = { username: string; host?: string; } | { userId: User['id']; }; export type Endpoints = { - // admin + 'admin/meta': { req: TODO; res: TODO; }; 'admin/abuse-user-reports': { req: TODO; res: TODO; }; + 'admin/accounts/create': { req: TODO; res: TODO; }; + 'admin/accounts/delete': { req: TODO; res: TODO; }; + 'admin/announcements/create': { req: TODO; res: TODO; }; + 'admin/announcements/delete': { req: { id: Announcement['id'] }; res: null; }; + 'admin/announcements/list': { req: TODO; res: TODO; }; + 'admin/announcements/update': { req: TODO; res: TODO; }; 'admin/delete-all-files-of-a-user': { req: { userId: User['id']; }; res: null; }; - 'admin/delete-logs': { req: NoParams; res: null; }; + 'admin/drive/clean-remote-files': { req: TODO; res: TODO; }; + 'admin/drive/files': { req: TODO; res: TODO; }; + 'admin/drive/show-file': { req: TODO; res: TODO; }; + 'admin/emoji/add-aliases-bulk': { req: TODO; res: TODO; }; + 'admin/emoji/add': { req: TODO; res: TODO; }; + 'admin/emoji/copy': { req: TODO; res: TODO; }; + 'admin/emoji/delete-bulk': { req: TODO; res: TODO; }; + 'admin/emoji/delete': { req: TODO; res: TODO; }; + 'admin/emoji/import-zip': { req: TODO; res: TODO; }; + 'admin/emoji/list-remote': { req: TODO; res: TODO; }; + 'admin/emoji/list': { req: TODO; res: TODO; }; + 'admin/emoji/remove-aliases-bulk': { req: TODO; res: TODO; }; + 'admin/emoji/set-aliases-bulk': { req: TODO; res: TODO; }; + 'admin/emoji/set-category-bulk': { req: TODO; res: TODO; }; + 'admin/emoji/update': { req: TODO; res: TODO; }; + 'admin/federation/delete-all-files': { req: { host: string }; res: null; }; + 'admin/federation/refresh-remote-instance-metadata': { req: TODO; res: TODO; }; + 'admin/federation/remove-all-following': { req: TODO; res: TODO; }; + 'admin/federation/update-instance': { req: TODO; res: TODO; }; 'admin/get-index-stats': { req: TODO; res: TODO; }; 'admin/get-table-stats': { req: TODO; res: TODO; }; 'admin/invite': { req: TODO; res: TODO; }; - 'admin/logs': { req: TODO; res: TODO; }; + 'admin/moderators/add': { req: TODO; res: TODO; }; + 'admin/moderators/remove': { req: TODO; res: TODO; }; + 'admin/queue/clear': { req: TODO; res: TODO; }; + 'admin/queue/deliver-delayed': { req: TODO; res: TODO; }; + 'admin/queue/inbox-delayed': { req: TODO; res: TODO; }; + 'admin/queue/stats': { req: TODO; res: TODO; }; + 'admin/relays/add': { req: TODO; res: TODO; }; + 'admin/relays/list': { req: TODO; res: TODO; }; + 'admin/relays/remove': { req: TODO; res: TODO; }; 'admin/reset-password': { req: TODO; res: TODO; }; 'admin/resolve-abuse-user-report': { req: TODO; res: TODO; }; - 'admin/resync-chart': { req: TODO; res: TODO; }; 'admin/send-email': { req: TODO; res: TODO; }; 'admin/server-info': { req: TODO; res: TODO; }; 'admin/show-moderation-logs': { req: TODO; res: TODO; }; @@ -34,53 +65,14 @@ export type Endpoints = { 'admin/unsuspend-user': { req: TODO; res: TODO; }; 'admin/update-meta': { req: TODO; res: TODO; }; 'admin/vacuum': { req: TODO; res: TODO; }; - 'admin/accounts/create': { req: TODO; res: TODO; }; - 'admin/ad/create': { req: TODO; res: TODO; }; - 'admin/ad/delete': { req: { id: Ad['id']; }; res: null; }; - 'admin/ad/list': { req: TODO; res: TODO; }; - 'admin/ad/update': { req: TODO; res: TODO; }; - 'admin/announcements/create': { req: TODO; res: TODO; }; - 'admin/announcements/delete': { req: { id: Announcement['id'] }; res: null; }; - 'admin/announcements/list': { req: TODO; res: TODO; }; - 'admin/announcements/update': { req: TODO; res: TODO; }; - 'admin/drive/clean-remote-files': { req: TODO; res: TODO; }; - 'admin/drive/cleanup': { req: TODO; res: TODO; }; - 'admin/drive/files': { req: TODO; res: TODO; }; - 'admin/drive/show-file': { req: TODO; res: TODO; }; - 'admin/emoji/add': { req: TODO; res: TODO; }; - 'admin/emoji/copy': { req: TODO; res: TODO; }; - 'admin/emoji/list-remote': { req: TODO; res: TODO; }; - 'admin/emoji/list': { req: TODO; res: TODO; }; - 'admin/emoji/remove': { req: TODO; res: TODO; }; - 'admin/emoji/update': { req: TODO; res: TODO; }; - 'admin/federation/delete-all-files': { req: { host: string; }; res: null; }; - 'admin/federation/refresh-remote-instance-metadata': { req: TODO; res: TODO; }; - 'admin/federation/remove-all-following': { req: TODO; res: TODO; }; - 'admin/federation/update-instance': { req: TODO; res: TODO; }; - 'admin/moderators/add': { req: TODO; res: TODO; }; - 'admin/moderators/remove': { req: TODO; res: TODO; }; - 'admin/promo/create': { req: TODO; res: TODO; }; - 'admin/queue/clear': { req: TODO; res: TODO; }; - 'admin/queue/deliver-delayed': { req: TODO; res: TODO; }; - 'admin/queue/inbox-delayed': { req: TODO; res: TODO; }; - 'admin/queue/jobs': { req: TODO; res: TODO; }; - 'admin/queue/stats': { req: TODO; res: TODO; }; - 'admin/relays/add': { req: TODO; res: TODO; }; - 'admin/relays/list': { req: TODO; res: TODO; }; - 'admin/relays/remove': { req: TODO; res: TODO; }; - - // announcements + 'admin/delete-account': { req: TODO; res: TODO; }; 'announcements': { req: { limit?: number; withUnreads?: boolean; sinceId?: Announcement['id']; untilId?: Announcement['id']; }; res: Announcement[]; }; - - // antennas 'antennas/create': { req: TODO; res: Antenna; }; 'antennas/delete': { req: { antennaId: Antenna['id']; }; res: null; }; 'antennas/list': { req: NoParams; res: Antenna[]; }; 'antennas/notes': { req: { antennaId: Antenna['id']; limit?: number; sinceId?: Note['id']; untilId?: Note['id']; }; res: Note[]; }; 'antennas/show': { req: { antennaId: Antenna['id']; }; res: Antenna; }; 'antennas/update': { req: TODO; res: Antenna; }; - - // ap 'ap/get': { req: { uri: string; }; res: Record; }; 'ap/show': { req: { uri: string; }; res: { type: 'Note'; @@ -89,35 +81,24 @@ export type Endpoints = { type: 'User'; object: UserDetailed; }; }; - - // app 'app/create': { req: TODO; res: App; }; 'app/show': { req: { appId: App['id']; }; res: App; }; - - // auth 'auth/accept': { req: { token: string; }; res: null; }; 'auth/session/generate': { req: { appSecret: string; }; res: { token: string; url: string; }; }; 'auth/session/show': { req: { token: string; }; res: AuthSession; }; 'auth/session/userkey': { req: { appSecret: string; token: string; }; res: { accessToken: string; user: User }; }; - - // blocking 'blocking/create': { req: { userId: User['id'] }; res: UserDetailed; }; 'blocking/delete': { req: { userId: User['id'] }; res: UserDetailed; }; 'blocking/list': { req: { limit?: number; sinceId?: Blocking['id']; untilId?: Blocking['id']; }; res: Blocking[]; }; - - // channels 'channels/create': { req: TODO; res: TODO; }; 'channels/featured': { req: TODO; res: TODO; }; 'channels/follow': { req: TODO; res: TODO; }; 'channels/followed': { req: TODO; res: TODO; }; 'channels/owned': { req: TODO; res: TODO; }; - 'channels/pin-note': { req: TODO; res: TODO; }; 'channels/show': { req: TODO; res: TODO; }; 'channels/timeline': { req: TODO; res: TODO; }; 'channels/unfollow': { req: TODO; res: TODO; }; 'channels/update': { req: TODO; res: TODO; }; - - // charts 'charts/active-users': { req: { span: 'day' | 'hour'; limit?: number; offset?: number | null; }; res: { local: { users: number[]; @@ -126,6 +107,7 @@ export type Endpoints = { users: number[]; }; }; }; + 'charts/ap-request': { req: TODO; res: TODO; }; 'charts/drive': { req: { span: 'day' | 'hour'; limit?: number; offset?: number | null; }; res: { local: { decCount: number[]; @@ -192,7 +174,6 @@ export type Endpoints = { total: number[]; }; }; }; - 'charts/network': { req: { span: 'day' | 'hour'; limit?: number; offset?: number | null; }; res: TODO; }; 'charts/notes': { req: { span: 'day' | 'hour'; limit?: number; offset?: number | null; }; res: { local: { dec: number[]; @@ -247,17 +228,14 @@ export type Endpoints = { total: number[]; }; }; }; - - // clips 'clips/add-note': { req: TODO; res: TODO; }; + 'clips/remove-note': { req: TODO; res: TODO; }; 'clips/create': { req: TODO; res: TODO; }; 'clips/delete': { req: { clipId: Clip['id']; }; res: null; }; 'clips/list': { req: TODO; res: TODO; }; 'clips/notes': { req: TODO; res: TODO; }; 'clips/show': { req: TODO; res: TODO; }; 'clips/update': { req: TODO; res: TODO; }; - - // drive 'drive': { req: NoParams; res: { capacity: number; usage: number; }; }; 'drive/files': { req: { folderId?: DriveFolder['id'] | null; type?: DriveFile['type'] | null; limit?: number; sinceId?: DriveFile['id']; untilId?: DriveFile['id']; }; res: DriveFile[]; }; 'drive/files/attached-notes': { req: TODO; res: TODO; }; @@ -276,20 +254,10 @@ export type Endpoints = { 'drive/folders/show': { req: { folderId: DriveFolder['id']; }; res: DriveFolder; }; 'drive/folders/update': { req: { folderId: DriveFolder['id']; name?: string; parentId?: DriveFolder['id'] | null; }; res: DriveFolder; }; 'drive/stream': { req: { type?: DriveFile['type'] | null; limit?: number; sinceId?: DriveFile['id']; untilId?: DriveFile['id']; }; res: DriveFile[]; }; - - // endpoint + 'email-address/available': { req: TODO; res: TODO; }; 'endpoint': { req: { endpoint: string; }; res: { params: { name: string; type: string; }[]; }; }; - - // endpoints 'endpoints': { req: NoParams; res: string[]; }; - - // federation - 'federation/dns': { req: { host: string; }; res: { - a: string[]; - aaaa: string[]; - cname: string[]; - txt: string[]; - }; }; + 'export-custom-emojis': { req: TODO; res: TODO; }; 'federation/followers': { req: { host: string; limit?: number; sinceId?: Following['id']; untilId?: Following['id']; }; res: FollowingFolloweePopulated[]; }; 'federation/following': { req: { host: string; limit?: number; sinceId?: Following['id']; untilId?: Following['id']; }; res: FollowingFolloweePopulated[]; }; 'federation/instances': { req: { @@ -307,16 +275,14 @@ export type Endpoints = { 'federation/show-instance': { req: { host: string; }; res: Instance; }; 'federation/update-remote-user': { req: { userId: User['id']; }; res: null; }; 'federation/users': { req: { host: string; limit?: number; sinceId?: User['id']; untilId?: User['id']; }; res: UserDetailed[]; }; - - // following + 'federation/stats': { req: TODO; res: TODO; }; 'following/create': { req: { userId: User['id'] }; res: User; }; 'following/delete': { req: { userId: User['id'] }; res: User; }; + 'following/invalidate': { req: TODO; res: TODO; }; 'following/requests/accept': { req: { userId: User['id'] }; res: null; }; 'following/requests/cancel': { req: { userId: User['id'] }; res: User; }; 'following/requests/list': { req: NoParams; res: FollowRequest[]; }; 'following/requests/reject': { req: { userId: User['id'] }; res: null; }; - - // gallery 'gallery/featured': { req: TODO; res: TODO; }; 'gallery/popular': { req: TODO; res: TODO; }; 'gallery/posts': { req: TODO; res: TODO; }; @@ -326,27 +292,20 @@ export type Endpoints = { 'gallery/posts/show': { req: TODO; res: TODO; }; 'gallery/posts/unlike': { req: TODO; res: TODO; }; 'gallery/posts/update': { req: TODO; res: TODO; }; - - // games - 'games/reversi/games': { req: TODO; res: TODO; }; - 'games/reversi/games/show': { req: TODO; res: TODO; }; - 'games/reversi/games/surrender': { req: TODO; res: TODO; }; - 'games/reversi/invitations': { req: TODO; res: TODO; }; - 'games/reversi/match': { req: TODO; res: TODO; }; - 'games/reversi/match/cancel': { req: TODO; res: TODO; }; - - // get-online-users-count - 'get-online-users-count': { req: NoParams; res: { count: number; }; }; - - // hashtags + 'get-online-users-count': { req: TODO; res: TODO; }; 'hashtags/list': { req: TODO; res: TODO; }; 'hashtags/search': { req: TODO; res: TODO; }; 'hashtags/show': { req: TODO; res: TODO; }; 'hashtags/trend': { req: TODO; res: TODO; }; 'hashtags/users': { req: TODO; res: TODO; }; - - // i 'i': { req: NoParams; res: User; }; + 'i/2fa/done': { req: TODO; res: TODO; }; + 'i/2fa/key-done': { req: TODO; res: TODO; }; + 'i/2fa/password-less': { req: TODO; res: TODO; }; + 'i/2fa/register-key': { req: TODO; res: TODO; }; + 'i/2fa/register': { req: TODO; res: TODO; }; + 'i/2fa/remove-key': { req: TODO; res: TODO; }; + 'i/2fa/unregister': { req: TODO; res: TODO; }; 'i/apps': { req: TODO; res: TODO; }; 'i/authorized-apps': { req: TODO; res: TODO; }; 'i/change-password': { req: TODO; res: TODO; }; @@ -360,7 +319,9 @@ export type Endpoints = { 'i/gallery/likes': { req: TODO; res: TODO; }; 'i/gallery/posts': { req: TODO; res: TODO; }; 'i/get-word-muted-notes-count': { req: TODO; res: TODO; }; + 'i/import-blocking': { req: TODO; res: TODO; }; 'i/import-following': { req: TODO; res: TODO; }; + 'i/import-muting': { req: TODO; res: TODO; }; 'i/import-user-lists': { req: TODO; res: TODO; }; 'i/notifications': { req: { limit?: number; @@ -421,22 +382,16 @@ export type Endpoints = { emailNotificationTypes?: string[]; }; res: MeDetailed; }; 'i/user-group-invites': { req: TODO; res: TODO; }; - 'i/2fa/done': { req: TODO; res: TODO; }; - 'i/2fa/key-done': { req: TODO; res: TODO; }; - 'i/2fa/password-less': { req: TODO; res: TODO; }; - 'i/2fa/register-key': { req: TODO; res: TODO; }; - 'i/2fa/register': { req: TODO; res: TODO; }; - 'i/2fa/remove-key': { req: TODO; res: TODO; }; - 'i/2fa/unregister': { req: TODO; res: TODO; }; - - // messaging + 'i/webhooks/create': { req: TODO; res: TODO; }; + 'i/webhooks/list': { req: TODO; res: TODO; }; + 'i/webhooks/show': { req: TODO; res: TODO; }; + 'i/webhooks/update': { req: TODO; res: TODO; }; + 'i/webhooks/delete': { req: TODO; res: TODO; }; 'messaging/history': { req: { limit?: number; group?: boolean; }; res: MessagingMessage[]; }; 'messaging/messages': { req: { userId?: User['id']; groupId?: UserGroup['id']; limit?: number; sinceId?: MessagingMessage['id']; untilId?: MessagingMessage['id']; markAsRead?: boolean; }; res: MessagingMessage[]; }; 'messaging/messages/create': { req: { userId?: User['id']; groupId?: UserGroup['id']; text?: string; fileId?: DriveFile['id']; }; res: MessagingMessage; }; 'messaging/messages/delete': { req: { messageId: MessagingMessage['id']; }; res: null; }; 'messaging/messages/read': { req: { messageId: MessagingMessage['id']; }; res: null; }; - - // meta 'meta': { req: { detail?: boolean; }; res: { $switch: { $cases: [[ @@ -452,19 +407,11 @@ export type Endpoints = { $default: LiteInstanceMetadata; }; }; }; - - // miauth 'miauth/gen-token': { req: TODO; res: TODO; }; - - // mute 'mute/create': { req: TODO; res: TODO; }; 'mute/delete': { req: { userId: User['id'] }; res: null; }; 'mute/list': { req: TODO; res: TODO; }; - - // my 'my/apps': { req: TODO; res: TODO; }; - - // notes 'notes': { req: { limit?: number; sinceId?: Note['id']; untilId?: Note['id']; }; res: Note[]; }; 'notes/children': { req: { noteId: Note['id']; limit?: number; sinceId?: Note['id']; untilId?: Note['id']; }; res: Note[]; }; 'notes/clips': { req: TODO; res: TODO; }; @@ -506,21 +453,18 @@ export type Endpoints = { 'notes/search': { req: TODO; res: TODO; }; 'notes/show': { req: { noteId: Note['id']; }; res: Note; }; 'notes/state': { req: TODO; res: TODO; }; + 'notes/thread-muting/create': { req: TODO; res: TODO; }; + 'notes/thread-muting/delete': { req: TODO; res: TODO; }; 'notes/timeline': { req: { limit?: number; sinceId?: Note['id']; untilId?: Note['id']; sinceDate?: number; untilDate?: number; }; res: Note[]; }; + 'notes/translate': { req: TODO; res: TODO; }; 'notes/unrenote': { req: { noteId: Note['id']; }; res: null; }; 'notes/user-list-timeline': { req: { listId: UserList['id']; limit?: number; sinceId?: Note['id']; untilId?: Note['id']; sinceDate?: number; untilDate?: number; }; res: Note[]; }; 'notes/watching/create': { req: TODO; res: TODO; }; 'notes/watching/delete': { req: { noteId: Note['id']; }; res: null; }; - - // notifications 'notifications/create': { req: { body: string; header?: string | null; icon?: string | null; }; res: null; }; 'notifications/mark-all-as-read': { req: NoParams; res: null; }; 'notifications/read': { req: { notificationId: Notification['id']; }; res: null; }; - - // page-push 'page-push': { req: { pageId: Page['id']; event: string; var?: any; }; res: null; }; - - // pages 'pages/create': { req: TODO; res: Page; }; 'pages/delete': { req: { pageId: Page['id']; }; res: null; }; 'pages/featured': { req: NoParams; res: Page[]; }; @@ -528,35 +472,17 @@ export type Endpoints = { 'pages/show': { req: { pageId?: Page['id']; name?: string; username?: string; }; res: Page; }; 'pages/unlike': { req: { pageId: Page['id']; }; res: null; }; 'pages/update': { req: TODO; res: null; }; - - // ping 'ping': { req: NoParams; res: { pong: number; }; }; - - // pinned-users 'pinned-users': { req: TODO; res: TODO; }; - - // promo - 'promo/read': { req: TODO; res: TODO; }; - - // request-reset-password 'request-reset-password': { req: { username: string; email: string; }; res: null; }; - - // reset-password + 'reset-db': { req: TODO; res: TODO; }; 'reset-password': { req: { token: string; password: string; }; res: null; }; - - // stats - 'stats': { req: NoParams; res: Stats; }; - - // server-info 'server-info': { req: NoParams; res: ServerInfo; }; - - // sw + 'stats': { req: NoParams; res: Stats; }; 'sw/register': { req: TODO; res: TODO; }; - - // username + 'sw/unregister': { req: TODO; res: TODO; }; + 'test': { req: TODO; res: TODO; }; 'username/available': { req: { username: string; }; res: { available: boolean; }; }; - - // users 'users': { req: { limit?: number; offset?: number; sort?: UserSorting; origin?: OriginType; }; res: User[]; }; 'users/clips': { req: TODO; res: TODO; }; 'users/followers': { req: { userId?: User['id']; username?: User['username']; host?: User['host'] | null; limit?: number; sinceId?: Following['id']; untilId?: Following['id']; }; res: FollowingFollowerPopulated[]; }; @@ -569,6 +495,7 @@ export type Endpoints = { 'users/groups/invitations/reject': { req: TODO; res: TODO; }; 'users/groups/invite': { req: TODO; res: TODO; }; 'users/groups/joined': { req: TODO; res: TODO; }; + 'users/groups/leave': { req: TODO; res: TODO; }; 'users/groups/owned': { req: TODO; res: TODO; }; 'users/groups/pull': { req: TODO; res: TODO; }; 'users/groups/show': { req: TODO; res: TODO; }; @@ -583,6 +510,7 @@ export type Endpoints = { 'users/lists/update': { req: { listId: UserList['id']; name: string; }; res: UserList; }; 'users/notes': { req: { userId: User['id']; limit?: number; sinceId?: Note['id']; untilId?: Note['id']; sinceDate?: number; untilDate?: number; }; res: Note[]; }; 'users/pages': { req: TODO; res: TODO; }; + 'users/reactions': { req: TODO; res: TODO; }; 'users/recommendation': { req: TODO; res: TODO; }; 'users/relation': { req: TODO; res: TODO; }; 'users/report-abuse': { req: TODO; res: TODO; }; @@ -598,4 +526,5 @@ export type Endpoints = { }; }; }; 'users/stats': { req: TODO; res: TODO; }; + 'fetch-rss': { req: TODO; res: TODO; }; }; From ebc4daa6c2d73986fbdb9ac57fd576c4d094832d Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Sat, 10 Sep 2022 12:25:58 -0400 Subject: [PATCH 030/152] refactor: number-diff.vue to composition api --- .../client/src/components/number-diff.vue | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/packages/client/src/components/number-diff.vue b/packages/client/src/components/number-diff.vue index e7d4a5472..921337bde 100644 --- a/packages/client/src/components/number-diff.vue +++ b/packages/client/src/components/number-diff.vue @@ -4,30 +4,17 @@ - - - - - - - - - - - - - From 7854abb7412384debecb93eb64fb835b86a9abf2 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Mon, 12 Sep 2022 10:37:22 +0200 Subject: [PATCH 038/152] remove unusable setting to send error reports Changelog: Removed --- locales/ar-SA.yml | 2 -- locales/bn-BD.yml | 2 -- locales/de-DE.yml | 2 -- locales/en-US.yml | 2 -- locales/es-ES.yml | 2 -- locales/fr-FR.yml | 2 -- locales/id-ID.yml | 2 -- locales/it-IT.yml | 2 -- locales/ja-JP.yml | 2 -- locales/ja-KS.yml | 2 -- locales/ko-KR.yml | 2 -- locales/pl-PL.yml | 1 - locales/ru-RU.yml | 2 -- locales/sk-SK.yml | 2 -- locales/uk-UA.yml | 2 -- locales/vi-VN.yml | 2 -- locales/zh-CN.yml | 2 -- locales/zh-TW.yml | 2 -- packages/client/src/pages/settings/other.vue | 8 -------- packages/client/src/store.ts | 4 ---- 20 files changed, 47 deletions(-) diff --git a/locales/ar-SA.yml b/locales/ar-SA.yml index 19b7833a0..7a7410930 100644 --- a/locales/ar-SA.yml +++ b/locales/ar-SA.yml @@ -660,8 +660,6 @@ clearCache: "امسح التخزين المؤقت" onlineUsersCount: "{n} مستخدم متصل" nUsers: "{n} مستخدم" nNotes: "{n} ملاحظة" -sendErrorReports: "أرسل تقارير الأخطاء" -sendErrorReportsDescription: "إذا فعّلته ستساعد في تحسين ميسكي وذلك عبر مشاركة معلومات تفصيلية عن الخطأ.\nومما تحتويه التقارير: نسخة نظام التشغيل ونوع المتصفح وسجل نشاطك إلخ." myTheme: "سماتي" backgroundColor: "لون الخلفية" accentColor: "طابع لوني" diff --git a/locales/bn-BD.yml b/locales/bn-BD.yml index 7229eac85..77aa8455d 100644 --- a/locales/bn-BD.yml +++ b/locales/bn-BD.yml @@ -690,8 +690,6 @@ clearCache: "ক্যাশ পরিষ্কার করুন" onlineUsersCount: "{n} জন ব্যাবহারকারী অনলাইন" nUsers: "{n} জন ব্যাবহারকারী" nNotes: "{n} টি নোট" -sendErrorReports: "ক্রুটি প্রতিবেদন পাঠান" -sendErrorReportsDescription: "চালু থাকলে, বিস্তারিত ত্রুটির তথ্য Misskey-এর সাথে শেয়ার করা হয়। যা সফ্টওয়্যারটির গুণমান উন্নত করতে সাহায্য করে। ত্রুটির তথ্যের মধ্যে রয়েছে OS সংস্করণ, ব্রাউজারের ধরন, কর্মের ইতিহাস ইত্যাদি।" myTheme: "আমার থিম" backgroundColor: "পটভূমির রং" accentColor: "এক্সেন্টের রং" diff --git a/locales/de-DE.yml b/locales/de-DE.yml index 1e10c5e98..1004319fd 100644 --- a/locales/de-DE.yml +++ b/locales/de-DE.yml @@ -691,8 +691,6 @@ clearCache: "Cache leeren" onlineUsersCount: "{n} Benutzer sind online" nUsers: "{n} Benutzer" nNotes: "{n} Notizen" -sendErrorReports: "Fehlerberichte senden" -sendErrorReportsDescription: "Ist diese Option aktiviert, so werden beim Auftreten von Fehlern detaillierte Fehlerinformationen an Misskey weitergegeben, was zur Verbesserung der Qualität von Misskey beiträgt.\nEnthalten in diesen Informationen sind u.a. die Version deines Betriebssystems, welchen Browser du verwendest und ein Verlauf deiner Aktivitäten innerhalb Misskey." myTheme: "Mein Farbschema" backgroundColor: "Hintergrundfarbe" accentColor: "Akzentfarbe" diff --git a/locales/en-US.yml b/locales/en-US.yml index ca99048bc..d9b774f2c 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -691,8 +691,6 @@ clearCache: "Clear cache" onlineUsersCount: "{n} users are online" nUsers: "{n} Users" nNotes: "{n} Notes" -sendErrorReports: "Send error reports" -sendErrorReportsDescription: "When turned on, detailed error information will be shared with Misskey when a problem occurs, helping to improve the quality of Misskey.\nThis will include information such the version of your OS, what browser you're using, your activity in Misskey, etc." myTheme: "My theme" backgroundColor: "Background color" accentColor: "Accent color" diff --git a/locales/es-ES.yml b/locales/es-ES.yml index 002a3b305..d426c205c 100644 --- a/locales/es-ES.yml +++ b/locales/es-ES.yml @@ -687,8 +687,6 @@ clearCache: "Limpiar caché" onlineUsersCount: "{n} usuarios en línea" nUsers: "{n} Usuarios" nNotes: "{n} Notas" -sendErrorReports: "Envíar informe de errores" -sendErrorReportsDescription: "Si habilita esta opción, ayudará a mejorar la calidad de Misskey compartiendo información detallada sobre los errores cuando se produzca un problema.\nEsto incluye información como la versión de su sistema operativo, el tipo de navegador que utiliza, su historial de actividad, etc." myTheme: "Mi Tema" backgroundColor: "Fondo" accentColor: "Acento" diff --git a/locales/fr-FR.yml b/locales/fr-FR.yml index 0ae13945d..d2b66f7d7 100644 --- a/locales/fr-FR.yml +++ b/locales/fr-FR.yml @@ -685,8 +685,6 @@ clearCache: "Vider le cache" onlineUsersCount: "{n} utilisateur(s) en ligne" nUsers: "{n} utilisateur·rice·s" nNotes: "{n} Notes" -sendErrorReports: "Envoyer les rapports d’erreur" -sendErrorReportsDescription: "Si vous activez l'envoi des rapports d'erreur, vous contribuerez à améliorer la qualité de Misskey grâce au partage d'informations détaillées sur les erreurs lorsqu'un problème survient.\nCela inclut des informations telles que la version de votre système d'exploitation, le type de navigateur que vous utilisez, votre historique d'activité, etc." myTheme: "Mes thèmes" backgroundColor: "Arrière-plan" accentColor: "Accentuation" diff --git a/locales/id-ID.yml b/locales/id-ID.yml index ff439ceb4..efbb36147 100644 --- a/locales/id-ID.yml +++ b/locales/id-ID.yml @@ -690,8 +690,6 @@ clearCache: "Hapus tembolok" onlineUsersCount: "{n} orang sedang daring" nUsers: "{n} Pengguna" nNotes: "{n} Catatan" -sendErrorReports: "Kirim laporan kesalahan" -sendErrorReportsDescription: "Ketika dinyalakan, informasi kesalahan rinci akan dibagikan dengan Misskey ketika masalah terjadi, hal ini untuk membantu kualitas Misskey. Fitur ini memungkinkan memuat informasi seperti sistem operasi yang kamu gunakan dan versinya, aplikasi peramban yang kamu gunakan, riwayat aktivitas kamu, dll." myTheme: "Tema saya" backgroundColor: "Latar Belakang" accentColor: "Aksen" diff --git a/locales/it-IT.yml b/locales/it-IT.yml index 3da0d0fb4..07028b24b 100644 --- a/locales/it-IT.yml +++ b/locales/it-IT.yml @@ -681,8 +681,6 @@ clearCache: "Svuota cache" onlineUsersCount: "{n} utenti online" nUsers: "{n} utenti" nNotes: "{n}Note" -sendErrorReports: "Invia segnalazioni di errori" -sendErrorReportsDescription: "Quando abilitato, se si verifica un problema, informazioni dettagliate sugli errori verranno condivise con Misskey in modo da aiutare a migliorare la qualità del software.\nCiò include informazioni come la versione del sistema operativo, il tipo di navigatore web che usi, la cronologia delle attività, ecc." myTheme: "I miei temi" backgroundColor: "Sfondo" textColor: "Testo" diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index acf0fff4f..81c5a348d 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -693,8 +693,6 @@ clearCache: "キャッシュをクリア" onlineUsersCount: "{n}人がオンライン" nUsers: "{n}ユーザー" nNotes: "{n}ノート" -sendErrorReports: "エラーリポートを送信" -sendErrorReportsDescription: "オンにすると、問題が発生したときにエラーの詳細情報がMisskeyに共有され、ソフトウェアの品質向上に役立てることができます。エラー情報には、OSのバージョン、ブラウザの種類、行動履歴などが含まれます。" myTheme: "マイテーマ" backgroundColor: "背景" accentColor: "アクセント" diff --git a/locales/ja-KS.yml b/locales/ja-KS.yml index cc19369e5..f8233fd62 100644 --- a/locales/ja-KS.yml +++ b/locales/ja-KS.yml @@ -604,8 +604,6 @@ clearCache: "キャッシュをほかす" onlineUsersCount: "{n}人が起きとるで" nUsers: "{n}ユーザー" nNotes: "{n}ノート" -sendErrorReports: "エラーリポートを送る" -sendErrorReportsDescription: "オンにしたら、なんか変なことが起きたときにエラーの詳細がMisskeyに共有されて、ソフトウェアの品質向上に役立てられるんや。エラー情報には、OSのバージョン、ブラウザの種類、行動履歴などが含まれるで。" myTheme: "マイテーマ" backgroundColor: "背景" accentColor: "アクセント" diff --git a/locales/ko-KR.yml b/locales/ko-KR.yml index da3977d91..68397cd7d 100644 --- a/locales/ko-KR.yml +++ b/locales/ko-KR.yml @@ -690,8 +690,6 @@ clearCache: "캐시 비우기" onlineUsersCount: "{n}명이 접속 중" nUsers: "{n} 유저" nNotes: "{n} 노트" -sendErrorReports: "오류 보고서 보내기" -sendErrorReportsDescription: "이 설정을 활성화하면, 문제가 발생했을 때 오류에 대한 상세 정보를 Misskey에 보내어 더 나은 소프트웨어를 만드는 데에 도움을 줄 수 있습니다." myTheme: "내 테마" backgroundColor: "배경 색" accentColor: "강조 색상" diff --git a/locales/pl-PL.yml b/locales/pl-PL.yml index 79e64b055..18c23e2d6 100644 --- a/locales/pl-PL.yml +++ b/locales/pl-PL.yml @@ -666,7 +666,6 @@ clearCache: "Wyczyść pamięć podręczną" onlineUsersCount: "{n} osób jest online" nUsers: "{n} użytkowników" nNotes: "{n} wpisów" -sendErrorReports: "Wyślij raporty o błędach" myTheme: "Mój motyw" backgroundColor: "Tło" accentColor: "Akcent" diff --git a/locales/ru-RU.yml b/locales/ru-RU.yml index ac26d88ee..26c8651b1 100644 --- a/locales/ru-RU.yml +++ b/locales/ru-RU.yml @@ -688,8 +688,6 @@ clearCache: "Очистить кэш" onlineUsersCount: "Пользователей сейчас в сети: {n}" nUsers: "Пользователей: {n}" nNotes: "Заметок: {n}" -sendErrorReports: "Посылать отчёты о сбоях" -sendErrorReportsDescription: "Если включено, когда возникнет какая-нибудь техническая проблема, подробные сведения об этом будут отправлены разработчикам Misskey. Это очень помогает делать программу лучше. В отчёты попадают тип и версия ОС, браузера, журнал действий (что привело к сбою) и тому подобное." myTheme: "Личная тема" backgroundColor: "Фон" accentColor: "Акцент" diff --git a/locales/sk-SK.yml b/locales/sk-SK.yml index 267e0967b..3e687ec27 100644 --- a/locales/sk-SK.yml +++ b/locales/sk-SK.yml @@ -689,8 +689,6 @@ clearCache: "Vyprázdniť cache" onlineUsersCount: "{n} používateľov je online" nUsers: "{n} používateľov" nNotes: "{n} poznámok" -sendErrorReports: "Poslať nahlásenie chyby" -sendErrorReportsDescription: "Keď je zapnuté, v prípade problému sa odošlú podrobné informácie o chybe do Misskey. Pomôžete tak zvýšiť kvalitu Misskey.\nTieto informácie zahŕňajú verziu vášho OS, použitý prehliadač, históriu aktivít, atď." myTheme: "Moja téma" backgroundColor: "Pozadie" accentColor: "Akcent" diff --git a/locales/uk-UA.yml b/locales/uk-UA.yml index 309e114af..a396ec40e 100644 --- a/locales/uk-UA.yml +++ b/locales/uk-UA.yml @@ -690,8 +690,6 @@ clearCache: "Очистити кеш" onlineUsersCount: "{n} користувачів онлайн" nUsers: "{n} Користувачів" nNotes: "{n} Записів" -sendErrorReports: "Надіслати звіт про помилки" -sendErrorReportsDescription: "При увімкненні детальна інформація про помилки буде надана Misskey у разі виникнення проблем, що дасть можливість покращити Misskey." myTheme: "Моя тема" backgroundColor: "Фон" accentColor: "Акцент" diff --git a/locales/vi-VN.yml b/locales/vi-VN.yml index 1b0b342e8..38dcedfb2 100644 --- a/locales/vi-VN.yml +++ b/locales/vi-VN.yml @@ -690,8 +690,6 @@ clearCache: "Xóa bộ nhớ đệm" onlineUsersCount: "{n} người đang online" nUsers: "{n} Người" nNotes: "{n} Tút" -sendErrorReports: "Báo lỗi" -sendErrorReportsDescription: "Khi được bật, thông tin chi tiết về lỗi sẽ được chia sẻ với Misskey khi xảy ra sự cố, giúp nâng cao chất lượng của Misskey.\nBao gồm thông tin như phiên bản hệ điều hành của bạn, trình duyệt bạn đang sử dụng, hoạt động của bạn trong Misskey, v.v." myTheme: "Theme của tôi" backgroundColor: "Màu nền" accentColor: "Màu phụ" diff --git a/locales/zh-CN.yml b/locales/zh-CN.yml index 3a11ef032..a253e08bd 100644 --- a/locales/zh-CN.yml +++ b/locales/zh-CN.yml @@ -690,8 +690,6 @@ clearCache: "清除缓存" onlineUsersCount: "{n}人在线" nUsers: "{n}用户" nNotes: "{n}帖子" -sendErrorReports: "发送错误报告" -sendErrorReportsDescription: "启用后,如果出现问题,可以与Misskey共享详细的错误信息,从而帮助提高软件的质量。" myTheme: "我的主题" backgroundColor: "背景" accentColor: "强调色" diff --git a/locales/zh-TW.yml b/locales/zh-TW.yml index c0091bcfc..2628cf951 100644 --- a/locales/zh-TW.yml +++ b/locales/zh-TW.yml @@ -690,8 +690,6 @@ clearCache: "清除快取資料" onlineUsersCount: "{n}人正在線上" nUsers: "{n}用戶" nNotes: "{n}貼文" -sendErrorReports: "傳送錯誤報告" -sendErrorReportsDescription: "啟用後,問題報告將傳送至開發者以提升軟體品質。問題報告可能包括OS版本,瀏覽器類型,行為歷史記錄等。" myTheme: "我的佈景主題" backgroundColor: "背景" accentColor: "重點色彩" diff --git a/packages/client/src/pages/settings/other.vue b/packages/client/src/pages/settings/other.vue index 52ef4d401..04d9dc637 100644 --- a/packages/client/src/pages/settings/other.vue +++ b/packages/client/src/pages/settings/other.vue @@ -4,10 +4,6 @@ {{ i18n.ts.showFeaturedNotesInTimeline }} - - {{ i18n.ts.accountInfo }} {{ i18n.ts.closeAccount }} @@ -15,17 +11,13 @@ diff --git a/packages/client/src/pages/about-misskey.vue b/packages/client/src/pages/about-misskey.vue deleted file mode 100644 index fd7b5f936..000000000 --- a/packages/client/src/pages/about-misskey.vue +++ /dev/null @@ -1,264 +0,0 @@ - - - - - diff --git a/packages/client/src/pages/about.vue b/packages/client/src/pages/about.vue index 7a86b638f..3e3678189 100644 --- a/packages/client/src/pages/about.vue +++ b/packages/client/src/pages/about.vue @@ -22,7 +22,7 @@ - {{ i18n.ts.aboutMisskey }} + {{ i18n.ts.aboutMisskey }} diff --git a/packages/client/src/pages/welcome.entrance.a.vue b/packages/client/src/pages/welcome.entrance.a.vue index 74b6eb413..946833819 100644 --- a/packages/client/src/pages/welcome.entrance.a.vue +++ b/packages/client/src/pages/welcome.entrance.a.vue @@ -114,7 +114,7 @@ function showMenu(ev) { text: i18n.ts.aboutMisskey, icon: 'fas fa-info-circle', action: () => { - os.pageWindow('/about-misskey'); + os.pageWindow('/about-foundkey'); }, }, null, { text: i18n.ts.help, diff --git a/packages/client/src/router.ts b/packages/client/src/router.ts index a97282dbe..037109455 100644 --- a/packages/client/src/router.ts +++ b/packages/client/src/router.ts @@ -58,8 +58,8 @@ export const routes = [{ component: page(() => import('./pages/about.vue')), hash: 'initialTab', }, { - path: '/about-misskey', - component: page(() => import('./pages/about-misskey.vue')), + path: '/about-foundkey', + component: page(() => import('./pages/about-foundkey.vue')), }, { path: '/theme-editor', component: page(() => import('./pages/theme-editor.vue')), From f4ee76d017c0d6e2e154c489c9b59053e520ff41 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Tue, 13 Sep 2022 20:22:10 +0200 Subject: [PATCH 047/152] client: default instance ticker name to instance's domain name Changelog: Fixed --- packages/client/src/components/instance-ticker.vue | 4 +++- packages/client/src/components/note-detailed.vue | 2 +- packages/client/src/components/note.vue | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/client/src/components/instance-ticker.vue b/packages/client/src/components/instance-ticker.vue index af30e2d31..7704b7d7f 100644 --- a/packages/client/src/components/instance-ticker.vue +++ b/packages/client/src/components/instance-ticker.vue @@ -1,7 +1,7 @@ @@ -10,6 +10,8 @@ import { instanceName, version, software } from '@/config'; const props = defineProps<{ + // null signifies localhost + host: string | null; instance?: { faviconUrl?: string; name: string; diff --git a/packages/client/src/components/note-detailed.vue b/packages/client/src/components/note-detailed.vue index f4af825a4..f617f4237 100644 --- a/packages/client/src/components/note-detailed.vue +++ b/packages/client/src/components/note-detailed.vue @@ -43,7 +43,7 @@
- +
diff --git a/packages/client/src/components/note.vue b/packages/client/src/components/note.vue index 484de45e3..e65ba298f 100644 --- a/packages/client/src/components/note.vue +++ b/packages/client/src/components/note.vue @@ -34,7 +34,7 @@
- +

From e507b1b8882eea3e406869650df0f1af5f1d3f39 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Tue, 13 Sep 2022 13:12:42 -0400 Subject: [PATCH 048/152] backend: localize strings for service integrations Currently only the 'connected' and 'disconnected' strings are translated. --- locales/en-US.yml | 10 ++++++++++ locales/ja-JP.yml | 10 ++++++++++ .../backend/src/server/api/service/discord.ts | 15 +++++++++++++-- packages/backend/src/server/api/service/github.ts | 14 ++++++++++++-- .../backend/src/server/api/service/twitter.ts | 14 ++++++++++++-- packages/backend/tsconfig.json | 4 ++-- 6 files changed, 59 insertions(+), 8 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index 3187acba8..83a8485b4 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1409,3 +1409,13 @@ _deck: list: "List" mentions: "Mentions" direct: "Direct notes" +_services: + _discord: + connected: "Discord: @{username}#{discriminator} connected to FoundKey: @{mkUsername}!" + disconnected: "Discord linkage has been removed :v:" + _twitter: + connected: "Twitter: @{twitterUserName} connected to FoundKey: @{userName}!" + disconnected: "Twitter linkage has been removed :v:" + _github: + connected: "GitHub: @{login} connected to FoundKey: @{userName}!" + disconnected: "GitHub linkage has been removed :v:" diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 4f37a67e7..8a6d40d5d 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1452,3 +1452,13 @@ _deck: list: "リスト" mentions: "あなた宛て" direct: "ダイレクト" +_services: + _discord: + connected: "Discord: @{username}#{discriminator} を、FoundKey: @{mkUsername} に接続しました!" + disconnected: "Discordの連携を解除しました :v:" + _twitter: + connected: "Twitter: @{twitterUserName} を、FoundKey: @{userName} に接続しました!" + disconnected: "Twitterの連携を解除しました :v:" + _github: + connected: "GitHub: @{login} を、FoundKey: @{userName} に接続しました!" + disconnected: "GitHubの連携を解除しました :v:" diff --git a/packages/backend/src/server/api/service/discord.ts b/packages/backend/src/server/api/service/discord.ts index 9d0cc47f4..2f6e9fb01 100644 --- a/packages/backend/src/server/api/service/discord.ts +++ b/packages/backend/src/server/api/service/discord.ts @@ -10,6 +10,7 @@ import { fetchMeta } from '@/misc/fetch-meta.js'; import { Users, UserProfiles } from '@/models/index.js'; import { ILocalUser } from '@/models/entities/user.js'; import { redisClient } from '@/db/redis.js'; +import { I18n } from '@/misc/i18n.js'; import signin from '../common/signin.js'; function getUserToken(ctx: Koa.BaseContext): string | null { @@ -26,6 +27,8 @@ function compareOrigin(ctx: Koa.BaseContext): boolean { return (normalizeUrl(referer) === normalizeUrl(config.url)); } +const locales = await import('../../../../../../locales/index.js').then(mod => mod.default); + // Init router const router = new Router(); @@ -47,6 +50,8 @@ router.get('/disconnect/discord', async ctx => { }); const profile = await UserProfiles.findOneByOrFail({ userId: user.id }); + const locale = locales[profile.lang || 'en-US']; + const i18n = new I18n(locale); delete profile.integrations.discord; @@ -54,7 +59,7 @@ router.get('/disconnect/discord', async ctx => { integrations: profile.integrations, }); - ctx.body = 'Discordの連携を解除しました :v:'; + ctx.body = i18n.t('_services._discord.disconnected'); // Publish i updated event publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, { @@ -259,6 +264,8 @@ router.get('/dc/cb', async ctx => { }); const profile = await UserProfiles.findOneByOrFail({ userId: user.id }); + const locale = locales[profile.lang || 'en-US']; + const i18n = new I18n(locale); await UserProfiles.update(user.id, { integrations: { @@ -274,7 +281,11 @@ router.get('/dc/cb', async ctx => { }, }); - ctx.body = `Discord: @${username}#${discriminator} connected to FoundKey: @${user.username}!`; + ctx.body = i18n.t('_services._discord.connected', { + username, + discriminator, + mkUsername: user.username, + }); // Publish i updated event publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, { diff --git a/packages/backend/src/server/api/service/github.ts b/packages/backend/src/server/api/service/github.ts index 640bbf82c..da4716bc3 100644 --- a/packages/backend/src/server/api/service/github.ts +++ b/packages/backend/src/server/api/service/github.ts @@ -11,6 +11,7 @@ import { Users, UserProfiles } from '@/models/index.js'; import { ILocalUser } from '@/models/entities/user.js'; import { redisClient } from '@/db/redis.js'; import signin from '../common/signin.js'; +import { I18n } from '@/misc/i18n.js'; function getUserToken(ctx: Koa.BaseContext): string | null { return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1]; @@ -26,6 +27,8 @@ function compareOrigin(ctx: Koa.BaseContext): boolean { return (normalizeUrl(referer) === normalizeUrl(config.url)); } +const locales = await import('../../../../../../locales/index.js').then(mod => mod.default); + // Init router const router = new Router(); @@ -47,6 +50,8 @@ router.get('/disconnect/github', async ctx => { }); const profile = await UserProfiles.findOneByOrFail({ userId: user.id }); + const locale = locales[profile.lang || 'en-US']; + const i18n = new I18n(locale); delete profile.integrations.github; @@ -54,7 +59,7 @@ router.get('/disconnect/github', async ctx => { integrations: profile.integrations, }); - ctx.body = 'GitHubの連携を解除しました :v:'; + ctx.body = i18n.t('_services._github.disconnected'); // Publish i updated event publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, { @@ -234,6 +239,8 @@ router.get('/gh/cb', async ctx => { }); const profile = await UserProfiles.findOneByOrFail({ userId: user.id }); + const locale = locales[profile.lang || 'en-US']; + const i18n = new I18n(locale); await UserProfiles.update(user.id, { integrations: { @@ -246,7 +253,10 @@ router.get('/gh/cb', async ctx => { }, }); - ctx.body = `GitHub: @${login} connected to FoundKey: @${user.username}!`; + ctx.body = i18n.t('_services._github.connected', { + login, + userName: user.username, + }); // Publish i updated event publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, { diff --git a/packages/backend/src/server/api/service/twitter.ts b/packages/backend/src/server/api/service/twitter.ts index 5594206f1..309bd922e 100644 --- a/packages/backend/src/server/api/service/twitter.ts +++ b/packages/backend/src/server/api/service/twitter.ts @@ -10,6 +10,7 @@ import { Users, UserProfiles } from '@/models/index.js'; import { ILocalUser } from '@/models/entities/user.js'; import { redisClient } from '@/db/redis.js'; import signin from '../common/signin.js'; +import { I18n } from '@/misc/i18n.js'; function getUserToken(ctx: Koa.BaseContext): string | null { return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1]; @@ -25,6 +26,8 @@ function compareOrigin(ctx: Koa.BaseContext): boolean { return (normalizeUrl(referer) === normalizeUrl(config.url)); } +const locales = await import('../../../../../../locales/index.js').then(mod => mod.default); + // Init router const router = new Router(); @@ -46,6 +49,8 @@ router.get('/disconnect/twitter', async ctx => { }); const profile = await UserProfiles.findOneByOrFail({ userId: user.id }); + const locale = locales[profile.lang || 'en-US']; + const i18n = new I18n(locale); delete profile.integrations.twitter; @@ -53,7 +58,7 @@ router.get('/disconnect/twitter', async ctx => { integrations: profile.integrations, }); - ctx.body = 'Twitter linkage has been removed :v:'; + ctx.body = i18n.t('_services._twitter.disconnected'); // Publish i updated event publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, { @@ -175,6 +180,8 @@ router.get('/tw/cb', async ctx => { }); const profile = await UserProfiles.findOneByOrFail({ userId: user.id }); + const locale = locales[profile.lang || 'en-US']; + const i18n = new I18n(locale); await UserProfiles.update(user.id, { integrations: { @@ -188,7 +195,10 @@ router.get('/tw/cb', async ctx => { }, }); - ctx.body = `Twitter: @${result.screenName} connected to FoundKey: @${user.username}!`; + ctx.body = i18n.t('_services._twitter.connected', { + twitterUserName: result.screenName, + userName: user.username, + }); // Publish i updated event publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, { diff --git a/packages/backend/tsconfig.json b/packages/backend/tsconfig.json index 0702607e3..6e17dad7a 100644 --- a/packages/backend/tsconfig.json +++ b/packages/backend/tsconfig.json @@ -10,8 +10,8 @@ "noFallthroughCasesInSwitch": true, "declaration": false, "sourceMap": false, - "target": "es2017", - "module": "es2020", + "target": "ES2021", + "module": "esnext", "moduleResolution": "node", "allowSyntheticDefaultImports": true, "removeComments": false, From 2e8e475f327a128cc1ffd3231f639362da6d2360 Mon Sep 17 00:00:00 2001 From: Chloe Kudryavtsev Date: Tue, 13 Sep 2022 16:37:29 -0400 Subject: [PATCH 049/152] client: remove ai mode Changelog: Removed --- locales/bn-BD.yml | 1 - locales/de-DE.yml | 1 - locales/en-US.yml | 1 - locales/es-ES.yml | 1 - locales/fr-FR.yml | 1 - locales/id-ID.yml | 1 - locales/it-IT.yml | 1 - locales/ja-JP.yml | 1 - locales/ko-KR.yml | 1 - locales/ru-RU.yml | 1 - locales/sk-SK.yml | 1 - locales/vi-VN.yml | 1 - locales/zh-CN.yml | 1 - locales/zh-TW.yml | 1 - .../client/src/pages/settings/general.vue | 6 ---- packages/client/src/store.ts | 4 --- packages/client/src/ui/classic.vue | 29 ------------------- 17 files changed, 53 deletions(-) diff --git a/locales/bn-BD.yml b/locales/bn-BD.yml index 0b621fe0a..ae3d6b8d0 100644 --- a/locales/bn-BD.yml +++ b/locales/bn-BD.yml @@ -785,7 +785,6 @@ translate: "অনুবাদ" translatedFrom: "{x} হতে অনুবাদ করা" accountDeletionInProgress: "অ্যাকাউন্ট মুছে ফেলা হচ্ছে" usernameInfo: "একটি নাম যা সার্ভারে আপনার অ্যাকাউন্টটিকে অনন্যভাবে সনাক্ত করে। আপনি বর্ণমালা (a ~ z, A ~ Z), সংখ্যা (0 ~ 9), এবং আন্ডারস্কোর (_) ব্যবহার করতে পারেন। ব্যবহারকারীর নাম পরে পরিবর্তন করা যাবে না।" -aiChanMode: "Ai মোড" keepCw: "CW রাখুন" pubSub: "Pub/Sub অ্যাকাউন্টগুলো" lastCommunication: "শেষ যোগাযোগ" diff --git a/locales/de-DE.yml b/locales/de-DE.yml index a281cc889..d04480e43 100644 --- a/locales/de-DE.yml +++ b/locales/de-DE.yml @@ -786,7 +786,6 @@ translate: "Übersetzen" translatedFrom: "Aus {x} übersetzt" accountDeletionInProgress: "Die Löschung deines Benutzerkontos ist momentan in Bearbeitung." usernameInfo: "Ein Name, durch den dein Benutzerkonto auf diesem Server identifiziert werden kann. Du kannst das Alphabet (a~z, A~Z), Ziffern (0~9) oder Unterstriche (_) verwenden. Benutzernamen können später nicht geändert werden." -aiChanMode: "Ai-Modus" keepCw: "Inhaltswarnungen beibehalten" pubSub: "Pub/Sub Benutzerkonten" lastCommunication: "Letzte Kommunikation" diff --git a/locales/en-US.yml b/locales/en-US.yml index 83a8485b4..db041e692 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -786,7 +786,6 @@ translate: "Translate" translatedFrom: "Translated from {x}" accountDeletionInProgress: "Account deletion is currently in progress" usernameInfo: "A name that identifies your account from others on this server. You can use the alphabet (a~z, A~Z), digits (0~9) or underscores (_). Usernames cannot be changed later." -aiChanMode: "Ai Mode" keepCw: "Keep content warnings" pubSub: "Pub/Sub Accounts" lastCommunication: "Last communication" diff --git a/locales/es-ES.yml b/locales/es-ES.yml index 913348d02..26d07f29f 100644 --- a/locales/es-ES.yml +++ b/locales/es-ES.yml @@ -781,7 +781,6 @@ translate: "Traducir" translatedFrom: "Traducido de {x}" accountDeletionInProgress: "La eliminación de la cuenta está en curso" usernameInfo: "Un nombre que identifique su cuenta de otras en este servidor. Puede utilizar el alfabeto (a~z, A~Z), dígitos (0~9) o guiones bajos (_). Los nombres de usuario no se pueden cambiar posteriormente." -aiChanMode: "Modo Ai" keepCw: "Mantener la advertencia de contenido" pubSub: "Cuentas Pub/Sub" lastCommunication: "Última comunicación" diff --git a/locales/fr-FR.yml b/locales/fr-FR.yml index 5015b7467..9a12c9c6a 100644 --- a/locales/fr-FR.yml +++ b/locales/fr-FR.yml @@ -780,7 +780,6 @@ translate: "Traduire" translatedFrom: "Traduit depuis {x}" accountDeletionInProgress: "La suppression de votre compte est en cours" usernameInfo: "C'est un nom qui identifie votre compte sur l'instance de manière unique. Vous pouvez utiliser des lettres de l'alphabet (minuscules et majuscules), des chiffres (de 0 à 9), ou bien le tiret « _ ». Vous ne pourrez pas modifier votre nom d'utilisateur·rice par la suite." -aiChanMode: "Mode Ai" keepCw: "Garder le CW" pubSub: "Comptes Pub/Sub" lastCommunication: "Dernière communication" diff --git a/locales/id-ID.yml b/locales/id-ID.yml index 8434db3c3..a81cc63bc 100644 --- a/locales/id-ID.yml +++ b/locales/id-ID.yml @@ -785,7 +785,6 @@ translate: "Terjemahkan" translatedFrom: "Terjemahkan dari {x}" accountDeletionInProgress: "Penghapusan akun sedang dalam proses" usernameInfo: "Nama yang mengidentifikasikan akun kamu dari yang lain pada server ini. Kamu dapat menggunakan alfabet (a~z, A~Z), digit (0~9) atau garis bawah (_). Username tidak dapat diubah setelahnya." -aiChanMode: "Mode Ai" keepCw: "Biarkan Peringatan Konten" pubSub: "Akun Pub/Sub" lastCommunication: "Komunikasi terakhir" diff --git a/locales/it-IT.yml b/locales/it-IT.yml index 80a0b76bf..9eeeb0c53 100644 --- a/locales/it-IT.yml +++ b/locales/it-IT.yml @@ -772,7 +772,6 @@ translate: "Traduzione" translatedFrom: "Tradotto da {x}" accountDeletionInProgress: "La cancellazione dell'account è in corso" usernameInfo: "Un nome per identificare univocamente il tuo account sul server. È possibile utilizzare caratteri alfanumerici (a~z, A~Z, 0~9) e il trattino basso (_). Non sarà possibile cambiare il nome utente in seguito." -aiChanMode: "Modalità Ai" keepCw: "Mantieni il CW" resolved: "Risolto" unresolved: "Non risolto" diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 8a6d40d5d..4dfe98e74 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -788,7 +788,6 @@ translate: "翻訳" translatedFrom: "{x}から翻訳" accountDeletionInProgress: "アカウントの削除が進行中です" usernameInfo: "サーバー上であなたのアカウントを一意に識別するための名前。アルファベット(a~z, A~Z)、数字(0~9)、およびアンダーバー(_)が使用できます。ユーザー名は後から変更することは出来ません。" -aiChanMode: "藍モード" keepCw: "CWを維持する" pubSub: "Pub/Subのアカウント" lastCommunication: "直近の通信" diff --git a/locales/ko-KR.yml b/locales/ko-KR.yml index 3e8feea4c..b6ba5c91d 100644 --- a/locales/ko-KR.yml +++ b/locales/ko-KR.yml @@ -785,7 +785,6 @@ translate: "번역" translatedFrom: "{x}에서 번역" accountDeletionInProgress: "계정 삭제 작업을 진행하고 있습니다" usernameInfo: "서버상에서 계정을 식별하기 위한 이름. 알파벳(a~z, A~Z), 숫자(0~9) 및 언더바(_)를 사용할 수 있습니다. 사용자명은 나중에 변경할 수 없습니다." -aiChanMode: "아이 모드" keepCw: "CW 유지하기" pubSub: "Pub/Sub 계정" lastCommunication: "마지막 통신" diff --git a/locales/ru-RU.yml b/locales/ru-RU.yml index 0273b270f..ad98d75cf 100644 --- a/locales/ru-RU.yml +++ b/locales/ru-RU.yml @@ -783,7 +783,6 @@ translate: "Перевод" translatedFrom: "Перевод. Язык оригинала — {x}" accountDeletionInProgress: "В настоящее время выполняется удаление учетной записи" usernameInfo: "Имя, которое отличает вашу учетную запись от других на этом сервере. Вы можете использовать алфавит (a~z, A~Z), цифры (0~9) или символы подчеркивания (_). Имена пользователей не могут быть изменены позже." -aiChanMode: "ИИ режим" keepCw: "Сохраняйте Предупреждения о содержимом" pubSub: "Учётные записи Pub/Sub" lastCommunication: "Последнее сообщение" diff --git a/locales/sk-SK.yml b/locales/sk-SK.yml index 91d345ddf..3a63e8511 100644 --- a/locales/sk-SK.yml +++ b/locales/sk-SK.yml @@ -784,7 +784,6 @@ translate: "Preložiť" translatedFrom: "Preložené z {x}" accountDeletionInProgress: "Odstraňovanie účtu prebieha" usernameInfo: "Meno, ktoré odlišuje váš účet od ostatných na tomto serveri. Môžete použiť abecedu (a~z, A~Z), čísla (0~9) alebo podtržník (_). Používateľské mená sa nedajú neskôr zmeniť." -aiChanMode: "Ai režim" keepCw: "Nechať varovania obsahu" pubSub: "Pub/Sub účty" lastCommunication: "Posledná komunikácia" diff --git a/locales/vi-VN.yml b/locales/vi-VN.yml index 8e1dee0e8..15ceccba0 100644 --- a/locales/vi-VN.yml +++ b/locales/vi-VN.yml @@ -785,7 +785,6 @@ translate: "Dịch" translatedFrom: "Dịch từ {x}" accountDeletionInProgress: "Đang xử lý việc xóa tài khoản" usernameInfo: "Bạn có thể sử dụng chữ cái (a ~ z, A ~ Z), chữ số (0 ~ 9) hoặc dấu gạch dưới (_). Tên người dùng không thể thay đổi sau này." -aiChanMode: "Chế độ Ai" keepCw: "Giữ cảnh báo nội dung" pubSub: "Tài khoản Chính/Phụ" lastCommunication: "Lần giao tiếp cuối" diff --git a/locales/zh-CN.yml b/locales/zh-CN.yml index ad2c63e16..6e693dcac 100644 --- a/locales/zh-CN.yml +++ b/locales/zh-CN.yml @@ -785,7 +785,6 @@ translate: "翻译" translatedFrom: "从 {x} 翻译" accountDeletionInProgress: "正在删除账户" usernameInfo: "在服务器上唯一标识您的帐户的名称。您可以使用字母 (a ~ z, A ~ Z)、数字 (0 ~ 9) 和下划线 (_)。用户名以后不能更改。" -aiChanMode: "小蓝模式" keepCw: "保留CW" pubSub: "Pub/Sub账户" lastCommunication: "最近通信" diff --git a/locales/zh-TW.yml b/locales/zh-TW.yml index fa32b5fe8..6332632a0 100644 --- a/locales/zh-TW.yml +++ b/locales/zh-TW.yml @@ -785,7 +785,6 @@ translate: "翻譯" translatedFrom: "從 {x} 翻譯" accountDeletionInProgress: "正在刪除帳戶" usernameInfo: "在伺服器上您的帳戶是唯一的識別名稱。您可以使用字母 (a ~ z, A ~ Z)、數字 (0 ~ 9) 和下底線 (_)。之後帳戶名是不能更改的。" -aiChanMode: "小藍模式" keepCw: "保持CW" pubSub: "Pub/Sub 帳戶" lastCommunication: "最近的通信" diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index 7400c6fd0..845d4f461 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -71,10 +71,6 @@ - - {{ i18n.ts.aiChanMode }} - - @@ -151,7 +147,6 @@ const instanceTicker = computed(defaultStore.makeGetterSetter('instanceTicker')) const enableInfiniteScroll = computed(defaultStore.makeGetterSetter('enableInfiniteScroll')); const useReactionPickerForContextMenu = computed(defaultStore.makeGetterSetter('useReactionPickerForContextMenu')); const squareAvatars = computed(defaultStore.makeGetterSetter('squareAvatars')); -const aiChanMode = computed(defaultStore.makeGetterSetter('aiChanMode')); watch(lang, () => { localStorage.setItem('lang', lang.value as string); @@ -180,7 +175,6 @@ watch([ useSystemFont, enableInfiniteScroll, squareAvatars, - aiChanMode, showGapBetweenNotesInTimeline, instanceTicker, overridedDeviceKind, diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index ea68a6ed2..5084907cf 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -228,10 +228,6 @@ export const defaultStore = markRaw(new Storage('base', { where: 'device', default: 5, }, - aiChanMode: { - where: 'device', - default: false, - }, })); // TODO: 他のタブと永続化されたstateを同期 diff --git a/packages/client/src/ui/classic.vue b/packages/client/src/ui/classic.vue index 9752b30b3..ba726ae9b 100644 --- a/packages/client/src/ui/classic.vue +++ b/packages/client/src/ui/classic.vue @@ -34,8 +34,6 @@ - -

@@ -65,7 +63,6 @@ let fullView = $ref(false); let globalHeaderHeight = $ref(0); const wallpaper = localStorage.getItem('wallpaper') != null; const showMenuOnTop = $computed(() => defaultStore.state.menuDisplay === 'top'); -let live2d = $ref(); let widgetsLeft = $ref(); let widgetsRight = $ref(); @@ -119,10 +116,6 @@ function onContextmenu(ev: MouseEvent) { }], ev); } -function onAiClick(ev) { - //if (this.live2d) this.live2d.click(ev); -} - if (window.innerWidth < 1024) { localStorage.setItem('ui', 'default'); location.reload(); @@ -147,28 +140,6 @@ onMounted(() => { window.addEventListener('resize', () => { isDesktop = (window.innerWidth >= DESKTOP_THRESHOLD); }, { passive: true }); - - if (defaultStore.state.aiChanMode) { - const iframeRect = live2d.getBoundingClientRect(); - window.addEventListener('mousemove', ev => { - live2d.contentWindow.postMessage({ - type: 'moveCursor', - body: { - x: ev.clientX - iframeRect.left, - y: ev.clientY - iframeRect.top, - }, - }, '*'); - }, { passive: true }); - window.addEventListener('touchmove', ev => { - live2d.contentWindow.postMessage({ - type: 'moveCursor', - body: { - x: ev.touches[0].clientX - iframeRect.left, - y: ev.touches[0].clientY - iframeRect.top, - }, - }, '*'); - }, { passive: true }); - } }); From f4b9244a88ea6e4f141c3dfc7dc8a75841367c2e Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Sat, 10 Sep 2022 00:42:39 -0400 Subject: [PATCH 050/152] client: refactor sparkle.vue to composition api --- packages/client/src/components/sparkle.vue | 102 ++++++++++----------- 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/packages/client/src/components/sparkle.vue b/packages/client/src/components/sparkle.vue index a72ea6976..9c84afcfa 100644 --- a/packages/client/src/components/sparkle.vue +++ b/packages/client/src/components/sparkle.vue @@ -63,62 +63,60 @@ - From 846ca03a7cf89c0e783a4808305748c671139697 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Sat, 10 Sep 2022 00:27:44 -0400 Subject: [PATCH 051/152] client: refactor sidebar-for-mobile.vue to composition api --- .../src/ui/_common_/sidebar-for-mobile.vue | 63 +++++++------------ 1 file changed, 24 insertions(+), 39 deletions(-) diff --git a/packages/client/src/ui/_common_/sidebar-for-mobile.vue b/packages/client/src/ui/_common_/sidebar-for-mobile.vue index aefbdc2ee..f16769efb 100644 --- a/packages/client/src/ui/_common_/sidebar-for-mobile.vue +++ b/packages/client/src/ui/_common_/sidebar-for-mobile.vue @@ -1,13 +1,13 @@