Compare commits
33 Commits
fb00902a32
...
2be1a22d82
Author | SHA1 | Date |
---|---|---|
Linca | 2be1a22d82 | |
naskya | 14b285f882 | |
naskya | baa5c402db | |
naskya | 5b01d3574f | |
naskya | e3a98ebc72 | |
naskya | 7fe7f90350 | |
naskya | 8ed942e00f | |
naskya | ddfdd038ad | |
naskya | 7fdd44cf8d | |
naskya | 0c4826becf | |
naskya | ecd8e3d109 | |
naskya | a3b156441a | |
naskya | ecbd8a8724 | |
naskya | 442dc33a34 | |
naskya | c8372767fa | |
naskya | 8e497b41cf | |
naskya | bfdf73caeb | |
naskya | 5b18f9761c | |
naskya | 641ff742bb | |
naskya | e6121946aa | |
naskya | c6212ff8f4 | |
naskya | d582a84c57 | |
naskya | a7978e2b08 | |
naskya | 766bac3dee | |
naskya | 7360736966 | |
naskya | e797849e9b | |
eana | ef57735e6a | |
eana | e7c33835b2 | |
Lhcfl | 46d0679845 | |
Lhcfl | 160e7f26a6 | |
Lhcfl | 9138c3726a | |
Lhcfl | 425b333474 | |
Lhcfl | d1c76b3882 |
192
.config/ci.yml
192
.config/ci.yml
|
@ -1,195 +1,11 @@
|
|||
#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# Firefish configuration
|
||||
#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
# ┌─────┐
|
||||
#───┘ URL └─────────────────────────────────────────────────────
|
||||
|
||||
# Final accessible URL seen by a user.
|
||||
url: https://example.tld/
|
||||
|
||||
# ONCE YOU HAVE STARTED THE INSTANCE, DO NOT CHANGE THE
|
||||
# URL SETTINGS AFTER THAT!
|
||||
|
||||
# ┌───────────────────────┐
|
||||
#───┘ Port and TLS settings └───────────────────────────────────
|
||||
|
||||
#
|
||||
# Misskey requires a reverse proxy to support HTTPS connections.
|
||||
#
|
||||
# +----- https://example.tld/ ------------+
|
||||
# +------+ |+-------------+ +----------------+|
|
||||
# | User | ---> || Proxy (443) | ---> | Misskey (3000) ||
|
||||
# +------+ |+-------------+ +----------------+|
|
||||
# +---------------------------------------+
|
||||
#
|
||||
# You need to set up a reverse proxy. (e.g. nginx)
|
||||
# An encrypted connection with HTTPS is highly recommended
|
||||
# because tokens may be transferred in GET requests.
|
||||
|
||||
# The port that your Misskey server should listen on.
|
||||
url: http://localhost:3000
|
||||
port: 3000
|
||||
|
||||
# ┌──────────────────────────┐
|
||||
#───┘ PostgreSQL configuration └────────────────────────────────
|
||||
|
||||
db:
|
||||
host: postgres
|
||||
port: 5432
|
||||
|
||||
# Database name
|
||||
db: postgres
|
||||
|
||||
# Auth
|
||||
user: postgres
|
||||
pass: test
|
||||
|
||||
# Whether disable Caching queries
|
||||
#disableCache: true
|
||||
|
||||
# Extra Connection options
|
||||
#extra:
|
||||
# ssl: true
|
||||
|
||||
# ┌─────────────────────┐
|
||||
#───┘ Redis configuration └─────────────────────────────────────
|
||||
|
||||
db: firefish_db
|
||||
user: firefish
|
||||
pass: password
|
||||
redis:
|
||||
host: redis
|
||||
port: 6379
|
||||
#family: 0 # 0=Both, 4=IPv4, 6=IPv6
|
||||
#pass: example-pass
|
||||
#prefix: example-prefix
|
||||
#db: 1
|
||||
|
||||
# ┌─────────────────────────────┐
|
||||
#───┘ Elasticsearch configuration └─────────────────────────────
|
||||
|
||||
#elasticsearch:
|
||||
# host: localhost
|
||||
# port: 9200
|
||||
# ssl: false
|
||||
# user:
|
||||
# pass:
|
||||
|
||||
# ┌───────────────┐
|
||||
#───┘ ID generation └───────────────────────────────────────────
|
||||
|
||||
# You can select the ID generation method.
|
||||
# You don't usually need to change this setting, but you can
|
||||
# change it according to your preferences.
|
||||
|
||||
# Available methods:
|
||||
# aid ... Short, Millisecond accuracy
|
||||
# meid ... Similar to ObjectID, Millisecond accuracy
|
||||
# ulid ... Millisecond accuracy
|
||||
# objectid ... This is left for backward compatibility
|
||||
|
||||
# ONCE YOU HAVE STARTED THE INSTANCE, DO NOT CHANGE THE
|
||||
# ID SETTINGS AFTER THAT!
|
||||
|
||||
id: 'aid'
|
||||
|
||||
# ┌─────────────────────┐
|
||||
#───┘ Other configuration └─────────────────────────────────────
|
||||
|
||||
# Max note length, should be < 8000.
|
||||
#maxNoteLength: 3000
|
||||
|
||||
# Whether disable HSTS
|
||||
#disableHsts: true
|
||||
|
||||
# Number of worker processes
|
||||
#clusterLimit: 1
|
||||
|
||||
# Job concurrency per worker
|
||||
# deliverJobConcurrency: 128
|
||||
# inboxJobConcurrency: 16
|
||||
|
||||
# Job rate limiter
|
||||
# deliverJobPerSec: 128
|
||||
# inboxJobPerSec: 16
|
||||
|
||||
# Job attempts
|
||||
# deliverJobMaxAttempts: 12
|
||||
# inboxJobMaxAttempts: 8
|
||||
|
||||
# IP address family used for outgoing request (ipv4, ipv6 or dual)
|
||||
#outgoingAddressFamily: ipv4
|
||||
|
||||
# Syslog option
|
||||
#syslog:
|
||||
# host: localhost
|
||||
# port: 514
|
||||
|
||||
# Proxy for HTTP/HTTPS
|
||||
#proxy: http://127.0.0.1:3128
|
||||
|
||||
#proxyBypassHosts: [
|
||||
# 'example.com',
|
||||
# '192.0.2.8'
|
||||
#]
|
||||
|
||||
# Proxy for SMTP/SMTPS
|
||||
#proxySmtp: http://127.0.0.1:3128 # use HTTP/1.1 CONNECT
|
||||
#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4
|
||||
#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5
|
||||
|
||||
# Media Proxy
|
||||
#mediaProxy: https://example.com/proxy
|
||||
|
||||
# Proxy remote files (default: false)
|
||||
#proxyRemoteFiles: true
|
||||
|
||||
#allowedPrivateNetworks: [
|
||||
# '127.0.0.1/32'
|
||||
#]
|
||||
|
||||
# Upload or download file size limits (bytes)
|
||||
#maxFileSize: 262144000
|
||||
|
||||
# Managed hosting settings
|
||||
# !!!!!!!!!!
|
||||
# >>>>>> NORMAL SELF-HOSTERS, STAY AWAY! <<<<<<
|
||||
# >>>>>> YOU DON'T NEED THIS! <<<<<<
|
||||
# !!!!!!!!!!
|
||||
# Each category is optional, but if each item in each category is mandatory!
|
||||
# If you mess this up, that's on you, you've been warned...
|
||||
|
||||
#maxUserSignups: 100
|
||||
#isManagedHosting: true
|
||||
#deepl:
|
||||
# managed: true
|
||||
# authKey: ''
|
||||
# isPro: false
|
||||
#
|
||||
#email:
|
||||
# managed: true
|
||||
# address: 'example@email.com'
|
||||
# host: 'email.com'
|
||||
# port: 587
|
||||
# user: 'example@email.com'
|
||||
# pass: ''
|
||||
# useImplicitSslTls: false
|
||||
#
|
||||
#objectStorage:
|
||||
# managed: true
|
||||
# baseUrl: ''
|
||||
# bucket: ''
|
||||
# prefix: ''
|
||||
# endpoint: ''
|
||||
# region: ''
|
||||
# accessKey: ''
|
||||
# secretKey: ''
|
||||
# useSsl: true
|
||||
# connnectOverProxy: false
|
||||
# setPublicReadOnUpload: true
|
||||
# s3ForcePathStyle: true
|
||||
|
||||
# !!!!!!!!!!
|
||||
# >>>>>> AGAIN, NORMAL SELF-HOSTERS, STAY AWAY! <<<<<<
|
||||
# >>>>>> YOU DON'T NEED THIS, ABOVE SETTINGS ARE FOR MANAGED HOSTING ONLY! <<<<<<
|
||||
# !!!!!!!!!!
|
||||
|
||||
# Seriously. Do NOT fill out the above settings if you're self-hosting.
|
||||
# They're much better off being set from the control panel.
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
image: docker.io/rust:slim-bookworm
|
||||
|
||||
services:
|
||||
- name: docker.io/groonga/pgroonga:latest-alpine-12-slim
|
||||
alias: postgres
|
||||
- name: docker.io/redis:7-alpine
|
||||
alias: redis
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
||||
when: always
|
||||
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'main'
|
||||
when: never
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- node_modules
|
||||
# - /usr/local/cargo/registry/index
|
||||
# - /usr/local/cargo/registry/cache
|
||||
- target/debug/deps
|
||||
- target/debug/build
|
||||
|
||||
stages:
|
||||
- test
|
||||
|
||||
variables:
|
||||
POSTGRES_DB: 'firefish_db'
|
||||
POSTGRES_USER: 'firefish'
|
||||
POSTGRES_PASSWORD: 'password'
|
||||
POSTGRES_HOST_AUTH_METHOD: 'trust'
|
||||
DEBIAN_FRONTEND: 'noninteractive'
|
||||
CARGO_PROFILE_DEV_OPT_LEVEL: '0'
|
||||
CARGO_PROFILE_DEV_LTO: 'off'
|
||||
CARGO_PROFILE_DEV_DEBUG: 'none'
|
||||
|
||||
default:
|
||||
before_script:
|
||||
- mkdir -p "${CARGO_HOME}"
|
||||
- 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 clang mold python3 perl nodejs postgresql-client
|
||||
- corepack enable
|
||||
- corepack prepare pnpm@latest --activate
|
||||
- cp .config/ci.yml .config/default.yml
|
||||
- cp ci/cargo/config.toml /usr/local/cargo/config.toml
|
||||
- export PGPASSWORD="${POSTGRES_PASSWORD}"
|
||||
- psql --host postgres --user "${POSTGRES_USER}" --dbname "${POSTGRES_DB}" --command 'CREATE EXTENSION pgroonga'
|
||||
|
||||
build_and_cargo_unit_test:
|
||||
stage: test
|
||||
script:
|
||||
- pnpm install --frozen-lockfile
|
||||
- pnpm run build:debug
|
||||
- pnpm run migrate
|
||||
- cargo test
|
|
@ -0,0 +1,3 @@
|
|||
[target.x86_64-unknown-linux-gnu]
|
||||
linker = "/usr/bin/clang"
|
||||
rustflags = ["-C", "link-arg=--ld-path=/usr/bin/mold"]
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
Breaking changes are indicated by the :warning: icon.
|
||||
|
||||
- Adding `lang` to the response of `i` and the request parameter of `i/update`.
|
||||
|
||||
## v20240504
|
||||
|
||||
- :warning: Removed `release` endpoint.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
BEGIN;
|
||||
|
||||
DELETE FROM "migrations" WHERE name IN (
|
||||
'AddUserProfileLanguage1714888400293',
|
||||
'DropUnusedIndexes1714643926317',
|
||||
'AlterAkaType1714099399879',
|
||||
'AddDriveFileUsage1713451569342',
|
||||
|
@ -764,9 +765,6 @@ CREATE SEQUENCE public.__chart_day__users_id_seq
|
|||
CACHE 1;
|
||||
ALTER SEQUENCE public.__chart_day__users_id_seq OWNED BY public.__chart_day__users.id;
|
||||
|
||||
-- drop-user-profile-language
|
||||
ALTER TABLE "user_profile" ADD COLUMN "lang" character varying(32);
|
||||
|
||||
-- emoji-moderator
|
||||
ALTER TABLE "user" DROP COLUMN "emojiModPerm";
|
||||
DROP TYPE "public"."user_emojimodperm_enum";
|
||||
|
|
|
@ -766,6 +766,9 @@ confirmToUnclipAlreadyClippedNote: "This post is already part of the \"{name}\"
|
|||
public: "Public"
|
||||
i18nInfo: "Firefish is being translated into various languages by volunteers. You
|
||||
can help at {link}."
|
||||
i18nServerInfo: "New clients will be in {language} by default."
|
||||
i18nServerChange: "Use {language} instead."
|
||||
i18nServerSet: "Use {language} for new clients."
|
||||
manageAccessTokens: "Manage access tokens"
|
||||
accountInfo: "Account Info"
|
||||
notesCount: "Number of posts"
|
||||
|
@ -2241,3 +2244,5 @@ incorrectLanguageWarning: "It looks like your post is in {detected}, but you sel
|
|||
noteEditHistory: "Post edit history"
|
||||
slashQuote: "Chain quote"
|
||||
foldNotification: "Group similar notifications"
|
||||
mergeThreadInTimeline: "Merge posts in timeline into threads if possible"
|
||||
mergeRenotesInTimeline: "Merge boosts"
|
||||
|
|
|
@ -685,6 +685,9 @@ unclip: "クリップ解除"
|
|||
confirmToUnclipAlreadyClippedNote: "この投稿はすでにクリップ「{name}」に含まれています。投稿をこのクリップから除外しますか?"
|
||||
public: "公開"
|
||||
i18nInfo: "Firefishは有志によって様々な言語に翻訳されています。{link}で翻訳に協力できます。"
|
||||
i18nServerInfo: "新しい端末では{language}が既定の言語になります。"
|
||||
i18nServerChange: "{language}に変更する。"
|
||||
i18nServerSet: "新しい端末での表示言語を{language}にします。"
|
||||
manageAccessTokens: "アクセストークンの管理"
|
||||
accountInfo: "アカウント情報"
|
||||
notesCount: "投稿の数"
|
||||
|
|
|
@ -667,6 +667,9 @@ unclip: "移除便签"
|
|||
confirmToUnclipAlreadyClippedNote: "本帖已包含在便签 \"{name}\" 里。您想要将本帖从该便签中移除吗?"
|
||||
public: "公开"
|
||||
i18nInfo: "Firefish 已经被志愿者们翻译成了各种语言。如果您也有兴趣,可以通过 {link} 帮助翻译。"
|
||||
i18nServerInfo: "新客户端将默认使用 {language}。"
|
||||
i18nServerChange: "改为 {language}。"
|
||||
i18nServerSet: "设定新客户端使用 {language}。"
|
||||
manageAccessTokens: "管理访问令牌"
|
||||
accountInfo: "账号信息"
|
||||
notesCount: "帖子数量"
|
||||
|
@ -2068,3 +2071,5 @@ noteEditHistory: "帖子编辑历史"
|
|||
media: 媒体
|
||||
slashQuote: "斜杠引用"
|
||||
foldNotification: "将通知按同类型分组"
|
||||
mergeThreadInTimeline: "将时间线内的连续回复合并成一串"
|
||||
mergeRenotesInTimeline: "合并转发"
|
||||
|
|
|
@ -661,6 +661,9 @@ unclip: "解除摘錄"
|
|||
confirmToUnclipAlreadyClippedNote: "此貼文已包含在摘錄「{name}」中。 你想將貼文從這個摘錄中排除嗎?"
|
||||
public: "公開"
|
||||
i18nInfo: "Firefish已經被志願者們翻譯成各種語言版本,如果想要幫忙的話,可以進入{link}幫助翻譯。"
|
||||
i18nServerInfo: "新客戶端將默認使用 {language}。"
|
||||
i18nServerChange: "改為 {language}。"
|
||||
i18nServerSet: "設定新客戶端使用 {language}。"
|
||||
manageAccessTokens: "管理存取權杖"
|
||||
accountInfo: "帳戶資訊"
|
||||
notesCount: "貼文數量"
|
||||
|
|
|
@ -268,6 +268,7 @@ export interface NoteLikeForGetNoteSummary {
|
|||
hasPoll: boolean
|
||||
}
|
||||
export function getNoteSummary(note: NoteLikeForGetNoteSummary): string
|
||||
export function isSafeUrl(url: string): boolean
|
||||
export function latestVersion(): Promise<string>
|
||||
export function toMastodonId(firefishId: string): string | null
|
||||
export function fromMastodonId(mastodonId: string): string | null
|
||||
|
@ -1129,6 +1130,7 @@ export interface UserProfile {
|
|||
preventAiLearning: boolean
|
||||
isIndexable: boolean
|
||||
mutedPatterns: Array<string>
|
||||
lang: string | null
|
||||
}
|
||||
export interface UserPublickey {
|
||||
userId: string
|
||||
|
|
|
@ -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, 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
|
||||
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
|
||||
|
@ -339,6 +339,7 @@ module.exports.safeForSql = safeForSql
|
|||
module.exports.formatMilliseconds = formatMilliseconds
|
||||
module.exports.getImageSizeFromUrl = getImageSizeFromUrl
|
||||
module.exports.getNoteSummary = getNoteSummary
|
||||
module.exports.isSafeUrl = isSafeUrl
|
||||
module.exports.latestVersion = latestVersion
|
||||
module.exports.toMastodonId = toMastodonId
|
||||
module.exports.fromMastodonId = fromMastodonId
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
#[crate::export]
|
||||
pub fn is_safe_url(url: &str) -> bool {
|
||||
if let Ok(url) = url.parse::<url::Url>() {
|
||||
if url.host_str().unwrap_or_default() == "unix"
|
||||
|| !["http", "https"].contains(&url.scheme())
|
||||
|| ![None, Some(80), Some(443)].contains(&url.port())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod unit_test {
|
||||
use super::is_safe_url;
|
||||
|
||||
#[test]
|
||||
fn safe_url() {
|
||||
assert!(is_safe_url("http://firefish.dev/firefish/firefish"));
|
||||
assert!(is_safe_url("https://firefish.dev/firefish/firefish"));
|
||||
assert!(is_safe_url("http://firefish.dev:80/firefish/firefish"));
|
||||
assert!(is_safe_url("https://firefish.dev:80/firefish/firefish"));
|
||||
assert!(is_safe_url("http://firefish.dev:443/firefish/firefish"));
|
||||
assert!(is_safe_url("https://firefish.dev:443/firefish/firefish"));
|
||||
assert!(!is_safe_url("https://unix/firefish/firefish"));
|
||||
assert!(!is_safe_url("https://firefish.dev:35/firefish/firefish"));
|
||||
assert!(!is_safe_url("ftp://firefish.dev/firefish/firefish"));
|
||||
assert!(!is_safe_url("nyaa"));
|
||||
assert!(!is_safe_url(""));
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ pub mod escape_sql;
|
|||
pub mod format_milliseconds;
|
||||
pub mod get_image_size;
|
||||
pub mod get_note_summary;
|
||||
pub mod is_safe_url;
|
||||
pub mod latest_version;
|
||||
pub mod mastodon_id;
|
||||
pub mod meta;
|
||||
|
|
|
@ -78,6 +78,7 @@ pub struct Model {
|
|||
pub is_indexable: bool,
|
||||
#[sea_orm(column_name = "mutedPatterns")]
|
||||
pub muted_patterns: Vec<String>,
|
||||
pub lang: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import type { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddUserProfileLanguage1714888400293 implements MigrationInterface {
|
||||
async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "user_profile" ADD COLUMN "lang" character varying(32)`,
|
||||
);
|
||||
}
|
||||
|
||||
async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "lang"`);
|
||||
}
|
||||
}
|
|
@ -7,10 +7,10 @@ import chalk from "chalk";
|
|||
import Logger from "@/services/logger.js";
|
||||
import IPCIDR from "ip-cidr";
|
||||
import PrivateIp from "private-ip";
|
||||
import { isValidUrl } from "./is-valid-url.js";
|
||||
import { isSafeUrl } from "backend-rs";
|
||||
|
||||
export async function downloadUrl(url: string, path: string): Promise<void> {
|
||||
if (!isValidUrl(url)) {
|
||||
if (!isSafeUrl(url)) {
|
||||
throw new StatusError("Invalid URL", 400);
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,8 @@ export async function downloadUrl(url: string, path: string): Promise<void> {
|
|||
limit: 0,
|
||||
},
|
||||
})
|
||||
.on("redirect", (res: Got.Response, opts: Got.NormalizedOptions) => {
|
||||
if (!isValidUrl(opts.url)) {
|
||||
.on("redirect", (_res: Got.Response, opts: Got.NormalizedOptions) => {
|
||||
if (!isSafeUrl(opts.url)) {
|
||||
downloadLogger.warn(`Invalid URL: ${opts.url}`);
|
||||
req.destroy();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import CacheableLookup from "cacheable-lookup";
|
|||
import fetch, { type RequestRedirect } from "node-fetch";
|
||||
import { HttpProxyAgent, HttpsProxyAgent } from "hpagent";
|
||||
import { config } from "@/config.js";
|
||||
import { isValidUrl } from "./is-valid-url.js";
|
||||
import { isSafeUrl } from "backend-rs";
|
||||
|
||||
export async function getJson(
|
||||
url: string,
|
||||
|
@ -60,7 +60,7 @@ export async function getResponse(args: {
|
|||
size?: number;
|
||||
redirect?: RequestRedirect;
|
||||
}) {
|
||||
if (!isValidUrl(args.url)) {
|
||||
if (!isSafeUrl(args.url)) {
|
||||
throw new StatusError("Invalid URL", 400);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ export async function getResponse(args: {
|
|||
});
|
||||
|
||||
if (args.redirect === "manual" && [301, 302, 307, 308].includes(res.status)) {
|
||||
if (!isValidUrl(res.url)) {
|
||||
if (!isSafeUrl(res.url)) {
|
||||
throw new StatusError("Invalid URL", 400);
|
||||
}
|
||||
return res;
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
export function isValidUrl(url: string | URL | undefined): boolean {
|
||||
if (process.env.NODE_ENV !== "production") return true;
|
||||
|
||||
try {
|
||||
if (url == null) return false;
|
||||
|
||||
const u = typeof url === "string" ? new URL(url) : url;
|
||||
if (!u.protocol.match(/^https?:$/) || u.hostname === "unix") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (u.port !== "" && !["80", "443"].includes(u.port)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -50,6 +50,12 @@ export class UserProfile {
|
|||
verified?: boolean;
|
||||
}[];
|
||||
|
||||
@Column("varchar", {
|
||||
length: 32,
|
||||
nullable: true,
|
||||
})
|
||||
public lang: string | null;
|
||||
|
||||
@Column("varchar", {
|
||||
length: 512,
|
||||
nullable: true,
|
||||
|
|
|
@ -512,6 +512,7 @@ export const UserRepository = db.getRepository(User).extend({
|
|||
description: profile!.description,
|
||||
location: profile!.location,
|
||||
birthday: profile!.birthday,
|
||||
lang: profile!.lang,
|
||||
fields: profile!.fields,
|
||||
followersCount: followersCount ?? null,
|
||||
followingCount: followingCount ?? null,
|
||||
|
|
|
@ -204,6 +204,12 @@ export const packedUserDetailedNotMeOnlySchema = {
|
|||
optional: false,
|
||||
example: "2018-03-12",
|
||||
},
|
||||
lang: {
|
||||
type: "string",
|
||||
nullable: true,
|
||||
optional: false,
|
||||
example: "ja-JP",
|
||||
},
|
||||
fields: {
|
||||
type: "array",
|
||||
nullable: false,
|
||||
|
|
|
@ -5,8 +5,8 @@ import { StatusError, getResponse } from "@/misc/fetch.js";
|
|||
import { createSignedPost, createSignedGet } from "./ap-request.js";
|
||||
import type { Response } from "node-fetch";
|
||||
import type { IObject } from "./type.js";
|
||||
import { isValidUrl } from "@/misc/is-valid-url.js";
|
||||
import { apLogger } from "@/remote/activitypub/logger.js";
|
||||
import { isSafeUrl } from "backend-rs";
|
||||
|
||||
export default async (user: { id: User["id"] }, url: string, object: any) => {
|
||||
const body = JSON.stringify(object);
|
||||
|
@ -44,7 +44,7 @@ export async function apGet(
|
|||
user?: ILocalUser,
|
||||
redirects: boolean = true,
|
||||
): Promise<{ finalUrl: string; content: IObject }> {
|
||||
if (!isValidUrl(url)) {
|
||||
if (!isSafeUrl(url)) {
|
||||
throw new StatusError("Invalid URL", 400);
|
||||
}
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ export const paramDef = {
|
|||
description: { ...Users.descriptionSchema, nullable: true },
|
||||
location: { ...Users.locationSchema, nullable: true },
|
||||
birthday: { ...Users.birthdaySchema, nullable: true },
|
||||
lang: { type: "string", nullable: true },
|
||||
avatarId: { type: "string", format: "misskey:id", nullable: true },
|
||||
bannerId: { type: "string", format: "misskey:id", nullable: true },
|
||||
fields: {
|
||||
|
@ -154,6 +155,7 @@ export default define(meta, paramDef, async (ps, _user, token) => {
|
|||
|
||||
if (ps.name !== undefined) updates.name = ps.name;
|
||||
if (ps.description !== undefined) profileUpdates.description = ps.description;
|
||||
if (typeof ps.lang === "string") profileUpdates.lang = ps.lang;
|
||||
if (ps.location !== undefined) profileUpdates.location = ps.location;
|
||||
if (ps.birthday !== undefined) profileUpdates.birthday = ps.birthday;
|
||||
if (ps.ffVisibility !== undefined)
|
||||
|
|
|
@ -132,6 +132,9 @@ export async function signIn(token: Account["token"], redirect?: string) {
|
|||
if (_DEV_) console.log("logging as token ", token);
|
||||
const newAccount = await fetchAccount(token);
|
||||
localStorage.setItem("account", JSON.stringify(newAccount));
|
||||
if (newAccount.lang) {
|
||||
localStorage.setItem("lang", newAccount.lang);
|
||||
}
|
||||
document.cookie = `token=${token}; path=/; max-age=31536000`; // bull dashboardの認証とかで使う
|
||||
await addAccount(newAccount.id, token);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div
|
||||
v-if="!muted.muted"
|
||||
v-show="!isDeleted"
|
||||
v-show="!isDeleted && renotes?.length !== 0"
|
||||
:id="appearNote.historyId || appearNote.id"
|
||||
ref="el"
|
||||
v-hotkey="keymap"
|
||||
|
@ -10,13 +10,20 @@
|
|||
:aria-label="accessibleLabel"
|
||||
class="tkcbzcuz note-container"
|
||||
:tabindex="!isDeleted ? '-1' : undefined"
|
||||
:class="{ renote: isRenote }"
|
||||
:class="{ renote: isRenote || (renotesSliced && renotesSliced.length > 0) }"
|
||||
>
|
||||
<MkNoteSub
|
||||
v-if="appearNote.reply && !detailedView && !collapsedReply"
|
||||
v-if="appearNote.reply && !detailedView && !collapsedReply && !parents"
|
||||
:note="appearNote.reply"
|
||||
class="reply-to"
|
||||
/>
|
||||
<MkNoteSub
|
||||
v-else-if="!detailedView && !collapsedReply && parents"
|
||||
v-for="n of parents"
|
||||
:key="n.id"
|
||||
:note="n"
|
||||
class="reply-to"
|
||||
/>
|
||||
<div
|
||||
v-if="!detailedView"
|
||||
class="note-context"
|
||||
|
@ -41,35 +48,6 @@
|
|||
<div v-if="pinned" class="info">
|
||||
<i :class="icon('ph-push-pin')"></i>{{ i18n.ts.pinnedNote }}
|
||||
</div>
|
||||
<div v-if="isRenote" class="renote">
|
||||
<i :class="icon('ph-rocket-launch')"></i>
|
||||
<I18n :src="i18n.ts.renotedBy" tag="span">
|
||||
<template #user>
|
||||
<MkA
|
||||
v-user-preview="note.userId"
|
||||
class="name"
|
||||
:to="userPage(note.user)"
|
||||
@click.stop
|
||||
>
|
||||
<MkUserName :user="note.user" />
|
||||
</MkA>
|
||||
</template>
|
||||
</I18n>
|
||||
<div class="info">
|
||||
<button
|
||||
ref="renoteTime"
|
||||
class="_button time"
|
||||
@click.stop="showRenoteMenu()"
|
||||
>
|
||||
<i
|
||||
v-if="isMyRenote"
|
||||
:class="icon('ph-dots-three-outline dropdownIcon')"
|
||||
></i>
|
||||
<MkTime :time="note.createdAt" />
|
||||
</button>
|
||||
<MkVisibility :note="note" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="collapsedReply && appearNote.reply" class="info">
|
||||
<MkAvatar class="avatar" :user="appearNote.reply.user" />
|
||||
<MkUserName
|
||||
|
@ -85,6 +63,71 @@
|
|||
:custom-emojis="note.emojis"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="isRenote || (renotesSliced && renotesSliced.length > 0)" class="renote">
|
||||
<i :class="icon('ph-rocket-launch')"></i>
|
||||
<I18n
|
||||
v-if="renotesSliced == null"
|
||||
:src="i18n.ts.renotedBy"
|
||||
tag="span"
|
||||
>
|
||||
<template #user>
|
||||
<MkAvatar class="avatar" :user="note.user" />
|
||||
<MkA
|
||||
v-user-preview="note.userId"
|
||||
class="name"
|
||||
:to="userPage(note.user)"
|
||||
@click.stop
|
||||
>
|
||||
<MkUserName :user="note.user" />
|
||||
</MkA>
|
||||
</template>
|
||||
</I18n>
|
||||
<I18n
|
||||
v-else
|
||||
:src="i18n.ts.renotedBy"
|
||||
tag="span"
|
||||
>
|
||||
<template #user>
|
||||
<template
|
||||
v-for="(renote, index) in renotesSliced"
|
||||
>
|
||||
<MkAvatar
|
||||
class="avatar"
|
||||
:user="renote.user"
|
||||
/>
|
||||
<MkA
|
||||
v-user-preview="renote.userId"
|
||||
class="name"
|
||||
:to="userPage(renote.user)"
|
||||
@click.stop
|
||||
>
|
||||
<MkUserName :user="renote.user" />
|
||||
</MkA>
|
||||
{{
|
||||
index !== renotesSliced.length - 1
|
||||
? ", "
|
||||
: renotesSliced.length < renotes!.length
|
||||
? "..."
|
||||
: ""
|
||||
}}
|
||||
</template>
|
||||
</template>
|
||||
</I18n>
|
||||
<div class="info">
|
||||
<button
|
||||
ref="renoteTime"
|
||||
class="_button time"
|
||||
@click.stop="showRenoteMenu()"
|
||||
>
|
||||
<i
|
||||
v-if="isMyNote"
|
||||
:class="icon('ph-dots-three-outline dropdownIcon')"
|
||||
></i>
|
||||
<MkTime :time="note.createdAt" />
|
||||
</button>
|
||||
<MkVisibility :note="note" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<article
|
||||
class="article"
|
||||
|
@ -279,7 +322,7 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, inject, onMounted, ref } from "vue";
|
||||
import { computed, inject, onMounted, ref, watch } from "vue";
|
||||
import type { Ref } from "vue";
|
||||
import type { entities } from "firefish-js";
|
||||
import MkSubNoteContent from "./MkSubNoteContent.vue";
|
||||
|
@ -310,17 +353,13 @@ import { notePage } from "@/filters/note";
|
|||
import { deepClone } from "@/scripts/clone";
|
||||
import { getNoteSummary } from "@/scripts/get-note-summary";
|
||||
import icon from "@/scripts/icon";
|
||||
import type { NoteTranslation } from "@/types/note";
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
type NoteType = entities.Note & {
|
||||
_featuredId_?: string;
|
||||
_prId_?: string;
|
||||
};
|
||||
import type { NoteTranslation, NoteType } from "@/types/note";
|
||||
import { isRenote as _isRenote, isDeleted as _isDeleted } from "@/scripts/note";
|
||||
|
||||
const props = defineProps<{
|
||||
note: NoteType;
|
||||
parents?: NoteType[];
|
||||
renotes?: entities.Note[];
|
||||
pinned?: boolean;
|
||||
detailedView?: boolean;
|
||||
collapsedReply?: boolean;
|
||||
|
@ -329,37 +368,20 @@ const props = defineProps<{
|
|||
isLongJudger?: (note: entities.Note) => boolean;
|
||||
}>();
|
||||
|
||||
//#region Constants
|
||||
const router = useRouter();
|
||||
const inChannel = inject("inChannel", null);
|
||||
|
||||
const note = ref(deepClone(props.note));
|
||||
|
||||
const softMuteReasonI18nSrc = (what?: string) => {
|
||||
if (what === "note") return i18n.ts.userSaysSomethingReason;
|
||||
if (what === "reply") return i18n.ts.userSaysSomethingReasonReply;
|
||||
if (what === "renote") return i18n.ts.userSaysSomethingReasonRenote;
|
||||
if (what === "quote") return i18n.ts.userSaysSomethingReasonQuote;
|
||||
|
||||
// I don't think here is reachable, but just in case
|
||||
return i18n.ts.userSaysSomething;
|
||||
const keymap = {
|
||||
r: () => reply(true),
|
||||
"e|a|plus": () => react(true),
|
||||
q: () => renoteButton.value!.renote(true),
|
||||
"up|k": focusBefore,
|
||||
"down|j": focusAfter,
|
||||
esc: blur,
|
||||
"m|o": () => menu(true),
|
||||
// FIXME: What's this?
|
||||
// s: () => showContent.value !== showContent.value,
|
||||
};
|
||||
|
||||
// plugin
|
||||
if (noteViewInterruptors.length > 0) {
|
||||
onMounted(async () => {
|
||||
let result = deepClone(note.value);
|
||||
for (const interruptor of noteViewInterruptors) {
|
||||
result = await interruptor.handler(result);
|
||||
}
|
||||
note.value = result;
|
||||
});
|
||||
}
|
||||
|
||||
const isRenote =
|
||||
note.value.renote != null &&
|
||||
note.value.text == null &&
|
||||
note.value.fileIds.length === 0 &&
|
||||
note.value.poll == null;
|
||||
|
||||
const el = ref<HTMLElement | null>(null);
|
||||
const footerEl = ref<HTMLElement>();
|
||||
const menuButton = ref<HTMLElement>();
|
||||
|
@ -367,42 +389,179 @@ const starButton = ref<InstanceType<typeof XStarButton>>();
|
|||
const renoteButton = ref<InstanceType<typeof XRenoteButton> | null>(null);
|
||||
const renoteTime = ref<HTMLElement>();
|
||||
const reactButton = ref<HTMLElement | null>(null);
|
||||
const appearNote = computed(() =>
|
||||
isRenote ? (note.value.renote as NoteType) : note.value,
|
||||
);
|
||||
const isMyRenote = isSignedIn(me) && me.id === note.value.userId;
|
||||
// const showContent = ref(false);
|
||||
const isDeleted = ref(false);
|
||||
const muted = ref(
|
||||
getWordSoftMute(
|
||||
note.value,
|
||||
me?.id,
|
||||
defaultStore.state.mutedWords,
|
||||
defaultStore.state.mutedLangs,
|
||||
),
|
||||
);
|
||||
const translation = ref<NoteTranslation | null>(null);
|
||||
const translating = ref(false);
|
||||
const enableEmojiReactions = defaultStore.state.enableEmojiReactions;
|
||||
const expandOnNoteClick = defaultStore.state.expandOnNoteClick;
|
||||
const enableEmojiReactions = defaultStore.reactiveState.enableEmojiReactions;
|
||||
const expandOnNoteClick = defaultStore.reactiveState.expandOnNoteClick;
|
||||
const lang = localStorage.getItem("lang");
|
||||
const translateLang = localStorage.getItem("translateLang");
|
||||
const targetLang = (translateLang || lang || navigator.language)?.slice(0, 2);
|
||||
const currentClipPage = inject<Ref<entities.Clip> | null>(
|
||||
"currentClipPage",
|
||||
null,
|
||||
);
|
||||
//#endregion
|
||||
|
||||
const isForeignLanguage: boolean =
|
||||
defaultStore.state.detectPostLanguage &&
|
||||
appearNote.value.text != null &&
|
||||
(() => {
|
||||
const postLang = detectLanguage(appearNote.value.text);
|
||||
return postLang !== "" && postLang !== targetLang;
|
||||
})();
|
||||
//#region Variables bound to Notes
|
||||
let capture: ReturnType<typeof useNoteCapture> | undefined;
|
||||
const note = ref(deepClone(props.note));
|
||||
const postIsExpanded = ref(false);
|
||||
const translation = ref<NoteTranslation | null>(null);
|
||||
const translating = ref(false);
|
||||
const isDeleted = ref(false);
|
||||
const renotes = ref(props.renotes?.filter((rn) => !_isDeleted(rn.id)));
|
||||
//#endregion
|
||||
|
||||
//#region computed
|
||||
|
||||
const renotesSliced = computed(() => renotes.value?.slice(0, 5));
|
||||
|
||||
const isRenote = computed(() => _isRenote(note.value));
|
||||
const appearNote = computed(() =>
|
||||
isRenote.value ? (note.value.renote as NoteType) : note.value,
|
||||
);
|
||||
const isMyNote = computed(
|
||||
() => isSignedIn(me) && me.id === note.value.userId && props.renotes == null,
|
||||
);
|
||||
const muted = computed(() =>
|
||||
getWordSoftMute(
|
||||
note.value,
|
||||
me?.id,
|
||||
defaultStore.reactiveState.mutedWords.value,
|
||||
defaultStore.reactiveState.mutedLangs.value,
|
||||
),
|
||||
);
|
||||
const isForeignLanguage = computed(
|
||||
() =>
|
||||
defaultStore.state.detectPostLanguage &&
|
||||
appearNote.value.text != null &&
|
||||
(() => {
|
||||
const postLang = detectLanguage(appearNote.value.text);
|
||||
return postLang !== "" && postLang !== targetLang;
|
||||
})(),
|
||||
);
|
||||
const reactionCount = computed(() =>
|
||||
Object.values(appearNote.value.reactions).reduce(
|
||||
(partialSum, val) => partialSum + val,
|
||||
0,
|
||||
),
|
||||
);
|
||||
const accessibleLabel = computed(() => {
|
||||
let label = `${appearNote.value.user.username}; `;
|
||||
if (appearNote.value.renote) {
|
||||
label += `${i18n.ts.renoted} ${appearNote.value.renote.user.username}; `;
|
||||
if (appearNote.value.renote.cw) {
|
||||
label += `${i18n.ts.cw}: ${appearNote.value.renote.cw}; `;
|
||||
if (postIsExpanded.value) {
|
||||
label += `${appearNote.value.renote.text}; `;
|
||||
}
|
||||
} else {
|
||||
label += `${appearNote.value.renote.text}; `;
|
||||
}
|
||||
} else {
|
||||
if (appearNote.value.cw) {
|
||||
label += `${i18n.ts.cw}: ${appearNote.value.cw}; `;
|
||||
if (postIsExpanded.value) {
|
||||
label += `${appearNote.value.text}; `;
|
||||
}
|
||||
} else {
|
||||
label += `${appearNote.value.text}; `;
|
||||
}
|
||||
}
|
||||
const date = new Date(appearNote.value.createdAt);
|
||||
label += `${date.toLocaleTimeString()}`;
|
||||
return label;
|
||||
});
|
||||
//#endregion
|
||||
|
||||
async function pluginInit(newNote: NoteType) {
|
||||
// plugin
|
||||
if (noteViewInterruptors.length > 0) {
|
||||
let result = deepClone(newNote);
|
||||
for (const interruptor of noteViewInterruptors) {
|
||||
result = await interruptor.handler(result);
|
||||
}
|
||||
note.value = result;
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateRenotes() {
|
||||
renotes.value = props.renotes?.filter((rn) => !_isDeleted(rn.id));
|
||||
}
|
||||
|
||||
async function init(newNote: NoteType, first = false) {
|
||||
if (!first) {
|
||||
// plugin
|
||||
if (noteViewInterruptors.length > 0) {
|
||||
await pluginInit(newNote);
|
||||
} else {
|
||||
note.value = deepClone(newNote);
|
||||
}
|
||||
}
|
||||
|
||||
translation.value = null;
|
||||
translating.value = false;
|
||||
postIsExpanded.value = false;
|
||||
isDeleted.value = _isDeleted(note.value.id);
|
||||
if (appearNote.value.historyId == null) {
|
||||
capture?.close();
|
||||
capture = useNoteCapture({
|
||||
rootEl: el,
|
||||
note: appearNote,
|
||||
isDeletedRef: isDeleted,
|
||||
});
|
||||
if (isRenote.value === true) {
|
||||
useNoteCapture({
|
||||
rootEl: el,
|
||||
note,
|
||||
isDeletedRef: isDeleted,
|
||||
});
|
||||
}
|
||||
if (props.renotes) {
|
||||
const renoteDeletedTrigger = ref(false);
|
||||
for (const renote of props.renotes) {
|
||||
useNoteCapture({
|
||||
rootEl: el,
|
||||
note: ref(renote),
|
||||
isDeletedRef: renoteDeletedTrigger,
|
||||
});
|
||||
}
|
||||
watch(renoteDeletedTrigger, recalculateRenotes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(props.note, true);
|
||||
|
||||
onMounted(() => {
|
||||
pluginInit(note.value);
|
||||
});
|
||||
|
||||
watch(isDeleted, () => {
|
||||
if (isDeleted.value === true) {
|
||||
if (props.parents && props.parents.length > 0) {
|
||||
let noteTakePlace: NoteType | null = null;
|
||||
while (noteTakePlace == null || _isDeleted(noteTakePlace.id)) {
|
||||
if (props.parents.length === 0) {
|
||||
return;
|
||||
}
|
||||
noteTakePlace = props.parents[props.parents.length - 1];
|
||||
props.parents.pop();
|
||||
}
|
||||
noteTakePlace.repliesCount -= 1;
|
||||
init(noteTakePlace);
|
||||
isDeleted.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.note.id,
|
||||
(o, n) => {
|
||||
if (o !== n && _isDeleted(note.value.id) !== true) {
|
||||
init(props.note);
|
||||
}
|
||||
},
|
||||
);
|
||||
watch(() => props.renotes?.length, recalculateRenotes);
|
||||
|
||||
async function translate_(noteId: string, targetLang: string) {
|
||||
return await os.api("notes/translate", {
|
||||
|
@ -431,24 +590,14 @@ async function translate() {
|
|||
translating.value = false;
|
||||
}
|
||||
|
||||
const keymap = {
|
||||
r: () => reply(true),
|
||||
"e|a|plus": () => react(true),
|
||||
q: () => renoteButton.value!.renote(true),
|
||||
"up|k": focusBefore,
|
||||
"down|j": focusAfter,
|
||||
esc: blur,
|
||||
"m|o": () => menu(true),
|
||||
// FIXME: What's this?
|
||||
// s: () => showContent.value !== showContent.value,
|
||||
};
|
||||
function softMuteReasonI18nSrc(what?: string) {
|
||||
if (what === "note") return i18n.ts.userSaysSomethingReason;
|
||||
if (what === "reply") return i18n.ts.userSaysSomethingReasonReply;
|
||||
if (what === "renote") return i18n.ts.userSaysSomethingReasonRenote;
|
||||
if (what === "quote") return i18n.ts.userSaysSomethingReasonQuote;
|
||||
|
||||
if (appearNote.value.historyId == null) {
|
||||
useNoteCapture({
|
||||
rootEl: el,
|
||||
note: appearNote,
|
||||
isDeletedRef: isDeleted,
|
||||
});
|
||||
// I don't think here is reachable, but just in case
|
||||
return i18n.ts.userSaysSomething;
|
||||
}
|
||||
|
||||
function reply(_viaKeyboard = false): void {
|
||||
|
@ -489,11 +638,6 @@ function undoReact(note: NoteType): void {
|
|||
});
|
||||
}
|
||||
|
||||
const currentClipPage = inject<Ref<entities.Clip> | null>(
|
||||
"currentClipPage",
|
||||
null,
|
||||
);
|
||||
|
||||
function onContextmenu(ev: MouseEvent): void {
|
||||
const isLink = (el: HTMLElement): boolean => {
|
||||
if (el.tagName === "A") return true;
|
||||
|
@ -582,7 +726,7 @@ function menu(viaKeyboard = false): void {
|
|||
}
|
||||
|
||||
function showRenoteMenu(viaKeyboard = false): void {
|
||||
if (!isMyRenote) return;
|
||||
if (!isMyNote.value) return;
|
||||
os.popupMenu(
|
||||
[
|
||||
{
|
||||
|
@ -643,39 +787,10 @@ function readPromo() {
|
|||
isDeleted.value = true;
|
||||
}
|
||||
|
||||
const postIsExpanded = ref(false);
|
||||
|
||||
function setPostExpanded(val: boolean) {
|
||||
postIsExpanded.value = val;
|
||||
}
|
||||
|
||||
const accessibleLabel = computed(() => {
|
||||
let label = `${appearNote.value.user.username}; `;
|
||||
if (appearNote.value.renote) {
|
||||
label += `${i18n.ts.renoted} ${appearNote.value.renote.user.username}; `;
|
||||
if (appearNote.value.renote.cw) {
|
||||
label += `${i18n.ts.cw}: ${appearNote.value.renote.cw}; `;
|
||||
if (postIsExpanded.value) {
|
||||
label += `${appearNote.value.renote.text}; `;
|
||||
}
|
||||
} else {
|
||||
label += `${appearNote.value.renote.text}; `;
|
||||
}
|
||||
} else {
|
||||
if (appearNote.value.cw) {
|
||||
label += `${i18n.ts.cw}: ${appearNote.value.cw}; `;
|
||||
if (postIsExpanded.value) {
|
||||
label += `${appearNote.value.text}; `;
|
||||
}
|
||||
} else {
|
||||
label += `${appearNote.value.text}; `;
|
||||
}
|
||||
}
|
||||
const date = new Date(appearNote.value.createdAt);
|
||||
label += `${date.toLocaleTimeString()}`;
|
||||
return label;
|
||||
});
|
||||
|
||||
defineExpose({
|
||||
focus,
|
||||
blur,
|
||||
|
@ -749,6 +864,7 @@ defineExpose({
|
|||
position: relative;
|
||||
padding: 0 32px 0 32px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
z-index: 1;
|
||||
&:first-child {
|
||||
margin-top: 20px;
|
||||
|
@ -801,6 +917,16 @@ defineExpose({
|
|||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 1.2em;
|
||||
height: 1.2em;
|
||||
border-radius: 2em;
|
||||
overflow: hidden;
|
||||
margin-right: 0.4em;
|
||||
background: var(--panelHighlight);
|
||||
transform: translateY(-4px);
|
||||
}
|
||||
|
||||
> span {
|
||||
overflow: hidden;
|
||||
flex-shrink: 1;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
ref="pagingComponent"
|
||||
:pagination="pagination"
|
||||
:disable-auto-load="disableAutoLoad"
|
||||
:folder
|
||||
>
|
||||
<template #empty>
|
||||
<div class="_fullinfo">
|
||||
|
@ -15,7 +16,7 @@
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<template #default="{ items: notes }">
|
||||
<template #default="{ foldedItems: notes }">
|
||||
<div ref="tlEl" class="giivymft" :class="{ noGap }">
|
||||
<XList
|
||||
ref="notes"
|
||||
|
@ -28,6 +29,21 @@
|
|||
class="notes"
|
||||
>
|
||||
<XNote
|
||||
v-if="'folded' in note && note.folded === 'thread'"
|
||||
:key="note.id"
|
||||
class="qtqtichx"
|
||||
:note="note.note"
|
||||
:parents="note.parents"
|
||||
/>
|
||||
<XNote
|
||||
v-else-if="'folded' in note && note.folded === 'renote'"
|
||||
:key="note.key"
|
||||
class="qtqtichx"
|
||||
:note="note.note"
|
||||
:renotes="note.renotesArr"
|
||||
/>
|
||||
<XNote
|
||||
v-else
|
||||
:key="note._featuredId_ || note._prId_ || note.id"
|
||||
class="qtqtichx"
|
||||
:note="note"
|
||||
|
@ -51,14 +67,21 @@ import XList from "@/components/MkDateSeparatedList.vue";
|
|||
import MkPagination from "@/components/MkPagination.vue";
|
||||
import { i18n } from "@/i18n";
|
||||
import { scroll } from "@/scripts/scroll";
|
||||
import type { NoteFolded, NoteThread, NoteType } from "@/types/note";
|
||||
|
||||
const tlEl = ref<HTMLElement>();
|
||||
|
||||
defineProps<{
|
||||
pagination: PagingOf<entities.Note>;
|
||||
noGap?: boolean;
|
||||
disableAutoLoad?: boolean;
|
||||
}>();
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
pagination: PagingOf<entities.Note>;
|
||||
noGap?: boolean;
|
||||
disableAutoLoad?: boolean;
|
||||
folder?: (ns: entities.Note[]) => (NoteType | NoteThread | NoteFolded)[];
|
||||
}>(),
|
||||
{
|
||||
folder: (ns: entities.Note[]) => ns,
|
||||
},
|
||||
);
|
||||
|
||||
const pagingComponent = ref<MkPaginationType<
|
||||
PagingKeyOf<entities.Note>
|
||||
|
|
|
@ -79,29 +79,35 @@ const stream = useStream();
|
|||
|
||||
const pagingComponent = ref<MkPaginationType<"i/notifications"> | null>(null);
|
||||
|
||||
const shouldFold = defaultStore.state.foldNotification;
|
||||
const shouldFold = defaultStore.reactiveState.foldNotification;
|
||||
|
||||
const convertNotification = computed(() =>
|
||||
shouldFold.value ? foldNotifications : (ns: entities.Notification[]) => ns,
|
||||
);
|
||||
|
||||
const FETCH_LIMIT = 90;
|
||||
|
||||
const pagination = Object.assign(
|
||||
{
|
||||
endpoint: "i/notifications" as const,
|
||||
params: computed(() => ({
|
||||
includeTypes: props.includeTypes ?? undefined,
|
||||
excludeTypes: props.includeTypes
|
||||
? undefined
|
||||
: me?.mutingNotificationTypes,
|
||||
unreadOnly: props.unreadOnly,
|
||||
})),
|
||||
},
|
||||
shouldFold
|
||||
? {
|
||||
limit: 50,
|
||||
secondFetchLimit: FETCH_LIMIT,
|
||||
}
|
||||
: {
|
||||
limit: 30,
|
||||
},
|
||||
const pagination = computed(() =>
|
||||
Object.assign(
|
||||
{
|
||||
endpoint: "i/notifications" as const,
|
||||
params: computed(() => ({
|
||||
includeTypes: props.includeTypes ?? undefined,
|
||||
excludeTypes: props.includeTypes
|
||||
? undefined
|
||||
: me?.mutingNotificationTypes,
|
||||
unreadOnly: props.unreadOnly,
|
||||
})),
|
||||
},
|
||||
shouldFold.value
|
||||
? {
|
||||
limit: 50,
|
||||
secondFetchLimit: FETCH_LIMIT,
|
||||
}
|
||||
: {
|
||||
limit: 30,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
function isNoteNotification(
|
||||
|
@ -138,14 +144,6 @@ const onNotification = (notification: entities.Notification) => {
|
|||
|
||||
let connection: StreamTypes.ChannelOf<"main"> | undefined;
|
||||
|
||||
function convertNotification(ns: entities.Notification[]) {
|
||||
if (shouldFold) {
|
||||
return foldNotifications(ns);
|
||||
} else {
|
||||
return ns;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
connection = stream.useChannel("main");
|
||||
connection.on("notification", onNotification);
|
||||
|
|
|
@ -365,9 +365,9 @@ async function fetch(firstFetching?: boolean) {
|
|||
}
|
||||
|
||||
// biome-ignore lint/style/noParameterAssign: assign it intentially
|
||||
res = res.filter((item) => {
|
||||
if (idMap.has(item)) return false;
|
||||
idMap.set(item, true);
|
||||
res = res.filter((it) => {
|
||||
if (idMap.has(it.id)) return false;
|
||||
idMap.set(it.id, true);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -435,8 +435,20 @@ const prepend = (...item: Item[]): void => {
|
|||
}
|
||||
};
|
||||
|
||||
const append = (...items: Item[]): void => {
|
||||
appended.value.push(...items);
|
||||
const append = (...it: Item[]): void => {
|
||||
// If there are too many appended, merge them into arrItems
|
||||
if (
|
||||
appended.value.length >
|
||||
(props.pagination.secondFetchLimit || SECOND_FETCH_LIMIT_DEFAULT)
|
||||
) {
|
||||
for (const item of appended.value) {
|
||||
idMap.set(item.id, true);
|
||||
}
|
||||
arrItems.value.push(appended.value);
|
||||
appended.value = [];
|
||||
// We don't need to calculate here because it won't cause any changes in items
|
||||
}
|
||||
appended.value.push(...it);
|
||||
calculateItems();
|
||||
};
|
||||
|
||||
|
@ -486,6 +498,8 @@ if (props.pagination.params && isRef<Param>(props.pagination.params)) {
|
|||
watch(props.pagination.params, reload, { deep: true });
|
||||
}
|
||||
|
||||
watch(() => props.folder, calculateItems);
|
||||
|
||||
watch(
|
||||
queue,
|
||||
(a, b) => {
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
:pagination="pagination"
|
||||
@queue="(x) => (queue = x)"
|
||||
@status="pullToRefreshComponent?.setDisabled($event)"
|
||||
:folder
|
||||
/>
|
||||
</MkPullToRefresh>
|
||||
<XNotes
|
||||
|
@ -39,6 +40,7 @@
|
|||
:pagination="pagination"
|
||||
@queue="(x) => (queue = x)"
|
||||
@status="pullToRefreshComponent?.setDisabled($event)"
|
||||
:folder
|
||||
/>
|
||||
</template>
|
||||
|
||||
|
@ -54,6 +56,8 @@ import { isSignedIn, me } from "@/me";
|
|||
import { i18n } from "@/i18n";
|
||||
import { defaultStore } from "@/store";
|
||||
import icon from "@/scripts/icon";
|
||||
import { foldNotes } from "@/scripts/fold";
|
||||
import type { NoteType } from "@/types/note";
|
||||
|
||||
export type TimelineSource =
|
||||
| "antenna"
|
||||
|
@ -85,6 +89,12 @@ const emit = defineEmits<{
|
|||
const tlComponent = ref<InstanceType<typeof XNotes>>();
|
||||
const pullToRefreshComponent = ref<InstanceType<typeof MkPullToRefresh>>();
|
||||
|
||||
const folder = computed(() => {
|
||||
const mergeThread = defaultStore.reactiveState.mergeThreadInTimeline.value;
|
||||
const mergeRenotes = defaultStore.reactiveState.mergeRenotesInTimeline.value;
|
||||
return (ns: NoteType[]) => foldNotes(ns, mergeThread, mergeRenotes);
|
||||
});
|
||||
|
||||
let endpoint: TypeUtils.EndpointsOf<entities.Note[]>; // keyof Endpoints
|
||||
let query: {
|
||||
antennaId?: string | undefined;
|
||||
|
|
|
@ -14,6 +14,12 @@
|
|||
>
|
||||
</template>
|
||||
</I18n>
|
||||
<I18n :src="i18n.ts.i18nServerInfo" v-if="serverLang" tag="span">
|
||||
<template #language><strong>{{ langs.find(a => a[0] === serverLang)?.[1] ?? serverLang }}</strong></template>
|
||||
</I18n>
|
||||
<button class="_textButton" @click="updateServerLang" v-if="lang && lang !== serverLang">
|
||||
{{i18n.t(serverLang ? "i18nServerChange" : "i18nServerSet", { language: langs.find(a => a[0] === lang)?.[1] ?? lang })}}
|
||||
</button>
|
||||
</template>
|
||||
</FormSelect>
|
||||
|
||||
|
@ -134,6 +140,12 @@
|
|||
<FormSwitch v-model="foldNotification" class="_formBlock">{{
|
||||
i18n.ts.foldNotification
|
||||
}}</FormSwitch>
|
||||
<FormSwitch v-model="mergeThreadInTimeline" class="_formBlock">{{
|
||||
i18n.ts.mergeThreadInTimeline
|
||||
}}</FormSwitch>
|
||||
<FormSwitch v-model="mergeRenotesInTimeline" class="_formBlock">{{
|
||||
i18n.ts.mergeRenotesInTimeline
|
||||
}}</FormSwitch>
|
||||
|
||||
<FormSelect v-model="serverDisconnectedBehavior" class="_formBlock">
|
||||
<template #label>{{ i18n.ts.whenServerDisconnected }}</template>
|
||||
|
@ -404,6 +416,7 @@ import { deviceKind } from "@/scripts/device-kind";
|
|||
import icon from "@/scripts/icon";
|
||||
|
||||
const lang = ref(localStorage.getItem("lang"));
|
||||
const serverLang = ref(me?.lang);
|
||||
const translateLang = ref(localStorage.getItem("translateLang"));
|
||||
const fontSize = ref(localStorage.getItem("fontSize"));
|
||||
const useSystemFont = ref(localStorage.getItem("useSystemFont") !== "f");
|
||||
|
@ -549,6 +562,12 @@ const autocorrectNoteLanguage = computed(
|
|||
const foldNotification = computed(
|
||||
defaultStore.makeGetterSetter("foldNotification"),
|
||||
);
|
||||
const mergeThreadInTimeline = computed(
|
||||
defaultStore.makeGetterSetter("mergeThreadInTimeline"),
|
||||
);
|
||||
const mergeRenotesInTimeline = computed(
|
||||
defaultStore.makeGetterSetter("mergeRenotesInTimeline"),
|
||||
);
|
||||
|
||||
// This feature (along with injectPromo) is currently disabled
|
||||
// function onChangeInjectFeaturedNote(v) {
|
||||
|
@ -559,6 +578,14 @@ const foldNotification = computed(
|
|||
// });
|
||||
// }
|
||||
|
||||
function updateServerLang() {
|
||||
os.api("i/update", {
|
||||
lang: lang.value,
|
||||
}).then((i) => {
|
||||
serverLang.value = i.lang;
|
||||
});
|
||||
}
|
||||
|
||||
watch(swipeOnDesktop, () => {
|
||||
defaultStore.set("swipeOnMobile", true);
|
||||
});
|
||||
|
@ -617,7 +644,6 @@ watch(
|
|||
enableTimelineStreaming,
|
||||
enablePullToRefresh,
|
||||
pullToRefreshThreshold,
|
||||
foldNotification,
|
||||
],
|
||||
async () => {
|
||||
await reloadAsk();
|
||||
|
|
|
@ -3,6 +3,9 @@ import type {
|
|||
FoldableNotification,
|
||||
NotificationFolded,
|
||||
} from "@/types/notification";
|
||||
import type { NoteType, NoteThread, NoteFolded } from "@/types/note";
|
||||
import { me } from "@/me";
|
||||
import { isDeleted, isRenote } from "./note";
|
||||
|
||||
interface FoldOption {
|
||||
/** If items length is 1, skip aggregation */
|
||||
|
@ -91,3 +94,94 @@ export function foldNotifications(ns: entities.Notification[]) {
|
|||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function foldNotes(ns: NoteType[], foldReply = true, foldRenote = true) {
|
||||
// By the implement of MkPagination, lastId is unique and is safe for key
|
||||
const lastId = ns[ns.length - 1]?.id ?? "prepend";
|
||||
|
||||
function foldReplies(ns: NoteType[]) {
|
||||
const res: Array<NoteType | NoteThread> = [];
|
||||
const threads = new Map<NoteType["id"], NoteType[]>();
|
||||
|
||||
for (const n of [...ns].reverse()) {
|
||||
if (isDeleted(n.id)) {
|
||||
continue;
|
||||
}
|
||||
if (n.replyId && threads.has(n.replyId)) {
|
||||
const th = threads.get(n.replyId)!;
|
||||
threads.delete(n.replyId);
|
||||
th.push(n);
|
||||
threads.set(n.id, th);
|
||||
} else if (n.reply?.replyId && threads.has(n.reply.replyId)) {
|
||||
const th = threads.get(n.reply.replyId)!;
|
||||
threads.delete(n.reply.replyId);
|
||||
th.push(n.reply, n);
|
||||
threads.set(n.id, th);
|
||||
} else {
|
||||
threads.set(n.id, [n]);
|
||||
}
|
||||
}
|
||||
|
||||
for (const n of ns) {
|
||||
const conversation = threads.get(n.id);
|
||||
if (conversation == null) continue;
|
||||
|
||||
const first = conversation[0];
|
||||
const last = conversation[conversation.length - 1];
|
||||
if (conversation.length === 1) {
|
||||
res.push(first);
|
||||
continue;
|
||||
}
|
||||
|
||||
res.push({
|
||||
// The same note can only appear once in the timeline, so the ID will not be repeated
|
||||
id: first.id,
|
||||
createdAt: last.createdAt,
|
||||
folded: "thread",
|
||||
note: last,
|
||||
parents: (first.reply ? [first.reply] : []).concat(
|
||||
conversation.slice(0, -1),
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
let res: (NoteType | NoteThread | NoteFolded)[] = ns;
|
||||
|
||||
if (foldReply) {
|
||||
res = foldReplies(ns);
|
||||
}
|
||||
|
||||
if (foldRenote) {
|
||||
res = foldItems(
|
||||
res,
|
||||
(n) => {
|
||||
// never fold my renotes
|
||||
if (!("folded" in n) && isRenote(n) && n.userId !== me?.id)
|
||||
return `renote-${n.renoteId}`;
|
||||
return n.id;
|
||||
},
|
||||
(ns, key) => {
|
||||
const represent = ns[0];
|
||||
if (!key.startsWith("renote-")) {
|
||||
return represent;
|
||||
}
|
||||
return {
|
||||
id: `G-${lastId}-${key}`,
|
||||
key: `G-${lastId}-${key}`,
|
||||
createdAt: represent.createdAt,
|
||||
folded: "renote",
|
||||
note: (represent as entities.Note).renote!,
|
||||
renotesArr: ns as entities.Note[],
|
||||
};
|
||||
},
|
||||
{
|
||||
skipSingleElement: false,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import type { entities } from "firefish-js";
|
||||
import { deletedNoteIds } from "./use-note-capture";
|
||||
|
||||
export function isRenote(note: entities.Note): note is entities.Note & {
|
||||
renote: entities.Note;
|
||||
text: null;
|
||||
renoteId: string;
|
||||
poll: undefined;
|
||||
} {
|
||||
return (
|
||||
note.renote != null &&
|
||||
note.text == null &&
|
||||
note.fileIds.length === 0 &&
|
||||
note.poll == null
|
||||
);
|
||||
}
|
||||
|
||||
export function isDeleted(noteId: string) {
|
||||
return deletedNoteIds.has(noteId);
|
||||
}
|
|
@ -1,22 +1,62 @@
|
|||
import type { Ref } from "vue";
|
||||
import { onUnmounted } from "vue";
|
||||
import type { entities } from "firefish-js";
|
||||
import { useStream } from "@/stream";
|
||||
import { isSignedIn, me } from "@/me";
|
||||
import * as os from "@/os";
|
||||
import type { NoteType } from "@/types/note";
|
||||
|
||||
export const deletedNoteIds = new Map<NoteType["id"], boolean>();
|
||||
|
||||
const noteRefs = new Map<NoteType["id"], Ref<NoteType>[]>();
|
||||
|
||||
function addToNoteRefs(note: Ref<NoteType>) {
|
||||
const refs = noteRefs.get(note.value.id);
|
||||
if (refs) {
|
||||
refs.push(note);
|
||||
} else {
|
||||
noteRefs.set(note.value.id, [note]);
|
||||
}
|
||||
}
|
||||
|
||||
function eachNote(id: NoteType["id"], cb: (note: Ref<NoteType>) => void) {
|
||||
const refs = noteRefs.get(id);
|
||||
if (refs) {
|
||||
for (const n of refs) {
|
||||
// n.value.id maybe changed
|
||||
if (n.value.id === id) {
|
||||
cb(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function useNoteCapture(props: {
|
||||
rootEl: Ref<HTMLElement | null>;
|
||||
note: Ref<entities.Note>;
|
||||
note: Ref<NoteType>;
|
||||
isDeletedRef: Ref<boolean>;
|
||||
onReplied?: (note: entities.Note) => void;
|
||||
onReplied?: (note: NoteType) => void;
|
||||
}) {
|
||||
let closed = false;
|
||||
const note = props.note;
|
||||
const connection = isSignedIn(me) ? useStream() : null;
|
||||
addToNoteRefs(note);
|
||||
|
||||
function onDeleted() {
|
||||
props.isDeletedRef.value = true;
|
||||
deletedNoteIds.set(note.value.id, true);
|
||||
|
||||
if (note.value.replyId) {
|
||||
eachNote(note.value.replyId, (n) => n.value.repliesCount--);
|
||||
}
|
||||
if (note.value.renoteId) {
|
||||
eachNote(note.value.renoteId, (n) => n.value.renoteCount--);
|
||||
}
|
||||
}
|
||||
|
||||
async function onStreamNoteUpdated(noteData): Promise<void> {
|
||||
const { type, id, body } = noteData;
|
||||
|
||||
if (closed) return;
|
||||
if (id !== note.value.id) return;
|
||||
|
||||
switch (type) {
|
||||
|
@ -87,7 +127,7 @@ export function useNoteCapture(props: {
|
|||
}
|
||||
|
||||
case "deleted": {
|
||||
props.isDeletedRef.value = true;
|
||||
onDeleted();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -96,17 +136,14 @@ export function useNoteCapture(props: {
|
|||
const editedNote = await os.api("notes/show", {
|
||||
noteId: id,
|
||||
});
|
||||
|
||||
const keys = new Set<string>();
|
||||
Object.keys(editedNote)
|
||||
.concat(Object.keys(note.value))
|
||||
.forEach((key) => keys.add(key));
|
||||
keys.forEach((key) => {
|
||||
for (const key of [
|
||||
...new Set(Object.keys(editedNote).concat(Object.keys(note.value))),
|
||||
]) {
|
||||
note.value[key] = editedNote[key];
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
// delete the note if failing to get the edited note
|
||||
props.isDeletedRef.value = true;
|
||||
onDeleted();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -147,4 +184,10 @@ export function useNoteCapture(props: {
|
|||
connection.off("_connected_", onStreamConnected);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
close: () => {
|
||||
closed = true;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -454,6 +454,14 @@ export const defaultStore = markRaw(
|
|||
where: "deviceAccount",
|
||||
default: true,
|
||||
},
|
||||
mergeThreadInTimeline: {
|
||||
where: "deviceAccount",
|
||||
default: true,
|
||||
},
|
||||
mergeRenotesInTimeline: {
|
||||
where: "deviceAccount",
|
||||
default: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { noteVisibilities } from "firefish-js";
|
||||
import type { entities, noteVisibilities } from "firefish-js";
|
||||
|
||||
export type NoteVisibility = (typeof noteVisibilities)[number] | "private";
|
||||
|
||||
|
@ -6,3 +6,25 @@ export interface NoteTranslation {
|
|||
sourceLang: string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
export type NoteType = entities.Note & {
|
||||
_featuredId_?: string;
|
||||
_prId_?: string;
|
||||
};
|
||||
|
||||
export type NoteFolded = {
|
||||
id: string;
|
||||
key: string;
|
||||
createdAt: entities.Note["createdAt"];
|
||||
folded: "renote";
|
||||
note: entities.Note;
|
||||
renotesArr: entities.Note[];
|
||||
};
|
||||
|
||||
export type NoteThread = {
|
||||
id: string;
|
||||
createdAt: entities.Note["createdAt"];
|
||||
folded: "thread";
|
||||
note: entities.Note;
|
||||
parents: entities.Note[];
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import path, { join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { execa } from "execa";
|
||||
import fs from "node:fs";
|
||||
|
||||
(async () => {
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
@ -32,4 +33,18 @@ import { execa } from "execa";
|
|||
stdio: "inherit",
|
||||
}
|
||||
);
|
||||
|
||||
if (!fs.existsSync(join(__dirname, "/../packages/backend-rs/built/index.js"))) {
|
||||
fs.copyFileSync(
|
||||
join(__dirname, "/../packages/backend-rs/index.js"),
|
||||
join(__dirname, "/../packages/backend-rs/built/index.js"),
|
||||
);
|
||||
console.warn("backend-rs/built/index.js has not been updated (https://github.com/napi-rs/napi-rs/issues/1768)");
|
||||
}
|
||||
if (!fs.existsSync(join(__dirname, "/../packages/backend-rs/built/index.d.ts"))) {
|
||||
fs.copyFileSync(
|
||||
join(__dirname, "/../packages/backend-rs/index.d.ts"),
|
||||
join(__dirname, "/../packages/backend-rs/built/index.d.ts"),
|
||||
);
|
||||
}
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue