Merge branch 'develop' into iceshrimp_mastodon

This commit is contained in:
naskya 2024-05-29 23:44:12 +09:00
commit 6db8ad14e2
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
11 changed files with 94 additions and 101 deletions

View file

@ -83,7 +83,7 @@ test:build:
- pnpm run migrate
- psql --host postgres --user "${POSTGRES_USER}" --dbname "${POSTGRES_DB}" --command "$(cat docs/downgrade.sql)"
test:build:backend_ts_only:
test:build:backend_ts:
stage: test
rules:
- if: $TEST == 'true'
@ -111,12 +111,14 @@ test:build:backend_ts_only:
- 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 nodejs postgresql-client
- apt-get install -y --no-install-recommends build-essential clang mold python3 perl nodejs postgresql-client
- corepack enable
- corepack prepare pnpm@latest --activate
- mkdir -p packages/backend-rs/built
- 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
- cp .config/ci.yml .config/default.yml
- export PGPASSWORD="${POSTGRES_PASSWORD}"
- psql --host postgres --user "${POSTGRES_USER}" --dbname "${POSTGRES_DB}" --command 'CREATE EXTENSION pgroonga'
@ -126,7 +128,7 @@ test:build:backend_ts_only:
- pnpm run migrate
- psql --host postgres --user "${POSTGRES_USER}" --dbname "${POSTGRES_DB}" --command "$(cat docs/downgrade.sql)"
test:build:client_only:
test:build:client:
stage: test
rules:
- if: $TEST == 'true'
@ -263,9 +265,6 @@ cargo:clippy:
cargo:doc:
stage: doc
needs:
- cargo:test
- test:build
rules:
- if: $DOC == 'true'
when: always
@ -282,43 +281,15 @@ cargo:doc:
when: always
services: []
before_script:
- apt-get update && apt-get -y upgrade
- apt-get install -y --no-install-recommends build-essential clang mold
- apt-get update
- apt-get install -y --no-install-recommends build-essential clang mold nodejs npm
- cp ci/cargo/config.toml /usr/local/cargo/config.toml
- npm install --global netlify-cli
script:
- cargo doc --no-deps
artifacts:
paths:
- target/doc
pages:
stage: doc
needs:
- cargo:doc
rules:
- if: $DOC == 'true'
when: always
- if: $DOC == 'false'
when: never
- if: $CI_COMMIT_BRANCH == 'develop'
changes:
paths:
- packages/backend-rs/**/*
- packages/macro-rs/**/*
- Cargo.toml
- Cargo.lock
- package.json
when: always
image: docker.io/alpine:latest
services: []
before_script: []
script:
- mkdir -p public/backend_rs
- cp --recursive target/doc public/backend-rs/doc
- printf '<meta http-equiv="refresh" content="0; url=%s">' 'backend_rs' > public/backend-rs/doc/index.html
artifacts:
paths:
- public
- printf '<meta http-equiv="refresh" content="0; url=%s">' 'backend_rs' > target/doc/index.html
- cd target/doc
- netlify deploy --prod --site="${CARGO_DOC_SITE_ID}" --dir=.
renovate:
stage: dependency

56
Cargo.lock generated
View file

