From 9a9c3d4c62ba7d6beeddb08abded6fb7449b1e52 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Sun, 4 Jun 2023 16:29:24 -0400 Subject: [PATCH 1/4] add rust to the runtime container for migrations --- Dockerfile | 2 +- docker-compose.yml | 2 +- packages/backend/package.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0aa13aefeb..d8671911e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,7 +36,7 @@ FROM node:19-alpine WORKDIR /calckey # Install runtime dependencies -RUN apk add --no-cache --no-progress tini ffmpeg vips-dev zip unzip +RUN apk add --no-cache --no-progress tini ffmpeg vips-dev zip unzip rust cargo COPY . ./ diff --git a/docker-compose.yml b/docker-compose.yml index bf4e4fb8da..e4f751af08 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: depends_on: - db - redis - - meilisearch +# - meilisearch ports: - "3000:3000" networks: diff --git a/packages/backend/package.json b/packages/backend/package.json index 47e9c415cb..c2e1e71131 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -8,10 +8,10 @@ "start:test": "NODE_ENV=test pnpm node ./built/index.js", "migrate": "pnpm run migrate:typeorm && pnpm run migrate:cargo", "migrate:typeorm": "typeorm migration:run -d ormconfig.js", - "migrate:cargo": "cargo run --manifest-path native-utils/migration/Cargo.toml -- up", + "migrate:cargo": "cargo run --manifest-path ./native-utils/migration/Cargo.toml -- up", "revertmigration": "pnpm run revertmigration:cargo && pnpm run revertmigration:typeorm", "revertmigration:typeorm": "typeorm migration:revert -d ormconfig.js", - "revertmigration:cargo": "cargo run --manifest-path native-utils/migration/Cargo.toml -- down", + "revertmigration:cargo": "cargo run --manifest-path ./native-utils/migration/Cargo.toml -- down", "check:connect": "node ./check_connect.js", "build": "pnpm swc src -d built -D", "watch": "pnpm swc src -d built -D -w", From 0151b256fcc514bca9e83509900b81461a742c47 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Sun, 4 Jun 2023 17:03:47 -0400 Subject: [PATCH 2/4] cache cargo artifacts --- .gitignore | 4 ++++ docker-compose.yml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 63ee4f35fc..3a667851c7 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,7 @@ yarn* # Nix Development shell items .devenv .direnv + +# Cargo cache for Docker +/.cargo-cache +/.cargo-target diff --git a/docker-compose.yml b/docker-compose.yml index e4f751af08..bc986ada9f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,8 @@ services: environment: NODE_ENV: production volumes: + - ./.cargo-cache:/root/.cargo + - ./.cargo-target:/calckey/packages/backend/native-utils/target - ./files:/calckey/files - ./.config:/calckey/.config:ro From 535fa9f506a4fad3afa1f55ed091692b3069a34a Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sun, 4 Jun 2023 14:41:18 -0700 Subject: [PATCH 3/4] fix: :bug: prevent null date insertion https://calckey.aokaga.work/notes/9f6ksv2oov --- packages/backend/src/services/note/create.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index bd54db7e24..31fddfc4e0 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -596,20 +596,20 @@ export default async ( lastNotedAt: new Date(), }); - const count = await Notes.countBy({ + await Notes.countBy({ userId: user.id, channelId: data.channel.id, }).then((count) => { // この処理が行われるのはノート作成後なので、ノートが一つしかなかったら最初の投稿だと判断できる // TODO: とはいえノートを削除して何回も投稿すればその分だけインクリメントされる雑さもあるのでどうにかしたい - if (count === 1) { - Channels.increment({ id: data.channel!.id }, "usersCount", 1); + if (count === 1 && data.channel != null) { + Channels.increment({ id: data.channel.id }, "usersCount", 1); } }); } // Register to search database - await index(note); + await index(note, false); }); async function renderNoteOrRenoteActivity(data: Option, note: Note) { @@ -649,9 +649,12 @@ async function insertNote( emojis: string[], mentionedUsers: MinimumUser[], ) { + if (data.createdAt === null || data.createdAt === undefined ) { + data.createdAt = new Date(); + } const insert = new Note({ - id: genId(data.createdAt!), - createdAt: data.createdAt!, + id: genId(data.createdAt), + createdAt: data.createdAt, fileIds: data.files ? data.files.map((file) => file.id) : [], replyId: data.reply ? data.reply.id : null, renoteId: data.renote ? data.renote.id : null, @@ -668,7 +671,7 @@ async function insertNote( tags: tags.map((tag) => normalizeForSearch(tag)), emojis, userId: user.id, - localOnly: data.localOnly!, + localOnly: data.localOnly || false, visibility: data.visibility as any, visibleUserIds: data.visibility === "specified" From 6a7e950f21972cb7bc15f0553afdafe30428191e Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sun, 4 Jun 2023 14:42:22 -0700 Subject: [PATCH 4/4] chore: formatting --- packages/backend/src/services/note/create.ts | 2 +- packages/client/src/ui/_common_/navbar.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 31fddfc4e0..abb8d94e88 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -649,7 +649,7 @@ async function insertNote( emojis: string[], mentionedUsers: MinimumUser[], ) { - if (data.createdAt === null || data.createdAt === undefined ) { + if (data.createdAt === null || data.createdAt === undefined) { data.createdAt = new Date(); } const insert = new Note({ diff --git a/packages/client/src/ui/_common_/navbar.vue b/packages/client/src/ui/_common_/navbar.vue index e5c0a26762..b884f5c306 100644 --- a/packages/client/src/ui/_common_/navbar.vue +++ b/packages/client/src/ui/_common_/navbar.vue @@ -92,7 +92,7 @@ >{{ i18n.ts.controlPanel }} -