diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8f4f4d54c7..4a6e4b5f98 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,11 @@ workflow: when: always - if: $CI_MERGE_REQUEST_PROJECT_PATH == 'firefish/firefish' when: always + - if: $CI_PROJECT_PATH != 'firefish/firefish' + changes: + paths: + - .gitlab-ci.yml + when: never - when: never cache: @@ -56,9 +61,11 @@ build_test: - if: $CI_PIPELINE_SOURCE == 'push' || $CI_PIPELINE_SOURCE == 'merge_request_event' changes: paths: - - packages/**/* + - packages/backend/* + - packages/backend-rs/* + - packages/macro-rs/* + - packages/megalodon/* - scripts/**/* - - locales/**/* - package.json - pnpm-lock.yaml - Cargo.toml @@ -68,6 +75,33 @@ build_test: - pnpm run build:debug - pnpm run migrate +client_build_test: + stage: test + rules: + - if: $CI_PIPELINE_SOURCE == 'push' || $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + paths: + - packages/client/* + - packages/firefish-js/* + - packages/sw/* + - scripts/**/* + - locales/**/* + - package.json + - pnpm-lock.yaml + - if: $CI_PIPELINE_SOURCE == 'push' || $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + paths: + - packages/backend/* + - packages/backend-rs/* + - packages/macro-rs/* + - packages/megalodon/* + - Cargo.toml + - Cargo.lock + when: never + script: + - pnpm install --frozen-lockfile + - pnpm --filter 'firefish-js' --filter 'client' --filter 'sw' run build:debug + container_image_build: stage: build image: docker.io/debian:bookworm-slim @@ -90,8 +124,21 @@ container_image_build: - apt-get install -y --no-install-recommends buildah ca-certificates fuse-overlayfs - buildah login --username "${CI_REGISTRY_USER}" --password "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}" - export IMAGE_TAG="${CI_REGISTRY}/${CI_PROJECT_PATH}/develop:not-for-production" + - export IMAGE_CACHE="${CI_REGISTRY}/${CI_PROJECT_PATH}/develop/cache" script: - - buildah build --isolation chroot --device /dev/fuse:rw --security-opt seccomp=unconfined --security-opt apparmor=unconfined --cap-add all --tag "${IMAGE_TAG}" --platform linux/amd64 . + - |- + buildah build \ + --isolation chroot \ + --device /dev/fuse:rw \ + --security-opt seccomp=unconfined \ + --security-opt apparmor=unconfined \ + --cap-add all \ + --platform linux/amd64 \ + --layers \ + --cache-to "${IMAGE_CACHE}" \ + --cache-from "${IMAGE_CACHE}" \ + --tag "${IMAGE_TAG}" \ + . - buildah inspect "${IMAGE_TAG}" - buildah push "${IMAGE_TAG}" @@ -119,7 +166,7 @@ cargo_unit_test: cargo_clippy: stage: test rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == 'develop' changes: paths: - packages/backend-rs/**/* @@ -129,6 +176,7 @@ cargo_clippy: - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'main' when: never script: + - rustup component add clippy - cargo clippy -- -D warnings renovate: diff --git a/packages/backend-rs/index.d.ts b/packages/backend-rs/index.d.ts index 86cc5c14e4..2900c59675 100644 --- a/packages/backend-rs/index.d.ts +++ b/packages/backend-rs/index.d.ts @@ -1301,7 +1301,6 @@ export interface AbuseUserReportLike { comment: string } export function publishToModerationStream(moderatorId: string, report: AbuseUserReportLike): void -export function publishToNotesStream(note: Note): void export function getTimestamp(id: string): number /** * The generated ID results in the form of `[8 chars timestamp] + [cuid2]`. diff --git a/packages/backend-rs/index.js b/packages/backend-rs/index.js index c79fafabe9..ffd10377a8 100644 --- a/packages/backend-rs/index.js +++ b/packages/backend-rs/index.js @@ -310,7 +310,7 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { SECOND, MINUTE, HOUR, DAY, USER_ONLINE_THRESHOLD, USER_ACTIVE_THRESHOLD, FILE_TYPE_BROWSERSAFE, loadEnv, loadConfig, stringToAcct, acctToString, addNoteToAntenna, isBlockedServer, isSilencedServer, isAllowedServer, checkWordMute, getFullApAccount, isSelfHost, isSameOrigin, extractHost, toPuny, isUnicodeEmoji, sqlLikeEscape, safeForSql, formatMilliseconds, getImageSizeFromUrl, getNoteSummary, isSafeUrl, latestVersion, toMastodonId, fromMastodonId, fetchMeta, metaToPugArgs, nyaify, hashPassword, verifyPassword, isOldPasswordAlgorithm, decodeReaction, countReactions, toDbReaction, removeOldAttestationChallenges, AntennaSrcEnum, DriveFileUsageHintEnum, MutedNoteReasonEnum, NoteVisibilityEnum, NotificationTypeEnum, PageVisibilityEnum, PollNotevisibilityEnum, RelayStatusEnum, UserEmojimodpermEnum, UserProfileFfvisibilityEnum, UserProfileMutingnotificationtypesEnum, initializeRustLogger, fetchNodeinfo, nodeinfo_2_1, nodeinfo_2_0, Protocol, Inbound, Outbound, watchNote, unwatchNote, PushNotificationKind, sendPushNotification, publishToChannelStream, ChatEvent, publishToChatStream, ChatIndexEvent, publishToChatIndexStream, publishToBroadcastStream, publishToGroupChatStream, publishToModerationStream, publishToNotesStream, getTimestamp, genId, genIdAt, secureRndstr } = nativeBinding +const { SECOND, MINUTE, HOUR, DAY, USER_ONLINE_THRESHOLD, USER_ACTIVE_THRESHOLD, FILE_TYPE_BROWSERSAFE, loadEnv, loadConfig, stringToAcct, acctToString, addNoteToAntenna, isBlockedServer, isSilencedServer, isAllowedServer, checkWordMute, getFullApAccount, isSelfHost, isSameOrigin, extractHost, toPuny, isUnicodeEmoji, sqlLikeEscape, safeForSql, formatMilliseconds, getImageSizeFromUrl, getNoteSummary, isSafeUrl, latestVersion, toMastodonId, fromMastodonId, fetchMeta, metaToPugArgs, nyaify, hashPassword, verifyPassword, isOldPasswordAlgorithm, decodeReaction, countReactions, toDbReaction, removeOldAttestationChallenges, AntennaSrcEnum, DriveFileUsageHintEnum, MutedNoteReasonEnum, NoteVisibilityEnum, NotificationTypeEnum, PageVisibilityEnum, PollNotevisibilityEnum, RelayStatusEnum, UserEmojimodpermEnum, UserProfileFfvisibilityEnum, UserProfileMutingnotificationtypesEnum, initializeRustLogger, fetchNodeinfo, nodeinfo_2_1, nodeinfo_2_0, Protocol, Inbound, Outbound, watchNote, unwatchNote, PushNotificationKind, sendPushNotification, publishToChannelStream, ChatEvent, publishToChatStream, ChatIndexEvent, publishToChatIndexStream, publishToBroadcastStream, publishToGroupChatStream, publishToModerationStream, getTimestamp, genId, genIdAt, secureRndstr } = nativeBinding module.exports.SECOND = SECOND module.exports.MINUTE = MINUTE @@ -383,7 +383,6 @@ module.exports.publishToChatIndexStream = publishToChatIndexStream module.exports.publishToBroadcastStream = publishToBroadcastStream module.exports.publishToGroupChatStream = publishToGroupChatStream module.exports.publishToModerationStream = publishToModerationStream -module.exports.publishToNotesStream = publishToNotesStream module.exports.getTimestamp = getTimestamp module.exports.genId = genId module.exports.genIdAt = genIdAt diff --git a/packages/backend-rs/src/service/stream.rs b/packages/backend-rs/src/service/stream.rs index bf957a6e9b..279d343f10 100644 --- a/packages/backend-rs/src/service/stream.rs +++ b/packages/backend-rs/src/service/stream.rs @@ -5,7 +5,6 @@ pub mod chat_index; pub mod custom_emoji; pub mod group_chat; pub mod moderation; -pub mod new_note; use crate::config::CONFIG; use crate::database::redis_conn; @@ -26,7 +25,7 @@ pub enum Stream { #[strum(to_string = "noteStream:{note_id}")] Note { note_id: String }, #[strum(serialize = "notesStream")] - NewNote, + Notes, #[strum(to_string = "userListStream:{list_id}")] UserList { list_id: String }, #[strum(to_string = "mainStream:{user_id}")] diff --git a/packages/backend-rs/src/service/stream/new_note.rs b/packages/backend-rs/src/service/stream/new_note.rs deleted file mode 100644 index 5386252ff7..0000000000 --- a/packages/backend-rs/src/service/stream/new_note.rs +++ /dev/null @@ -1,10 +0,0 @@ -use crate::model::entity::note; -use crate::service::stream::{publish_to_stream, Error, Stream}; - -// for napi export (https://github.com/napi-rs/napi-rs/issues/2060) -type Note = note::Model; - -#[crate::export(js_name = "publishToNotesStream")] -pub fn publish(note: &Note) -> Result<(), Error> { - publish_to_stream(&Stream::NewNote, None, Some(serde_json::to_string(note)?)) -} diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 95670b06b5..2096f8b1a2 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -1,5 +1,9 @@ import * as mfm from "mfm-js"; -import { publishMainStream, publishNoteStream } from "@/services/stream.js"; +import { + publishMainStream, + publishNotesStream, + publishNoteStream, +} from "@/services/stream.js"; import DeliverManager from "@/remote/activitypub/deliver-manager.js"; import renderNote from "@/remote/activitypub/renderer/note.js"; import renderCreate from "@/remote/activitypub/renderer/create.js"; @@ -45,7 +49,6 @@ import { genId, genIdAt, isSilencedServer, - publishToNotesStream, } from "backend-rs"; import { countSameRenotes } from "@/misc/count-same-renotes.js"; import { deliverToRelays, getCachedRelays } from "../relay.js"; @@ -508,7 +511,7 @@ export default async ( 30, ); } - publishToNotesStream(toRustObject(noteToPublish)); + publishNotesStream(noteToPublish); } } finally { await lock.release(); diff --git a/packages/backend/src/services/stream.ts b/packages/backend/src/services/stream.ts index c60d5ce974..36914d4d41 100644 --- a/packages/backend/src/services/stream.ts +++ b/packages/backend/src/services/stream.ts @@ -193,10 +193,9 @@ class Publisher { // ); // }; - /* ported to backend-rs */ - // public publishNotesStream = (note: Note): void => { - // this.publish("notesStream", null, note); - // }; + public publishNotesStream = (note: Note): void => { + this.publish("notesStream", null, note); + }; /* ported to backend-rs */ // public publishAdminStream = ( @@ -222,7 +221,7 @@ export const publishUserEvent = publisher.publishUserEvent; export const publishMainStream = publisher.publishMainStream; export const publishDriveStream = publisher.publishDriveStream; export const publishNoteStream = publisher.publishNoteStream; -// export const publishNotesStream = publisher.publishNotesStream; +export const publishNotesStream = publisher.publishNotesStream; // export const publishChannelStream = publisher.publishChannelStream; export const publishUserListStream = publisher.publishUserListStream; // export const publishAntennaStream = publisher.publishAntennaStream; diff --git a/packages/client/src/components/global/MkTime.vue b/packages/client/src/components/global/MkTime.vue index 1f9333cd74..7cbbb77b0b 100644 --- a/packages/client/src/components/global/MkTime.vue +++ b/packages/client/src/components/global/MkTime.vue @@ -10,7 +10,7 @@