Merge branch 'develop' into iceshrimp_mastodon

This commit is contained in:
naskya 2024-07-02 23:54:11 +09:00
commit 76c411f1ff
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
13 changed files with 314 additions and 469 deletions

View file

@ -37,6 +37,7 @@ variables:
POSTGRES_PASSWORD: 'password'
POSTGRES_HOST_AUTH_METHOD: 'trust'
DEBIAN_FRONTEND: 'noninteractive'
NODE_OPTIONS: '--max_old_space_size=3072'
CARGO_PROFILE_DEV_OPT_LEVEL: '0'
CARGO_PROFILE_DEV_LTO: 'off'
CARGO_PROFILE_DEV_DEBUG: 'none'
@ -119,7 +120,7 @@ test:build:backend_ts:
- cp packages/backend-rs/index.js packages/backend-rs/built/index.js
- cp packages/backend-rs/index.d.ts packages/backend-rs/built/index.d.ts
- cp ci/cargo/config.toml /usr/local/cargo/config.toml
- test -f packages/backend-rs/built/backend-rs.linux-x64-gnu.node || pnpm --filter 'backend-rs' run build:debug
- test -f packages/backend-rs/built/backend-rs.linux-x64-gnu.node || pnpm install --frozen-lockfile && pnpm --filter 'backend-rs' run build:debug
- cp .config/ci.yml .config/default.yml
- export PGPASSWORD="${POSTGRES_PASSWORD}"
- psql --host postgres --user "${POSTGRES_USER}" --dbname "${POSTGRES_DB}" --command 'CREATE EXTENSION pgroonga'

18
Cargo.lock generated
View file