@ -103,7 +103,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -154,7 +154,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -165,7 +165,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -430,7 +430,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
"syn_derive",
]
@ -731,7 +731,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f"
dependencies = [
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -1478,7 +1478,7 @@ checksum = "0122b7114117e64a63ac49f752a5ca4624d534c7b1c7de796ac196381cd2d947"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -1507,7 +1507,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -1747,7 +1747,7 @@ dependencies = [
"quote",
"serde",
"serde_json",
"syn 2.0.65",
"syn 2.0.66",
"thiserror",
]
@ -1842,7 +1842,7 @@ dependencies = [
"napi-derive-backend",
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -1857,7 +1857,7 @@ dependencies = [
"quote",
"regex",
"semver",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -1985,7 +1985,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -2077,7 +2077,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -2138,7 +2138,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -2296,7 +2296,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -2478,7 +2478,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd"
dependencies = [
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -2944,7 +2944,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -2985,7 +2985,7 @@ dependencies = [
"proc-macro2",
"quote",
"sea-bae",
"syn 2.0.65",
"syn 2.0.66",
"unicode-ident",
]
@ -3076,7 +3076,7 @@ checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -3549,7 +3549,7 @@ dependencies = [
"proc-macro2",
"quote",
"rustversion",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -3571,9 +3571,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.65"
version = "2.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106"
checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5"
dependencies = [
"proc-macro2",
"quote",
@ -3589,7 +3589,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -3673,7 +3673,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -3770,7 +3770,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -3875,7 +3875,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]
@ -4089,7 +4089,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
"wasm-bindgen-shared",
]
@ -4111,7 +4111,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -4395,7 +4395,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.65",
"syn 2.0.66",
]
[[package]]

View file

@ -36,7 +36,7 @@ serde = "1.0.202"
serde_json = "1.0.117"
serde_yaml = "0.9.34"
strum = "0.26.2"
syn = "2.0.65"
syn = "2.0.66"
sysinfo = "0.30.12"
thiserror = "1.0.61"
tokio = "1.37.0"

View file

@ -13,9 +13,9 @@ export const USER_ACTIVE_THRESHOLD: number
* List of file types allowed to be viewed directly in the browser
* Anything not included here will be responded as application/octet-stream
* SVG is not allowed because it generates XSS <- we need to fix this and later allow it to be viewed directly
* <https://github.com/sindresorhus/file-type/blob/main/supported.js>
* <https://github.com/sindresorhus/file-type/blob/main/core.js>
* <https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers>
* * <https://github.com/sindresorhus/file-type/blob/main/supported.js>
* * <https://github.com/sindresorhus/file-type/blob/main/core.js>
* * <https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers>
*/
export const FILE_TYPE_BROWSERSAFE: string[]
export interface EnvConfig {

View file

@ -15,9 +15,9 @@ pub const USER_ACTIVE_THRESHOLD: i32 = 3 * DAY;
/// List of file types allowed to be viewed directly in the browser
/// Anything not included here will be responded as application/octet-stream
/// SVG is not allowed because it generates XSS <- we need to fix this and later allow it to be viewed directly
/// <https://github.com/sindresorhus/file-type/blob/main/supported.js>
/// <https://github.com/sindresorhus/file-type/blob/main/core.js>
/// <https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers>
/// * <https://github.com/sindresorhus/file-type/blob/main/supported.js>
/// * <https://github.com/sindresorhus/file-type/blob/main/core.js>
/// * <https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers>
#[crate::export]
pub const FILE_TYPE_BROWSERSAFE: [&str; 41] = [
// Images

View file

@ -11,20 +11,27 @@ pub const VERSION: &str = macro_rs::read_version_from_package_json!();
struct ServerConfig {
pub url: String,
pub port: u16,
/// host to listen on
/// the host address to bind to
pub bind: Option<String>,
pub disable_hsts: Option<bool>,
/// PostgreSQL configurations
pub db: DbConfig,
/// Redis configurations
pub redis: RedisConfig,
/// secondary Redis server configurations
pub cache_server: Option<RedisConfig>,
/// proxy host used for HTTP requests
pub proxy: Option<String>,
/// proxy host used for SMTP requests
pub proxy_smtp: Option<String>,
/// hosts to bypass the proxy
pub proxy_bypass_hosts: Option<Vec<String>>,
pub allowed_private_networks: Option<Vec<String>>,
// TODO: i64 -> u64 (NapiValue is not implemented for u64)
/// maximum file size that can be uploaded to the drive (in bytes)
pub max_file_size: Option<i64>,
pub access_log: Option<String>,
pub cluster_limits: Option<WorkerConfigInternal>,
@ -38,9 +45,10 @@ struct ServerConfig {
pub deliver_job_max_attempts: Option<u32>,
pub inbox_job_max_attempts: Option<u32>,
/// deprecated
/// deprecated in favor of `max_log_level`
pub log_level: Option<Vec<String>>,
/// verbosity of the server log. `error`, `warn`, `info`, `debug`, or `trace`
pub max_log_level: Option<String>,
pub syslog: Option<SysLogConfig>,

View file

@ -13,14 +13,26 @@ pub struct NoteLike {
pub reply_id: Option<String>,
}
pub async fn all_texts(note: NoteLike, include_in_reply_to: bool) -> Result<Vec<String>, DbErr> {
/// Returns [Vec<String>] containing the post text, content warning,
/// those of the "parent" (replied/quoted) posts, and alt texts of attached files.
///
/// ## Arguments
///
/// * `note` - [NoteLike] object
/// * `include_parent` - whether to take the reply-to post and quoted post into account
pub async fn all_texts(note: NoteLike, include_parent: bool) -> Result<Vec<String>, DbErr> {
let db = db_conn().await?;
let mut texts: Vec<String> = vec![];
let is_renote: bool;
if let Some(text) = note.text {
is_renote = false;
texts.push(text);
} else {
is_renote = true;
}
if let Some(cw) = note.cw {
texts.push(cw);
}
@ -37,8 +49,10 @@ pub async fn all_texts(note: NoteLike, include_in_reply_to: bool) -> Result<Vec<
.flatten(),
);
if let Some(renote_id) = &note.renote_id {
if let Some((text, cw)) = note::Entity::find_by_id(renote_id)
if note.renote_id.is_some() && (include_parent || is_renote) {
let renote_id = note.renote_id.unwrap();
if let Some((text, cw)) = note::Entity::find_by_id(&renote_id)
.select_only()
.columns([note::Column::Text, note::Column::Cw])
.into_tuple::<(Option<String>, Option<String>)>()
@ -56,7 +70,7 @@ pub async fn all_texts(note: NoteLike, include_in_reply_to: bool) -> Result<Vec<
}
}
if include_in_reply_to && note.reply_id.is_some() {
if include_parent && note.reply_id.is_some() {
if let Some((text, cw)) = note::Entity::find_by_id(note.reply_id.as_ref().unwrap())
.select_only()
.columns([note::Column::Text, note::Column::Cw])

View file

@ -78,7 +78,7 @@ pub async fn update_antennas_on_new_note(
Ok(())
}
pub async fn add_note_to_antenna(antenna_id: &str, note: &Note) -> Result<(), Error> {
async fn add_note_to_antenna(antenna_id: &str, note: &Note) -> Result<(), Error> {
// for timeline API
redis_conn()
.await?

View file

@ -1,3 +1,3 @@
pub mod fetch;
pub mod generate;
pub mod schema;
mod schema;

View file

@ -31,18 +31,18 @@
"@koa/router": "12.0.1",
"@ladjs/koa-views": "9.0.0",
"@peertube/http-signature": "1.7.0",
"@redocly/openapi-core": "1.12.2",
"@redocly/openapi-core": "1.13.0",
"@sinonjs/fake-timers": "11.2.2",
"adm-zip": "0.5.10",
"ajv": "8.13.0",
"archiver": "7.0.1",
"async-lock": "1.4.0",
"async-mutex": "^0.5.0",
"aws-sdk": "2.1626.0",
"aws-sdk": "2.1627.0",
"axios": "1.7.2",
"backend-rs": "workspace:*",
"blurhash": "2.0.5",
"bull": "4.12.8",
"bull": "4.12.9",
"cacheable-lookup": "TheEssem/cacheable-lookup",
"cbor-x": "1.5.9",
"chalk": "5.3.0",

View file

@ -70,8 +70,8 @@ importers:
specifier: 1.7.0
version: 1.7.0
'@redocly/openapi-core':
specifier: 1.12.2
version: 1.12.2
specifier: 1.13.0
version: 1.13.0
'@sinonjs/fake-timers':
specifier: 11.2.2
version: 11.2.2
@ -91,8 +91,8 @@ importers:
specifier: ^0.5.0
version: 0.5.0
aws-sdk:
specifier: 2.1626.0
version: 2.1626.0
specifier: 2.1627.0
version: 2.1627.0
axios:
specifier: 1.7.2
version: 1.7.2
@ -103,8 +103,8 @@ importers:
specifier: 2.0.5
version: 2.0.5
bull:
specifier: 4.12.8
version: 4.12.8
specifier: 4.12.9
version: 4.12.9
cacheable-lookup:
specifier: TheEssem/cacheable-lookup
version: https://codeload.github.com/TheEssem/cacheable-lookup/tar.gz/dd2fb616366a3c68dcf321a57a67295967b204bf
@ -1888,8 +1888,8 @@ packages:
'@redocly/config@0.5.0':
resolution: {integrity: sha512-oA1ezWPT2tSV9CLk0FtZlViaFKtp+id3iAVeKBme1DdP4xUCdxEdP8umB21iLKdc6leRd5uGa+T5Ox4nHBAXWg==}
'@redocly/openapi-core@1.12.2':
resolution: {integrity: sha512-dImBZaKws54a4/QdoAVsLDm4/gfVnzAVD68pSGFPMTLNM2AZINvevfUfOrbUNTXwHvG2UJkthUxDGQZLsp3Vaw==}
'@redocly/openapi-core@1.13.0':
resolution: {integrity: sha512-lPvVE4+QjWMXCEIui994pYBZGqvEsodaCJPCJLkx6RK3OL/6Ss8wN17YTDmF49tzw3xgA8t4+x7TqelUSRcZUQ==}
engines: {node: '>=14.19.0', npm: '>=7.0.0'}
'@rollup/plugin-alias@5.1.0':
@ -2885,8 +2885,8 @@ packages:
resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==}
engines: {node: '>= 0.4'}
aws-sdk@2.1626.0:
resolution: {integrity: sha512-auPVi0ZwmWioHcXK7A6RReNVk9y4GmvT5gPQvq5ictss/Cl/Yb9vjy/6DrZ2wUjSVAE16z5IVyE6G4Zsdhr+JQ==}
aws-sdk@2.1627.0:
resolution: {integrity: sha512-jcgGkGc4zZ8VZymw8RzD9BrnxHjmV7Lb1fc7Kw9Hku67PKSSoEp/sMGagjOBjBU7saRcACRPBFR7dgUyIDHGNw==}
engines: {node: '>= 10.0.0'}
axios@0.24.0:
@ -3043,8 +3043,8 @@ packages:
builtins@5.1.0:
resolution: {integrity: sha512-SW9lzGTLvWTP1AY8xeAMZimqDrIaSdLQUcVr9DMef51niJ022Ri87SwRRKYm4A6iHfkPaiVUu/Duw2Wc4J7kKg==}
bull@4.12.8:
resolution: {integrity: sha512-JgZVAR3ChuesMWSJfQjgTyXb6kdT6qos3ft9pt0AASRMiRZIjDxHMtxfcOs2Zf8O9uSv0Y5ycYwv5Te3liGJ3A==}
bull@4.12.9:
resolution: {integrity: sha512-rqka/O9ZBfrKgI4fanhN6XW0AJ9WYRakjHlCJPjoHyh79xIvEjyU8hvs/CCeRdrbU6zSw8UNfDOjCUaQO1MTuQ==}
engines: {node: '>=12'}
busboy@1.6.0:
@ -8953,7 +8953,7 @@ snapshots:
'@redocly/config@0.5.0': {}
'@redocly/openapi-core@1.12.2':
'@redocly/openapi-core@1.13.0':
dependencies:
'@redocly/ajv': 8.11.0
'@redocly/config': 0.5.0
@ -10052,7 +10052,7 @@ snapshots:
dependencies:
possible-typed-array-names: 1.0.0
aws-sdk@2.1626.0:
aws-sdk@2.1627.0:
dependencies:
buffer: 4.9.2
events: 1.1.1
@ -10267,7 +10267,7 @@ snapshots:
dependencies:
semver: 7.6.2
bull@4.12.8:
bull@4.12.9:
dependencies:
cron-parser: 4.9.0
get-port: 5.1.1