From 50cb7c6de10bfe5e27e78d83d7905a70b598fc8d Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sun, 11 Dec 2022 19:24:12 -0800 Subject: [PATCH] Bug fixes, use calckey.js --- CALCKEY.md | 2 ++ package.json | 4 ++-- packages/backend/package.json | 2 +- packages/backend/src/remote/resolve-user.ts | 14 +++++++------- .../backend/src/server/api/endpoints/i/known-as.ts | 9 +++++++-- packages/backend/test/utils.ts | 2 +- packages/client/package.json | 2 +- packages/client/src/account.ts | 2 +- .../client/src/components/MkAbuseReportWindow.vue | 2 +- packages/client/src/components/MkCropperDialog.vue | 2 +- packages/client/src/components/MkCwButton.vue | 2 +- packages/client/src/components/MkDrive.file.vue | 2 +- packages/client/src/components/MkDrive.folder.vue | 2 +- .../client/src/components/MkDrive.navFolder.vue | 2 +- packages/client/src/components/MkDrive.vue | 2 +- .../client/src/components/MkDriveFileThumbnail.vue | 2 +- .../client/src/components/MkDriveSelectDialog.vue | 2 +- packages/client/src/components/MkDriveWindow.vue | 2 +- packages/client/src/components/MkEmojiPicker.vue | 2 +- .../client/src/components/MkFeaturedPhotos.vue | 2 +- packages/client/src/components/MkFollowButton.vue | 2 +- packages/client/src/components/MkImageViewer.vue | 2 +- .../client/src/components/MkInstanceCardMini.vue | 2 +- packages/client/src/components/MkMediaBanner.vue | 2 +- packages/client/src/components/MkMediaImage.vue | 2 +- packages/client/src/components/MkMediaList.vue | 2 +- packages/client/src/components/MkMediaVideo.vue | 2 +- packages/client/src/components/MkNote.vue | 2 +- packages/client/src/components/MkNoteDetailed.vue | 2 +- packages/client/src/components/MkNoteHeader.vue | 2 +- packages/client/src/components/MkNoteSimple.vue | 2 +- packages/client/src/components/MkNoteSub.vue | 2 +- packages/client/src/components/MkNotification.vue | 2 +- .../src/components/MkNotificationSettingWindow.vue | 2 +- packages/client/src/components/MkNotifications.vue | 2 +- packages/client/src/components/MkPagination.vue | 2 +- packages/client/src/components/MkPoll.vue | 2 +- packages/client/src/components/MkPostForm.vue | 2 +- .../src/components/MkReactionsViewer.reaction.vue | 2 +- .../client/src/components/MkReactionsViewer.vue | 2 +- packages/client/src/components/MkRenoteButton.vue | 2 +- .../client/src/components/MkSubNoteContent.vue | 2 +- .../src/components/MkTokenGenerateWindow.vue | 2 +- packages/client/src/components/MkUserCardMini.vue | 2 +- packages/client/src/components/MkUserInfo.vue | 2 +- .../src/components/MkUserOnlineIndicator.vue | 2 +- packages/client/src/components/MkUserPreview.vue | 2 +- .../client/src/components/MkUserSelectDialog.vue | 2 +- .../client/src/components/MkVisibilityPicker.vue | 2 +- packages/client/src/components/global/MkAcct.vue | 2 +- packages/client/src/components/global/MkAvatar.vue | 2 +- .../client/src/components/global/MkUserName.vue | 2 +- packages/client/src/filters/user.ts | 2 +- packages/client/src/instance.ts | 2 +- packages/client/src/os.ts | 2 +- packages/client/src/pages/_error_.vue | 2 +- packages/client/src/pages/about-calckey.vue | 2 +- packages/client/src/pages/admin/overview.user.vue | 2 +- packages/client/src/pages/api-console.vue | 2 +- packages/client/src/pages/clip.vue | 2 +- packages/client/src/pages/instance-info.vue | 2 +- .../src/pages/messaging/messaging-room.form.vue | 2 +- .../src/pages/messaging/messaging-room.message.vue | 2 +- .../client/src/pages/messaging/messaging-room.vue | 2 +- packages/client/src/pages/note.vue | 2 +- packages/client/src/pages/notifications.vue | 2 +- packages/client/src/pages/settings/migration.vue | 3 --- .../client/src/pages/settings/notifications.vue | 2 +- packages/client/src/pages/share.vue | 4 ++-- packages/client/src/pages/user-info.vue | 2 +- packages/client/src/pages/user/clips.vue | 2 +- packages/client/src/pages/user/follow-list.vue | 2 +- packages/client/src/pages/user/followers.vue | 2 +- packages/client/src/pages/user/following.vue | 2 +- packages/client/src/pages/user/gallery.vue | 2 +- packages/client/src/pages/user/home.vue | 4 ++-- packages/client/src/pages/user/index.activity.vue | 2 +- packages/client/src/pages/user/index.photos.vue | 2 +- packages/client/src/pages/user/index.timeline.vue | 2 +- packages/client/src/pages/user/index.vue | 2 +- packages/client/src/pages/user/pages.vue | 2 +- packages/client/src/pages/user/reactions.vue | 2 +- packages/client/src/scripts/get-note-menu.ts | 2 +- packages/client/src/scripts/get-note-summary.ts | 2 +- packages/client/src/scripts/page-metadata.ts | 2 +- packages/client/src/scripts/upload.ts | 2 +- packages/client/src/scripts/use-note-capture.ts | 2 +- packages/client/src/stream.ts | 2 +- packages/client/src/types/menu.ts | 2 +- .../src/ui/_common_/statusbar-federation.vue | 2 +- .../client/src/ui/_common_/statusbar-user-list.vue | 2 +- packages/client/src/ui/deck/deck-store.ts | 2 +- packages/sw/src/filters/user.ts | 2 +- packages/sw/src/scripts/operations.ts | 2 +- packages/sw/src/types.ts | 2 +- 95 files changed, 110 insertions(+), 106 deletions(-) diff --git a/CALCKEY.md b/CALCKEY.md index 45ed6f0df2..b1ccadef73 100644 --- a/CALCKEY.md +++ b/CALCKEY.md @@ -9,6 +9,7 @@ - Rewrite backend in Rust and [Axum](https://github.com/tokio-rs/axum) - Function - Federate with note edits + - Admin customizable max note length (100-8000) - User "choices" (recommended users) like Mastodon and Soapbox - Join Reason system like Mastodon/Pleroma - Option to publicize instance blocks @@ -97,6 +98,7 @@ - Undo renote button inside original note - Custom locales - Obliteration of Ai-chan +- Switch to [Calckey.js](https://codeberg.org/thatonecalculator/cal) - MissV: [fix Misskey Forkbomb](https://code.vtopia.live/Vtopia/MissV/commit/40b23c070bd4adbb3188c73546c6c625138fb3c1) - [Make showing ads optional](https://github.com/misskey-dev/misskey/pull/8996) - [Tapping avatar in mobile opens account modal](https://github.com/misskey-dev/misskey/pull/9056) diff --git a/package.json b/package.json index dad94fd358..391723bfcd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "calckey", - "version": "13.0.0-beta1", + "version": "13.0.0-beta2", "codename": "aqua", "repository": { "type": "git", @@ -19,7 +19,7 @@ "start:test": "yarn workspace backend run start:test", "init": "yarn migrate", "migrate": "yarn workspace backend run migrate", - "revertmigration": "yarn workspace backend run revertmigration", + "revertmigration": "yarn workspace backend run revertmigration", "migrateandstart": "yarn migrate && yarn start", "gulp": "gulp build", "watch": "yarn dev", diff --git a/packages/backend/package.json b/packages/backend/package.json index 503631315b..df1bebd850 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -42,6 +42,7 @@ "blurhash": "1.1.5", "bull": "4.10.1", "cacheable-lookup": "7.0.0", + "calckey-js": "^0.0.15", "cbor": "8.1.0", "chalk": "5.1.2", "chalk-template": "0.4.0", @@ -77,7 +78,6 @@ "koa-views": "7.0.2", "mfm-js": "0.23.0", "mime-types": "2.1.35", - "misskey-js": "0.0.14", "mocha": "10.1.0", "multer": "1.4.4-lts.1", "nested-property": "4.0.0", diff --git a/packages/backend/src/remote/resolve-user.ts b/packages/backend/src/remote/resolve-user.ts index b44981bb83..fe6b65472e 100644 --- a/packages/backend/src/remote/resolve-user.ts +++ b/packages/backend/src/remote/resolve-user.ts @@ -1,13 +1,13 @@ import { URL } from 'node:url'; -import webFinger from './webfinger.js'; -import config from '@/config/index.js'; -import { createPerson, updatePerson } from './activitypub/models/person.js'; -import { remoteLogger } from './logger.js'; import chalk from 'chalk'; -import { User, IRemoteUser } from '@/models/entities/user.js'; +import { IsNull } from 'typeorm'; +import config from '@/config/index.js'; +import type { User, IRemoteUser } from '@/models/entities/user.js'; import { Users } from '@/models/index.js'; import { toPuny } from '@/misc/convert-host.js'; -import { IsNull } from 'typeorm'; +import webFinger from './webfinger.js'; +import { createPerson, updatePerson } from './activitypub/models/person.js'; +import { remoteLogger } from './logger.js'; const logger = remoteLogger.createSubLogger('resolve-user'); @@ -67,7 +67,7 @@ export async function resolveUser(username: string, host: string | null): Promis // validate uri const uri = new URL(self.href); if (uri.hostname !== host) { - throw new Error(`Invalid uri`); + throw new Error('Invalid uri'); } await Users.update({ diff --git a/packages/backend/src/server/api/endpoints/i/known-as.ts b/packages/backend/src/server/api/endpoints/i/known-as.ts index 7b3354190a..d33906a65b 100644 --- a/packages/backend/src/server/api/endpoints/i/known-as.ts +++ b/packages/backend/src/server/api/endpoints/i/known-as.ts @@ -28,7 +28,7 @@ export const meta = { id: 'fcd2eef9-a9b2-4c4f-8624-038099e90aa5', }, notRemote: { - message: 'User not remote.', + message: 'User is not remote. You can only migrate to other instances.', code: 'NOT_REMOTE', id: '4362f8dc-731f-4ad8-a694-be2a88922a24', }, @@ -61,8 +61,13 @@ export default define(meta, paramDef, async (ps, user) => { const updates = {} as Partial; + // FIXME: .uri is local uri, not remote uri! if (!knownAs.uri) knownAs.uri = ''; - updates.alsoKnownAs = [knownAs.uri]; + if (updates.alsoKnownAs == null || updates.alsoKnownAs.length === 0) { + updates.alsoKnownAs = [knownAs.uri]; + } else { + updates.alsoKnownAs.push(knownAs.uri); + } await Users.update(user.id, updates); diff --git a/packages/backend/test/utils.ts b/packages/backend/test/utils.ts index 245cf858d8..6833e6eb58 100644 --- a/packages/backend/test/utils.ts +++ b/packages/backend/test/utils.ts @@ -6,7 +6,7 @@ import * as childProcess from 'child_process'; import * as http from 'node:http'; import { SIGKILL } from 'constants'; import WebSocket from 'ws'; -import * as misskey from 'misskey-js'; +import * as misskey from 'calckey-js'; import fetch from 'node-fetch'; import FormData from 'form-data'; import { DataSource } from 'typeorm'; diff --git a/packages/client/package.json b/packages/client/package.json index bc49ac0211..c71ac27efc 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -19,6 +19,7 @@ "blurhash": "1.1.5", "broadcast-channel": "4.18.1", "browser-image-resizer": "https://github.com/misskey-dev/browser-image-resizer.git#commit=0380d12c8e736788ea7f4e6e985175521ea7b23c", + "calckey-js": "^0.0.15", "chart.js": "4.0.1", "chartjs-adapter-date-fns": "2.0.1", "chartjs-plugin-gradient": "0.5.1", @@ -34,7 +35,6 @@ "katex": "0.16.3", "matter-js": "0.18.0", "mfm-js": "0.23.0", - "misskey-js": "0.0.14", "photoswipe": "5.3.3", "prismjs": "1.29.0", "punycode": "2.1.1", diff --git a/packages/client/src/account.ts b/packages/client/src/account.ts index eefcc9a100..62fc2d82f1 100644 --- a/packages/client/src/account.ts +++ b/packages/client/src/account.ts @@ -1,5 +1,5 @@ import { defineAsyncComponent, reactive } from 'vue'; -import * as misskey from 'misskey-js'; +import * as misskey from 'calckey-js'; import { showSuspendedDialog } from './scripts/show-suspended-dialog'; import { i18n } from './i18n'; import { del, get, set } from '@/scripts/idb-proxy'; diff --git a/packages/client/src/components/MkAbuseReportWindow.vue b/packages/client/src/components/MkAbuseReportWindow.vue index c83592d8c1..b8ef6686c0 100644 --- a/packages/client/src/components/MkAbuseReportWindow.vue +++ b/packages/client/src/components/MkAbuseReportWindow.vue @@ -24,7 +24,7 @@