From ecc7ca1aa6d266d4955a5fb6d2cc242f3606a462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Thu, 25 Apr 2024 21:33:10 +0800 Subject: [PATCH 1/7] fix: questionable if statements in note import --- .../backend/src/misc/process-masto-notes.ts | 6 +++++- .../queue/processors/db/import-firefish-post.ts | 17 +++++++++++++---- .../queue/processors/db/import-masto-post.ts | 17 +++++++++++++---- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/packages/backend/src/misc/process-masto-notes.ts b/packages/backend/src/misc/process-masto-notes.ts index 03968944ec..01c438f97d 100644 --- a/packages/backend/src/misc/process-masto-notes.ts +++ b/packages/backend/src/misc/process-masto-notes.ts @@ -53,7 +53,11 @@ function processMastoFile(fn: string, path: string, dir: string, uid: string) { continue; } for (const attachment of note.object.attachment) { - const url = attachment.url.replaceAll("..", ""); + // The url in some Mastodon import files do not start with /media_attachments/. + // If this is not handled properly, these users not be able to import images in their posts. + const url = attachment.url + .replaceAll("..", "") + .replaceAll(/.*\/media_attachments\//g, "/media_attachments/"); if (url.indexOf("\0") !== -1) { logger.error(`Found Poison Null Bytes Attack: ${url}`); reject(); diff --git a/packages/backend/src/queue/processors/db/import-firefish-post.ts b/packages/backend/src/queue/processors/db/import-firefish-post.ts index 88356c2458..34a27c4c7a 100644 --- a/packages/backend/src/queue/processors/db/import-firefish-post.ts +++ b/packages/backend/src/queue/processors/db/import-firefish-post.ts @@ -59,18 +59,27 @@ export async function importCkPost( userId: user.id, }); - // FIXME: What is this condition? - if (note != null && (note.fileIds?.length || 0) < files.length) { + // If an import is completely successful at once, the order should not be out of order. + // If it takes multiple imports to complete, the order is not guaranteed to be consistent. + if (note != null && files.length > 0) { + const addFiles: DriveFile[] = []; + for (const file of files) { + if (!note.fileIds.includes(file.id)) { + addFiles.push(file); + } + } + const update: Partial = {}; - update.fileIds = files.map((x) => x.id); + update.fileIds = addFiles.map((x) => x.id); if (update.fileIds != null) { - await NoteFiles.delete({ noteId: note.id }); await NoteFiles.insert( update.fileIds.map((fileId) => ({ noteId: note?.id, fileId })), ); } + update.fileIds = note.fileIds.concat(update.fileIds); + await Notes.update(note.id, update); await NoteEdits.insert({ id: genId(), diff --git a/packages/backend/src/queue/processors/db/import-masto-post.ts b/packages/backend/src/queue/processors/db/import-masto-post.ts index 6a39290741..532c288dba 100644 --- a/packages/backend/src/queue/processors/db/import-masto-post.ts +++ b/packages/backend/src/queue/processors/db/import-masto-post.ts @@ -85,18 +85,27 @@ export async function importMastoPost( userId: user.id, }); - // FIXME: What is this condition? - if (note != null && (note.fileIds?.length || 0) < files.length) { + // If an import is completely successful at once, the order should not be out of order. + // If it takes multiple imports to complete, the order is not guaranteed to be consistent. + if (note != null && files.length > 0) { + const addFiles: DriveFile[] = []; + for (const file of files) { + if (!note.fileIds.includes(file.id)) { + addFiles.push(file); + } + } + const update: Partial = {}; - update.fileIds = files.map((x) => x.id); + update.fileIds = addFiles.map((x) => x.id); if (update.fileIds != null) { - await NoteFiles.delete({ noteId: note.id }); await NoteFiles.insert( update.fileIds.map((fileId) => ({ noteId: note?.id, fileId })), ); } + update.fileIds = note.fileIds.concat(update.fileIds); + await Notes.update(note.id, update); await NoteEdits.insert({ id: genId(), From da1a945ffa454be19fe432468f6beeb05adac3f4 Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 4 Jul 2024 00:11:32 +0900 Subject: [PATCH 2/7] docs: update changelog --- docs/changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 00ded7275f..513370dd63 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -5,6 +5,10 @@ Critical security updates are indicated by the :warning: icon. - Server administrators must check [notice-for-admins.md](./notice-for-admins.md) as well. - Third-party client/bot developers may want to check [api-change.md](./api-change.md) as well. +## Unreleased + +- Fix bugs + ## [v20240630](https://firefish.dev/firefish/firefish/-/merge_requests/11072/commits) - Add ability to automatically append #Alt4Me hashtag when posting a file without an alt text ([What is #Alt4Me?](https://social.growyourown.services/@FediTips/112055775451305236)) From e5ee673feddee90c872c79966f8d748393eaa3b4 Mon Sep 17 00:00:00 2001 From: lotigara Date: Wed, 3 Jul 2024 11:05:49 +0000 Subject: [PATCH 3/7] locale: update translations (Russian) Currently translated at 93.6% (1824 of 1947 strings) Translation: Firefish/locales Translate-URL: https://hosted.weblate.org/projects/firefish/locales/ru/ --- locales/ru-RU.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/locales/ru-RU.yml b/locales/ru-RU.yml index 551db955d4..e360b5ae27 100644 --- a/locales/ru-RU.yml +++ b/locales/ru-RU.yml @@ -2137,3 +2137,15 @@ replies: Ответы quotes: Цитаты clickToShowPatterns: Нажмите, чтобы показать модуль шаблонов renotes: Репосты +markLocalFilesNsfwByDefaultDescription: Независимо от данной настройки, пользователи + могут самостоятельно удалять метку NSFW. Не применяется на существующие файлы. +toEdit: Редактировать +attachedToNotes: Посты с этим файлом +showAttachedNotes: Показывать посты с этим файлом +strongPassword: Хороший пароль +toReply: Ответить +toPost: Выложить +sentFollowRequests: Отправленные запросы на подписку +toQuote: Цитировать +cannotEditVisibility: Вы не можете изменить видимость +noSentFollowRequests: Вы не отправляли никаких запросов на подписку From aa01c3d8ce3a79f503d09c2eb3b9b5ee105fd104 Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 4 Jul 2024 00:30:58 +0900 Subject: [PATCH 4/7] chore (client): Firefish versions are lexicographically ordered --- packages/client/src/init.ts | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts index 9ae1db8496..0b5fb24566 100644 --- a/packages/client/src/init.ts +++ b/packages/client/src/init.ts @@ -240,26 +240,20 @@ function checkForSplash() { // テーマリビルドするため localStorage.removeItem("theme"); - try { - // 変なバージョン文字列来るとcompareVersionsでエラーになるため - // If a strange version string comes, an error will occur in compareVersions. - if ( - lastVersion != null && - lastVersion < version && - defaultStore.state.showUpdates - ) { - // ログインしてる場合だけ - if (me) { - popup( - defineAsyncComponent(() => import("@/components/MkUpdated.vue")), - {}, - {}, - "closed", - ); - } + if ( + lastVersion != null && + lastVersion < version && + defaultStore.state.showUpdates + ) { + // ログインしてる場合だけ + if (me) { + popup( + defineAsyncComponent(() => import("@/components/MkUpdated.vue")), + {}, + {}, + "closed", + ); } - } catch (err) { - console.error(err); } } From 7d16beb7b4833db8374701f3319c888a8115028f Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 4 Jul 2024 00:32:09 +0900 Subject: [PATCH 5/7] chore (client): do not call getInstanceInfo twice --- packages/client/src/init.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts index 0b5fb24566..16750c26e0 100644 --- a/packages/client/src/init.ts +++ b/packages/client/src/init.ts @@ -69,6 +69,8 @@ function checkForSplash() { (async () => { await initializeInstanceCache(); + const instance = getInstanceInfo(); + console.info(`Firefish v${version}`); if (_DEV_) { @@ -178,7 +180,7 @@ function checkForSplash() { } // #endregion - localStorage.setItem("v", getInstanceInfo().version); + localStorage.setItem("v", instance.version); // Init service worker initializeSw(); @@ -332,7 +334,7 @@ function checkForSplash() { }; // #endregion - const { defaultLightTheme, defaultDarkTheme } = getInstanceInfo(); + const { defaultLightTheme, defaultDarkTheme } = instance; if (defaultStore.state.themeInitial) { if (defaultLightTheme != null) From 1412b1ce9fcf2f1fc20761ccf14b44f0778625a2 Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 4 Jul 2024 01:38:29 +0900 Subject: [PATCH 6/7] docs: update installation guide --- docs/install.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/install.md b/docs/install.md index c13594e3ac..6a2079fd73 100644 --- a/docs/install.md +++ b/docs/install.md @@ -374,7 +374,7 @@ cd ~/firefish ## Rotate logs -If the server runs long, the size of log files increases, filling up disk space. To prevent this, you should set up a log rotation (removing old logs automatically). +As the server runs longer and longer, the size of the log files increases, filling up the disk space. To prevent this, you should set up a log rotation (removing old logs automatically). You can edit the `SystemMaxUse` value in the `[journal]` section of `/etc/systemd/journald.conf` to do it: @@ -402,13 +402,13 @@ pgroonga.log_level = error You can check the `postgresql.conf` location by this command: ```sh -psql --user postgres --command 'SHOW config_file' +sudo --user=postgres psql --command='SHOW config_file' ``` The PGroonga log file (`pgroonga.log`) is located under this directory: ```sh -psql --user postgres --command 'SHOW data_directory' +sudo --user=postgres psql --command='SHOW data_directory' ``` ## Tune database configuration @@ -431,9 +431,17 @@ Since this is not a dedicated database server, be sure to leave some memory spac Once you have entered the appropriate values for your environment, click the "Generate" button to generate a configuration and replace the values in `postgresql.conf` with the suggested values. +After that, you need to restart the PostgreSQL service. + +```sh +sudo systemctl stop firefish +sudo systemctl restart postgresql +sudo systemctl start firefish +``` + ## VACUUM your database -If the database runs long, "garbage" can degrade its performance or cause problems. To prevent this, you should execute the following commands regularly. +If the database runs long, accumulated "garbage" can degrade its performance or cause problems. To prevent this, you should `VACUUM` your database regularly. ```sh sudo systemctl stop firefish From 9345f37d9a344e27818d2437fb81dc973ca1c70b Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 4 Jul 2024 01:46:13 +0900 Subject: [PATCH 7/7] docs: update notice-for-admins.md --- docs/notice-for-admins.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/notice-for-admins.md b/docs/notice-for-admins.md index 0822f5b869..fbc58623fe 100644 --- a/docs/notice-for-admins.md +++ b/docs/notice-for-admins.md @@ -8,7 +8,9 @@ Please take a look at #10947. ## Unreleased -This is not related to the recent changes, but we have added a new section called "[Maintain the server](https://firefish.dev/firefish/firefish/-/blob/develop/docs/install.md#maintain-the-server)" in the installation guide. We suggest that you take a look at it. +### For all users + +This is not related to the recent changes, but we have added a new section called "[Maintain the server](https://firefish.dev/firefish/firefish/-/blob/develop/docs/install.md#maintain-the-server)" in the installation guide. We suggest that you take a look at it. (and we welcome your docs contributions!) ## v20240607