Compare commits
10 Commits
377b4653d5
...
48bfadde44
Author | SHA1 | Date |
---|---|---|
laozhoubuluo | 48bfadde44 | |
naskya | 971f196627 | |
naskya | 8cc0e40d35 | |
naskya | beeea86253 | |
naskya | 084a4bc63a | |
naskya | cda31d3dc7 | |
naskya | 907578e8f8 | |
naskya | 2923ea86de | |
naskya | 226c990385 | |
老周部落 | 508cb25f54 |
|
@ -56,10 +56,6 @@ packages/backend/assets/instance.css
|
|||
packages/backend/assets/sounds/None.mp3
|
||||
packages/backend/assets/LICENSE
|
||||
|
||||
!/packages/backend/queue/processors/db
|
||||
!/packages/backend/src/db
|
||||
!/packages/backend/src/server/api/endpoints/drive/files
|
||||
|
||||
packages/megalodon/lib
|
||||
packages/megalodon/.idea
|
||||
|
||||
|
|
|
@ -3,8 +3,10 @@ image: docker.io/rust:slim-bookworm
|
|||
services:
|
||||
- name: docker.io/groonga/pgroonga:latest-alpine-12-slim
|
||||
alias: postgres
|
||||
pull_policy: if-not-present
|
||||
- name: docker.io/redis:7-alpine
|
||||
alias: redis
|
||||
pull_policy: if-not-present
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
|
@ -12,6 +14,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:
|
||||
|
@ -79,10 +86,7 @@ client_build_test:
|
|||
- 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:
|
||||
|
@ -93,6 +97,15 @@ client_build_test:
|
|||
- Cargo.toml
|
||||
- Cargo.lock
|
||||
when: never
|
||||
services: []
|
||||
before_script:
|
||||
- apt-get update && apt-get -y upgrade
|
||||
- apt-get -y --no-install-recommends install curl
|
||||
- curl -fsSL 'https://deb.nodesource.com/setup_18.x' | bash -
|
||||
- apt-get install -y --no-install-recommends build-essential python3 perl nodejs
|
||||
- corepack enable
|
||||
- corepack prepare pnpm@latest --activate
|
||||
- cp .config/ci.yml .config/default.yml
|
||||
script:
|
||||
- pnpm install --frozen-lockfile
|
||||
- pnpm --filter 'firefish-js' --filter 'client' --filter 'sw' run build:debug
|
||||
|
@ -119,8 +132,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}"
|
||||
|
||||
|
@ -157,8 +183,12 @@ cargo_clippy:
|
|||
- Cargo.lock
|
||||
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'main'
|
||||
when: never
|
||||
script:
|
||||
services: []
|
||||
before_script:
|
||||
- apt-get install -y --no-install-recommends build-essential clang mold perl
|
||||
- cp ci/cargo/config.toml /usr/local/cargo/config.toml
|
||||
- rustup component add clippy
|
||||
script:
|
||||
- cargo clippy -- -D warnings
|
||||
|
||||
renovate:
|
||||
|
|
|
@ -1292,7 +1292,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]`.
|
||||
|
|
|
@ -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, 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, publishToChannelStream, ChatEvent, publishToChatStream, ChatIndexEvent, publishToChatIndexStream, publishToBroadcastStream, publishToGroupChatStream, publishToModerationStream, getTimestamp, genId, genIdAt, secureRndstr } = nativeBinding
|
||||
|
||||
module.exports.SECOND = SECOND
|
||||
module.exports.MINUTE = MINUTE
|
||||
|
@ -381,7 +381,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
|
||||
|
|
|
@ -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}")]
|
||||
|
|
|
@ -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)?))
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
import { noteVisibilities } from "@/types.js";
|
||||
|
||||
export type Post = {
|
||||
text: string | undefined;
|
||||
cw: string | null;
|
||||
|
@ -12,7 +14,9 @@ export function parse(acct: any): Post {
|
|||
cw: acct.cw,
|
||||
localOnly: acct.localOnly,
|
||||
createdAt: new Date(acct.createdAt),
|
||||
visibility: `hidden${acct.visibility || ""}`,
|
||||
visibility: noteVisibilities.includes(acct.visibility)
|
||||
? acct.visibility
|
||||
: "public",
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -83,22 +83,27 @@ export async function importCkPost(
|
|||
logger.info("Post updated");
|
||||
}
|
||||
if (note == null) {
|
||||
note = await create(user, {
|
||||
createdAt: createdAt,
|
||||
files: files.length === 0 ? undefined : files,
|
||||
poll: undefined,
|
||||
text: text || undefined,
|
||||
reply: post.replyId ? job.data.parent : null,
|
||||
renote: post.renoteId ? job.data.parent : null,
|
||||
cw: cw,
|
||||
localOnly,
|
||||
visibility: visibility,
|
||||
visibleUsers: [],
|
||||
channel: null,
|
||||
apMentions: new Array(0),
|
||||
apHashtags: undefined,
|
||||
apEmojis: undefined,
|
||||
});
|
||||
note = await create(
|
||||
user,
|
||||
{
|
||||
createdAt: createdAt,
|
||||
files: files.length === 0 ? undefined : files,
|
||||
poll: undefined,
|
||||
text: text || undefined,
|
||||
reply: post.replyId ? job.data.parent : null,
|
||||
renote: post.renoteId ? job.data.parent : null,
|
||||
cw: cw,
|
||||
localOnly,
|
||||
visibility: visibility,
|
||||
visibleUsers: [],
|
||||
channel: null,
|
||||
apMentions: new Array(0),
|
||||
apHashtags: undefined,
|
||||
apEmojis: undefined,
|
||||
},
|
||||
false,
|
||||
true,
|
||||
);
|
||||
logger.debug("New post has been created");
|
||||
} else {
|
||||
logger.info("This post already exists");
|
||||
|
|
|
@ -109,24 +109,30 @@ export async function importMastoPost(
|
|||
logger.info("Post updated");
|
||||
}
|
||||
if (note == null) {
|
||||
note = await create(user, {
|
||||
createdAt: isRenote
|
||||
? new Date(post.published)
|
||||
: new Date(post.object.published),
|
||||
files: files.length === 0 ? undefined : files,
|
||||
poll: undefined,
|
||||
text: text || undefined,
|
||||
reply,
|
||||
renote,
|
||||
cw: !isRenote && post.object.sensitive ? post.object.summary : undefined,
|
||||
localOnly: false,
|
||||
visibility: "hiddenpublic",
|
||||
visibleUsers: [],
|
||||
channel: null,
|
||||
apMentions: new Array(0),
|
||||
apHashtags: undefined,
|
||||
apEmojis: undefined,
|
||||
});
|
||||
note = await create(
|
||||
user,
|
||||
{
|
||||
createdAt: isRenote
|
||||
? new Date(post.published)
|
||||
: new Date(post.object.published),
|
||||
files: files.length === 0 ? undefined : files,
|
||||
poll: undefined,
|
||||
text: text || undefined,
|
||||
reply,
|
||||
renote,
|
||||
cw:
|
||||
!isRenote && post.object.sensitive ? post.object.summary : undefined,
|
||||
localOnly: false,
|
||||
visibility: "public",
|
||||
visibleUsers: [],
|
||||
channel: null,
|
||||
apMentions: new Array(0),
|
||||
apHashtags: undefined,
|
||||
apEmojis: undefined,
|
||||
},
|
||||
false,
|
||||
true,
|
||||
);
|
||||
logger.debug("New post has been created");
|
||||
} else {
|
||||
logger.info("This post already exists");
|
||||
|
|
|
@ -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";
|
||||
|
@ -172,11 +175,12 @@ export default async (
|
|||
},
|
||||
data: Option,
|
||||
silent = false,
|
||||
dontFederateInitially = false,
|
||||
) =>
|
||||
// biome-ignore lint/suspicious/noAsyncPromiseExecutor: FIXME
|
||||
new Promise<Note>(async (res, rej) => {
|
||||
const dontFederateInitially =
|
||||
data.visibility?.startsWith("hidden") === true;
|
||||
const dontFederateInitiallyFlag =
|
||||
data.visibility === "hidden" ? true : dontFederateInitially;
|
||||
|
||||
// If you reply outside the channel, match the scope of the target.
|
||||
// TODO (I think it's a process that could be done on the client side, but it's server side for now.)
|
||||
|
@ -210,8 +214,6 @@ export default async (
|
|||
if (data.channel != null) data.visibility = "public";
|
||||
if (data.channel != null) data.visibleUsers = [];
|
||||
if (data.channel != null) data.localOnly = true;
|
||||
if (data.visibility.startsWith("hidden") && data.visibility !== "hidden")
|
||||
data.visibility = data.visibility.slice(6);
|
||||
|
||||
// enforce silent clients on server
|
||||
if (
|
||||
|
@ -474,7 +476,7 @@ export default async (
|
|||
}
|
||||
}
|
||||
|
||||
if (!dontFederateInitially) {
|
||||
if (!dontFederateInitiallyFlag) {
|
||||
let publishKey: string;
|
||||
let noteToPublish: Note;
|
||||
const relays = await getCachedRelays();
|
||||
|
@ -508,7 +510,7 @@ export default async (
|
|||
30,
|
||||
);
|
||||
}
|
||||
publishToNotesStream(toRustObject(noteToPublish));
|
||||
publishNotesStream(noteToPublish);
|
||||
}
|
||||
} finally {
|
||||
await lock.release();
|
||||
|
@ -612,7 +614,7 @@ export default async (
|
|||
});
|
||||
|
||||
//#region AP deliver
|
||||
if (Users.isLocalUser(user) && !dontFederateInitially) {
|
||||
if (Users.isLocalUser(user) && !dontFederateInitiallyFlag) {
|
||||
(async () => {
|
||||
const noteActivity = await renderNoteOrRenoteActivity(data, note);
|
||||
const dm = new DeliverManager(user, noteActivity);
|
||||
|
|
|
@ -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 = <K extends keyof AdminStreamTypes>(
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue