Merge branch 'develop' of https://codeberg.org/calckey/calckey into upstream/develop

This commit is contained in:
Freeplay 2023-06-04 17:52:49 -04:00
commit 8bc7cb358c
6 changed files with 21 additions and 12 deletions

4
.gitignore vendored
View file

@ -62,3 +62,7 @@ yarn*
# Nix Development shell items # Nix Development shell items
.devenv .devenv
.direnv .direnv
# Cargo cache for Docker
/.cargo-cache
/.cargo-target

View file

@ -36,7 +36,7 @@ FROM node:19-alpine
WORKDIR /calckey WORKDIR /calckey
# Install runtime dependencies # 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 . ./ COPY . ./

View file

@ -8,7 +8,7 @@ services:
depends_on: depends_on:
- db - db
- redis - redis
- meilisearch # - meilisearch
ports: ports:
- "3000:3000" - "3000:3000"
networks: networks:
@ -17,6 +17,8 @@ services:
environment: environment:
NODE_ENV: production NODE_ENV: production
volumes: volumes:
- ./.cargo-cache:/root/.cargo
- ./.cargo-target:/calckey/packages/backend/native-utils/target
- ./files:/calckey/files - ./files:/calckey/files
- ./.config:/calckey/.config:ro - ./.config:/calckey/.config:ro

View file

@ -8,10 +8,10 @@
"start:test": "NODE_ENV=test pnpm node ./built/index.js", "start:test": "NODE_ENV=test pnpm node ./built/index.js",
"migrate": "pnpm run migrate:typeorm && pnpm run migrate:cargo", "migrate": "pnpm run migrate:typeorm && pnpm run migrate:cargo",
"migrate:typeorm": "typeorm migration:run -d ormconfig.js", "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": "pnpm run revertmigration:cargo && pnpm run revertmigration:typeorm",
"revertmigration:typeorm": "typeorm migration:revert -d ormconfig.js", "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", "check:connect": "node ./check_connect.js",
"build": "pnpm swc src -d built -D", "build": "pnpm swc src -d built -D",
"watch": "pnpm swc src -d built -D -w", "watch": "pnpm swc src -d built -D -w",

View file

@ -596,20 +596,20 @@ export default async (
lastNotedAt: new Date(), lastNotedAt: new Date(),
}); });
const count = await Notes.countBy({ await Notes.countBy({
userId: user.id, userId: user.id,
channelId: data.channel.id, channelId: data.channel.id,
}).then((count) => { }).then((count) => {
// この処理が行われるのはノート作成後なので、ノートが一つしかなかったら最初の投稿だと判断できる // この処理が行われるのはノート作成後なので、ノートが一つしかなかったら最初の投稿だと判断できる
// TODO: とはいえノートを削除して何回も投稿すればその分だけインクリメントされる雑さもあるのでどうにかしたい // TODO: とはいえノートを削除して何回も投稿すればその分だけインクリメントされる雑さもあるのでどうにかしたい
if (count === 1) { if (count === 1 && data.channel != null) {
Channels.increment({ id: data.channel!.id }, "usersCount", 1); Channels.increment({ id: data.channel.id }, "usersCount", 1);
} }
}); });
} }
// Register to search database // Register to search database
await index(note); await index(note, false);
}); });
async function renderNoteOrRenoteActivity(data: Option, note: Note) { async function renderNoteOrRenoteActivity(data: Option, note: Note) {
@ -649,9 +649,12 @@ async function insertNote(
emojis: string[], emojis: string[],
mentionedUsers: MinimumUser[], mentionedUsers: MinimumUser[],
) { ) {
if (data.createdAt === null || data.createdAt === undefined) {
data.createdAt = new Date();
}
const insert = new Note({ const insert = new Note({
id: genId(data.createdAt!), id: genId(data.createdAt),
createdAt: data.createdAt!, createdAt: data.createdAt,
fileIds: data.files ? data.files.map((file) => file.id) : [], fileIds: data.files ? data.files.map((file) => file.id) : [],
replyId: data.reply ? data.reply.id : null, replyId: data.reply ? data.reply.id : null,
renoteId: data.renote ? data.renote.id : null, renoteId: data.renote ? data.renote.id : null,
@ -668,7 +671,7 @@ async function insertNote(
tags: tags.map((tag) => normalizeForSearch(tag)), tags: tags.map((tag) => normalizeForSearch(tag)),
emojis, emojis,
userId: user.id, userId: user.id,
localOnly: data.localOnly!, localOnly: data.localOnly || false,
visibility: data.visibility as any, visibility: data.visibility as any,
visibleUserIds: visibleUserIds:
data.visibility === "specified" data.visibility === "specified"