@ -207,7 +207,7 @@ dependencies = [
"chrono",
"cuid2",
"emojis",
"idna 1.0.1",
"idna 1.0.2",
"image",
"isahc",
"macros",
@ -1403,9 +1403,9 @@ dependencies = [
[[package]]
name = "idna"
version = "1.0.1"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44a986806a1cc899952ba462bc1f28afbfd5850ab6cb030ccb20dd02cc527a24"
checksum = "bd69211b9b519e98303c015e21a007e293db403b6c85b9b124e133d25e242cdd"
dependencies = [
"icu_normalizer",
"icu_properties",
@ -1831,9 +1831,9 @@ checksum = "e1c0f5d67ee408a4685b61f5ab7e58605c8ae3f2b4189f0127d804ff13d5560a"
[[package]]
name = "napi-derive"
version = "2.16.6"
version = "2.16.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70a8a778fd367b13c64232e58632514b795514ece491ce136d96e976d34a3eb8"
checksum = "eafd2b920906ea5b1f5f1f9d1eff9cc74e4ff8124dca41b501c1413079589187"
dependencies = [
"cfg-if",
"convert_case",
@ -1845,9 +1845,9 @@ dependencies = [
[[package]]
name = "napi-derive-backend"
version = "1.0.68"
version = "1.0.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35849e64596ecd467e1ac897153364a1ffd09b1d79b32ebad94ef8980ac73311"
checksum = "b370b784440c65eb9001d839012eb912ee43e3a2d0361e2c30c13052372c39fe"
dependencies = [
"convert_case",
"once_cell",
@ -2960,9 +2960,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.118"
version = "1.0.120"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4"
checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5"
dependencies = [
"itoa",
"ryu",

View file

@ -7,7 +7,7 @@ macros = { path = "packages/macro-rs/macros" }
macros-impl = { path = "packages/macro-rs/macros-impl" }
napi = "2.16.8"
napi-derive = "2.16.6"
napi-derive = "2.16.8"
napi-build = "2.1.3"
argon2 = { version = "0.5.3", default-features = false }
@ -19,7 +19,7 @@ chrono = { version = "0.4.38", default-features = false }
convert_case = { version = "0.6.0", default-features = false }
cuid2 = { version = "0.1.2", default-features = false }
emojis = { version = "0.6.2", default-features = false }
idna = { version = "1.0.1", default-features = false }
idna = { version = "1.0.2", default-features = false }
image = { version = "0.25.1", default-features = false }
isahc = { version = "1.7.2", default-features = false }
nom-exif = { version = "1.2.0", default-features = false }
@ -33,7 +33,7 @@ regex = { version = "1.10.5", default-features = false }
rmp-serde = { version = "1.3.0", default-features = false }
sea-orm = { version = "0.12.15", default-features = false }
serde = { version = "1.0.203", default-features = false }
serde_json = { version = "1.0.118", default-features = false }
serde_json = { version = "1.0.120", default-features = false }
serde_yaml = { version = "0.9.34", default-features = false }
syn = { version = "2.0.68", default-features = false }
sysinfo = { version = "0.30.12", default-features = false }

View file

@ -26,7 +26,7 @@ COPY packages/backend-rs packages/backend-rs/
# Compile backend-rs
RUN ln -s $(which gcc) /usr/bin/aarch64-linux-musl-gcc
RUN NODE_ENV='production' pnpm run --filter backend-rs build
RUN NODE_ENV='production' NODE_OPTIONS='--max_old_space_size=3072' pnpm run --filter backend-rs build
# Copy/Overwrite index.js to mitigate the bug in napi-rs codegen
COPY packages/backend-rs/index.js packages/backend-rs/built/index.js
@ -45,7 +45,7 @@ RUN pnpm install --frozen-lockfile
COPY . ./
# Build other workspaces
RUN NODE_ENV='production' pnpm run --recursive --filter '!backend-rs' build && pnpm run build:assets
RUN NODE_ENV='production' NODE_OPTIONS='--max_old_space_size=3072' pnpm run --recursive --filter '!backend-rs' build && pnpm run build:assets
# Trim down the dependencies to only those for production
RUN find . -path '*/node_modules/*' -delete && pnpm install --prod --frozen-lockfile

View file

@ -46,7 +46,7 @@ export interface Acct {
host: string | null
}
export function acctToString(acct: Acct): string
export declare function acctToString(acct: Acct): string
export interface Ad {
id: string
@ -194,7 +194,7 @@ export enum ChatIndexEvent {
* * `muted_words` : list of muted keyword lists (each array item is a space-separated keyword list that represents an AND condition)
* * `muted_patterns` : list of JavaScript-style (e.g., `/foo/i`) regular expressions
*/
export function checkWordMute(note: PartialNoteToCheckWordMute, mutedWords: Array<string>, mutedPatterns: Array<string>): Promise<boolean>
export declare function checkWordMute(note: PartialNoteToCheckWordMute, mutedWords: Array<string>, mutedPatterns: Array<string>): Promise<boolean>
export interface Clip {
id: string
@ -263,16 +263,16 @@ export interface Config {
userAgent: string
}
export function countReactions(reactions: Record<string, number>): Record<string, number>
export declare function countReactions(reactions: Record<string, number>): Record<string, number>
export interface Cpu {
model: string
cores: number
}
export function cpuInfo(): Cpu
export declare function cpuInfo(): Cpu
export function cpuUsage(): number
export declare function cpuUsage(): number
export const DAY: number
@ -292,7 +292,7 @@ export interface DecodedReaction {
host: string | null
}
export function decodeReaction(reaction: string): DecodedReaction
export declare function decodeReaction(reaction: string): DecodedReaction
export interface DeepLConfig {
managed?: boolean
@ -381,12 +381,12 @@ export interface Emoji {
height: number | null
}
export function extractHost(uri: string): string
export declare function extractHost(uri: string): string
export function fetchMeta(): Promise<Meta>
export declare function fetchMeta(): Promise<Meta>
/** Fetches and returns the NodeInfo (version 2.0) of a remote server. */
export function fetchNodeinfo(host: string): Promise<Nodeinfo>
export declare function fetchNodeinfo(host: string): Promise<Nodeinfo>
/**
* List of file types allowed to be viewed directly in the browser
@ -427,7 +427,7 @@ export interface FollowRequest {
}
/** Converts milliseconds to a human readable string. */
export function formatMilliseconds(milliseconds: number): string
export declare function formatMilliseconds(milliseconds: number): string
export interface GalleryLike {
id: string
@ -450,9 +450,9 @@ export interface GalleryPost {
}
/** Generates a random string based on [thread_rng] and [Alphanumeric]. */
export function generateSecureRandomString(length: number): string
export declare function generateSecureRandomString(length: number): string
export function generateUserToken(): string
export declare function generateUserToken(): string
/**
* The generated ID results in the form of `[8 chars timestamp] + [cuid2]`.
@ -462,24 +462,24 @@ export function generateUserToken(): string
*
* Ref: <https://github.com/paralleldrive/cuid2#parameterized-length>
*/
export function genId(): string
export declare function genId(): string
/** Generate an ID using a specific datetime */
export function genIdAt(date: Date): string
export declare function genIdAt(date: Date): string
export function getFullApAccount(username: string, host?: string | undefined | null): string
export declare function getFullApAccount(username: string, host?: string | undefined | null): string
export function getImageSizeFromUrl(url: string): Promise<ImageSize>
export declare function getImageSizeFromUrl(url: string): Promise<ImageSize>
export function getNoteSummary(fileIds: Array<string>, text: string | undefined | null, cw: string | undefined | null, hasPoll: boolean): string
export declare function getNoteSummary(fileIds: Array<string>, text: string | undefined | null, cw: string | undefined | null, hasPoll: boolean): string
export function getTimestamp(id: string): number
export declare function getTimestamp(id: string): number
/** Prints the greeting message and the Firefish version to stdout. */
export function greet(): void
export declare function greet(): void
/** Hashes the given password using [argon2] algorithm. */
export function hashPassword(password: string): string
export declare function hashPassword(password: string): string
export interface Hashtag {
id: string
@ -523,7 +523,7 @@ export enum Inbound {
}
/** Initializes the [tracing] logger. */
export function initializeRustLogger(): void
export declare function initializeRustLogger(): void
export interface Instance {
id: string
@ -571,7 +571,7 @@ export interface Instance {
* # }
* ```
*/
export function isAllowedServer(host: string): Promise<boolean>
export declare function isAllowedServer(host: string): Promise<boolean>
/**
* Checks if a server is blocked.
@ -591,18 +591,18 @@ export function isAllowedServer(host: string): Promise<boolean>
* # }
* ```
*/
export function isBlockedServer(host: string): Promise<boolean>
export declare function isBlockedServer(host: string): Promise<boolean>
/** Returns whether the [bcrypt] algorithm is used for the password hash. */
export function isOldPasswordAlgorithm(hash: string): boolean
export declare function isOldPasswordAlgorithm(hash: string): boolean
export function isQuote(note: NoteLikeForIsQuote): boolean
export declare function isQuote(note: NoteLikeForIsQuote): boolean
export function isSafeUrl(url: string): boolean
export declare function isSafeUrl(url: string): boolean
export function isSameOrigin(uri: string): boolean
export declare function isSameOrigin(uri: string): boolean
export function isSelfHost(host?: string | undefined | null): boolean
export declare function isSelfHost(host?: string | undefined | null): boolean
/**
* Checks if a server is silenced.
@ -622,12 +622,12 @@ export function isSelfHost(host?: string | undefined | null): boolean
* # }
* ```
*/
export function isSilencedServer(host: string): Promise<boolean>
export declare function isSilencedServer(host: string): Promise<boolean>
export function isUnicodeEmoji(s: string): boolean
export declare function isUnicodeEmoji(s: string): boolean
/** Returns the latest Firefish version. */
export function latestVersion(): Promise<string>
export declare function latestVersion(): Promise<string>
export interface LibreTranslateConfig {
managed?: boolean
@ -635,7 +635,7 @@ export interface LibreTranslateConfig {
apiKey?: string
}
export function loadConfig(): Config
export declare function loadConfig(): Config
export interface Memory {
/** Total memory amount in bytes */
@ -646,7 +646,7 @@ export interface Memory {
available: number
}
export function memoryUsage(): Memory
export declare function memoryUsage(): Memory
export interface MessagingMessage {
id: string
@ -749,7 +749,7 @@ export interface Meta {
antennaLimit: number
}
export function metaToPugArgs(meta: Meta): PugArgs
export declare function metaToPugArgs(meta: Meta): PugArgs
export interface Migrations {
id: number
@ -805,9 +805,9 @@ export interface Nodeinfo {
metadata: Record<string, any>
}
export function nodeinfo_2_0(): Promise<any>
export declare function nodeinfo_2_0(): Promise<any>
export function nodeinfo_2_1(): Promise<any>
export declare function nodeinfo_2_1(): Promise<any>
export interface Note {
id: string
@ -969,7 +969,7 @@ export enum NotificationType {
* assert_eq!(nyaify("I'll take a nap.", Some("en")), "I'll take a nyap.");
* ```
*/
export function nyaify(text: string, lang?: string | undefined | null): string
export declare function nyaify(text: string, lang?: string | undefined | null): string
export interface ObjectStorageConfig {
managed?: boolean
@ -1131,23 +1131,23 @@ export enum Protocol {
Zot = 9
}
export function publishToBroadcastStream(emoji: PackedEmoji): Promise<void>
export declare function publishToBroadcastStream(emoji: PackedEmoji): Promise<void>
export function publishToChannelStream(channelId: string, userId: string): Promise<void>
export declare function publishToChannelStream(channelId: string, userId: string): Promise<void>
export function publishToChatIndexStream(userId: string, kind: ChatIndexEvent, object: any): Promise<void>
export declare function publishToChatIndexStream(userId: string, kind: ChatIndexEvent, object: any): Promise<void>
export function publishToChatStream(senderUserId: string, receiverUserId: string, kind: ChatEvent, object: any): Promise<void>
export declare function publishToChatStream(senderUserId: string, receiverUserId: string, kind: ChatEvent, object: any): Promise<void>
export function publishToDriveFileStream(userId: string, kind: DriveFileEvent, object: any): Promise<void>
export declare function publishToDriveFileStream(userId: string, kind: DriveFileEvent, object: any): Promise<void>
export function publishToDriveFolderStream(userId: string, kind: DriveFolderEvent, object: any): Promise<void>
export declare function publishToDriveFolderStream(userId: string, kind: DriveFolderEvent, object: any): Promise<void>
export function publishToGroupChatStream(groupId: string, kind: ChatEvent, object: any): Promise<void>
export declare function publishToGroupChatStream(groupId: string, kind: ChatEvent, object: any): Promise<void>
export function publishToModerationStream(moderatorId: string, report: AbuseUserReportLike): Promise<void>
export declare function publishToModerationStream(moderatorId: string, report: AbuseUserReportLike): Promise<void>
export function publishToNotesStream(note: Note): Promise<void>
export declare function publishToNotesStream(note: Note): Promise<void>
export interface PugArgs {
img: string | null
@ -1225,7 +1225,7 @@ export enum RelayStatus {
}
/** Delete all entries in the [attestation_challenge] table created at more than 5 minutes ago */
export function removeOldAttestationChallenges(): Promise<void>
export declare function removeOldAttestationChallenges(): Promise<void>
export interface RenoteMuting {
id: string
@ -1242,11 +1242,11 @@ export interface ReplyMuting {
}
/** Returns `true` if `src` does not contain suspicious characters like `%`. */
export function safeForSql(src: string): boolean
export declare function safeForSql(src: string): boolean
export const SECOND: number
export function sendPushNotification(receiverUserId: string, kind: PushNotificationKind, content: any): Promise<void>
export declare function sendPushNotification(receiverUserId: string, kind: PushNotificationKind, content: any): Promise<void>
export interface ServerConfig {
url: string
@ -1307,7 +1307,7 @@ export interface Services {
}
/** Prints the server hardware information as the server info log. */
export function showServerInfo(): void
export declare function showServerInfo(): void
export interface Signin {
id: string
@ -1327,9 +1327,9 @@ export interface Software20 {
}
/** Escapes `%` and `\` in the given string. */
export function sqlLikeEscape(src: string): string
export declare function sqlLikeEscape(src: string): string
export function sqlRegexEscape(src: string): string
export declare function sqlRegexEscape(src: string): string
export interface Storage {
/** Total storage space in bytes */
@ -1338,9 +1338,9 @@ export interface Storage {
used: number
}
export function storageUsage(): Storage | null
export declare function storageUsage(): Storage | null
export function stringToAcct(acct: string): Acct
export declare function stringToAcct(acct: string): Acct
export interface SwSubscription {
id: string
@ -1364,19 +1364,19 @@ export interface TlsConfig {
rejectUnauthorized: boolean
}
export function toDbReaction(reaction?: string | undefined | null, host?: string | undefined | null): Promise<string>
export declare function toDbReaction(reaction?: string | undefined | null, host?: string | undefined | null): Promise<string>
export function toPuny(host: string): string
export declare function toPuny(host: string): string
export function unwatchNote(watcherId: string, noteId: string): Promise<void>
export declare function unwatchNote(watcherId: string, noteId: string): Promise<void>
export function updateAntennaCache(): Promise<void>
export declare function updateAntennaCache(): Promise<void>
export function updateAntennasOnNewNote(note: Note, noteAuthor: Acct, noteMutedUsers: Array<string>): Promise<void>
export declare function updateAntennasOnNewNote(note: Note, noteAuthor: Acct, noteMutedUsers: Array<string>): Promise<void>
export function updateMetaCache(): Promise<void>
export declare function updateMetaCache(): Promise<void>
export function updateNodeinfoCache(): Promise<void>
export declare function updateNodeinfoCache(): Promise<void>
/** Usage statistics for this server. */
export interface Usage {
@ -1596,9 +1596,9 @@ export interface UserSecurityKey {
}
/** Checks whether the given password and hash match. */
export function verifyPassword(password: string, hash: string): boolean
export declare function verifyPassword(password: string, hash: string): boolean
export function watchNote(watcherId: string, noteAuthorId: string, noteId: string): Promise<void>
export declare function watchNote(watcherId: string, noteAuthorId: string, noteId: string): Promise<void>
export interface Webhook {
id: string

View file

@ -1,4 +1,3 @@
// TODO?: handle name collisions
#[macros::export(object, js_name = "NoteLikeForIsQuote")]
pub struct NoteLike {
pub renote_id: Option<String>,

View file

@ -28,18 +28,18 @@
"@koa/router": "12.0.1",
"@ladjs/koa-views": "9.0.0",
"@peertube/http-signature": "1.7.0",
"@redocly/openapi-core": "1.16.0",
"@redocly/openapi-core": "1.17.0",
"@sinonjs/fake-timers": "11.2.2",
"adm-zip": "0.5.14",
"ajv": "8.16.0",
"archiver": "7.0.1",
"async-lock": "1.4.0",
"async-mutex": "0.5.0",
"aws-sdk": "2.1651.0",
"aws-sdk": "2.1652.0",
"axios": "1.7.2",
"backend-rs": "workspace:*",
"blurhash": "2.0.5",
"bull": "4.14.0",
"bull": "4.15.0",
"cacheable-lookup": "git+https://github.com/TheEssem/cacheable-lookup.git#dd2fb616366a3c68dcf321a57a67295967b204bf",
"cbor-x": "1.5.9",
"chalk": "5.3.0",
@ -93,7 +93,7 @@
"punycode": "2.3.1",
"pureimage": "0.4.13",
"qrcode": "1.5.3",
"qs": "6.12.1",
"qs": "6.12.2",
"random-seed": "0.3.0",
"ratelimiter": "3.4.1",
"redis-semaphore": "5.6.0",
@ -172,7 +172,7 @@
"tsc-alias": "1.8.10",
"tsconfig-paths": "4.2.0",
"type-fest": "4.20.1",
"typescript": "5.5.2",
"typescript": "5.5.3",
"webpack": "5.92.1",
"ws": "8.17.1"
}

View file

@ -5,6 +5,7 @@ import type { User } from "@/models/entities/user.js";
import type { Note } from "@/models/entities/note.js";
import { Notes, DriveFiles, UserProfiles, Users } from "@/models/index.js";
import getNoteHtml from "@/remote/activitypub/misc/get-note-html.js";
import { isQuote, getNoteSummary } from "backend-rs";
/**
* If there is this part in the note, it will cause CDATA to be terminated early.
@ -17,7 +18,7 @@ export default async function (
user: User,
threadDepth = 5,
history = 20,
noteintitle = false,
noteintitle = true,
renotes = true,
replies = true,
) {
@ -81,20 +82,26 @@ export default async function (
depth -= 1;
}
let title = `${author.name} `;
if (note.renoteId) {
title += "renotes";
} else if (note.replyId) {
title += "replies";
} else {
title += "says";
}
let title = `Post by ${author.name}`;
if (noteintitle) {
const content = note.cw ?? note.text;
if (note.renoteId) {
title = `Boost by ${author.name}`;
} else if (note.replyId) {
title = `Reply by ${author.name}`;
} else {
title = `Post by ${author.name}`;
}
const effectiveNote =
!isQuote(note) && note.renote != null ? note.renote : note;
const content = getNoteSummary(
effectiveNote.fileIds,
effectiveNote.text,
effectiveNote.cw,
effectiveNote.hasPoll,
);
if (content) {
title += `: ${content}`;
} else {
title += "something";
}
}

View file

@ -79,7 +79,7 @@
"throttle-debounce": "5.0.2",
"tinycolor2": "1.6.0",
"tinyld": "1.3.4",
"typescript": "5.5.2",
"typescript": "5.5.3",
"unicode-emoji-json": "0.6.0",
"uuid": "10.0.0",
"vite": "5.3.2",
@ -88,6 +88,6 @@
"vue-draggable-plus": "0.5.0",
"vue-plyr": "7.0.0",
"vue-prism-editor": "2.0.0-alpha.2",
"vue-tsc": "2.0.22"
"vue-tsc": "2.0.24"
}
}

View file

@ -56,7 +56,7 @@ const name = "rssTicker";
const widgetPropsDef = {
url: {
type: "string" as const,
default: "http://feeds.afpbb.com/rss/afpbb/afpbbnews",
default: "https://info.firefish.dev/@firefish.rss?noteintitle",
},
shuffle: {
type: "boolean" as const,

View file

@ -46,7 +46,7 @@ const name = "rss";
const widgetPropsDef = {
url: {
type: "string" as const,
default: "http://feeds.afpbb.com/rss/afpbb/afpbbnews",
default: "https://info.firefish.dev/@firefish.rss?noteintitle",
},
height: {
type: "number" as const,

View file

@ -30,7 +30,7 @@
"ts-node": "10.9.2",
"tsc-alias": "1.8.10",
"tsd": "0.31.1",
"typescript": "5.5.2"
"typescript": "5.5.3"
},
"files": [
"built", "src"

File diff suppressed because it is too large Load diff