mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-29 15:51:20 +00:00
Merge remote-tracking branch 'origin/main' into delete_local_image_on_delete_account
This commit is contained in:
commit
8c99a5598d
131 changed files with 2545 additions and 1229 deletions
4
.github/CODEOWNERS
vendored
4
.github/CODEOWNERS
vendored
|
@ -1,3 +1,3 @@
|
||||||
* @Nutomic @dessalines @phiresky
|
* @Nutomic @dessalines @phiresky @dullbananas @SleeplessOne1917
|
||||||
crates/apub/ @Nutomic
|
crates/apub/ @Nutomic
|
||||||
migrations/ @dessalines @phiresky
|
migrations/ @dessalines @phiresky @dullbananas
|
||||||
|
|
2
.github/ISSUE_TEMPLATE/BUG_REPORT.yml
vendored
2
.github/ISSUE_TEMPLATE/BUG_REPORT.yml
vendored
|
@ -20,6 +20,8 @@ body:
|
||||||
required: true
|
required: true
|
||||||
- label: Is this only a single bug? Do not put multiple bugs in one issue.
|
- label: Is this only a single bug? Do not put multiple bugs in one issue.
|
||||||
required: true
|
required: true
|
||||||
|
- label: Do you agree to follow the rules in our [Code of Conduct](https://join-lemmy.org/docs/code_of_conduct.html)?
|
||||||
|
required: true
|
||||||
- label: Is this a backend issue? Use the [lemmy-ui](https://github.com/LemmyNet/lemmy-ui) repo for UI / frontend issues.
|
- label: Is this a backend issue? Use the [lemmy-ui](https://github.com/LemmyNet/lemmy-ui) repo for UI / frontend issues.
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|
2
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml
vendored
2
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml
vendored
|
@ -20,6 +20,8 @@ body:
|
||||||
required: true
|
required: true
|
||||||
- label: Is this a backend issue? Use the [lemmy-ui](https://github.com/LemmyNet/lemmy-ui) repo for UI / frontend issues.
|
- label: Is this a backend issue? Use the [lemmy-ui](https://github.com/LemmyNet/lemmy-ui) repo for UI / frontend issues.
|
||||||
required: true
|
required: true
|
||||||
|
- label: Do you agree to follow the rules in our [Code of Conduct](https://join-lemmy.org/docs/code_of_conduct.html)?
|
||||||
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: problem
|
id: problem
|
||||||
attributes:
|
attributes:
|
||||||
|
|
|
@ -6,21 +6,23 @@ variables:
|
||||||
- &install_pnpm "corepack enable pnpm"
|
- &install_pnpm "corepack enable pnpm"
|
||||||
- &slow_check_paths
|
- &slow_check_paths
|
||||||
- path:
|
- path:
|
||||||
|
include: [
|
||||||
# rust source code
|
# rust source code
|
||||||
- "crates/**"
|
"crates/**",
|
||||||
- "src/**"
|
"src/**",
|
||||||
- "**/Cargo.toml"
|
"**/Cargo.toml",
|
||||||
- "Cargo.lock"
|
"Cargo.lock",
|
||||||
# database migrations
|
# database migrations
|
||||||
- "migrations/**"
|
"migrations/**",
|
||||||
# typescript tests
|
# typescript tests
|
||||||
- "api_tests/**"
|
"api_tests/**",
|
||||||
# config files and scripts used by ci
|
# config files and scripts used by ci
|
||||||
- ".woodpecker.yml"
|
".woodpecker.yml",
|
||||||
- ".rustfmt.toml"
|
".rustfmt.toml",
|
||||||
- "scripts/update_config_defaults.sh"
|
"scripts/update_config_defaults.sh",
|
||||||
- "diesel.toml"
|
"diesel.toml",
|
||||||
- ".gitmodules"
|
".gitmodules",
|
||||||
|
]
|
||||||
|
|
||||||
# Broken for cron jobs currently, see
|
# Broken for cron jobs currently, see
|
||||||
# https://github.com/woodpecker-ci/woodpecker/issues/1716
|
# https://github.com/woodpecker-ci/woodpecker/issues/1716
|
||||||
|
@ -198,7 +200,7 @@ steps:
|
||||||
- cat target/log/lemmy_*.out || true
|
- cat target/log/lemmy_*.out || true
|
||||||
- "# If you can't see all output, then use the download button"
|
- "# If you can't see all output, then use the download button"
|
||||||
when:
|
when:
|
||||||
status: [failure]
|
- status: [failure]
|
||||||
|
|
||||||
publish_release_docker:
|
publish_release_docker:
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
|
@ -211,7 +213,7 @@ steps:
|
||||||
- RUST_RELEASE_MODE=release
|
- RUST_RELEASE_MODE=release
|
||||||
tag: ${CI_COMMIT_TAG}
|
tag: ${CI_COMMIT_TAG}
|
||||||
when:
|
when:
|
||||||
event: tag
|
- event: tag
|
||||||
|
|
||||||
nightly_build:
|
nightly_build:
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
|
@ -224,7 +226,7 @@ steps:
|
||||||
- RUST_RELEASE_MODE=release
|
- RUST_RELEASE_MODE=release
|
||||||
tag: dev
|
tag: dev
|
||||||
when:
|
when:
|
||||||
event: cron
|
- event: cron
|
||||||
|
|
||||||
# using https://github.com/pksunkara/cargo-workspaces
|
# using https://github.com/pksunkara/cargo-workspaces
|
||||||
publish_to_crates_io:
|
publish_to_crates_io:
|
||||||
|
@ -237,7 +239,7 @@ steps:
|
||||||
- cargo workspaces publish --from-git --allow-dirty --no-verify --allow-branch "${CI_COMMIT_TAG}" --yes custom "${CI_COMMIT_TAG}"
|
- cargo workspaces publish --from-git --allow-dirty --no-verify --allow-branch "${CI_COMMIT_TAG}" --yes custom "${CI_COMMIT_TAG}"
|
||||||
secrets: [cargo_api_token]
|
secrets: [cargo_api_token]
|
||||||
when:
|
when:
|
||||||
event: tag
|
- event: tag
|
||||||
|
|
||||||
notify_on_failure:
|
notify_on_failure:
|
||||||
image: alpine:3
|
image: alpine:3
|
||||||
|
@ -245,7 +247,7 @@ steps:
|
||||||
- apk add curl
|
- apk add curl
|
||||||
- "curl -d'Lemmy CI build failed: ${CI_PIPELINE_URL}' ntfy.sh/lemmy_drone_ci"
|
- "curl -d'Lemmy CI build failed: ${CI_PIPELINE_URL}' ntfy.sh/lemmy_drone_ci"
|
||||||
when:
|
when:
|
||||||
status: [failure]
|
- status: [failure]
|
||||||
|
|
||||||
notify_on_tag_deploy:
|
notify_on_tag_deploy:
|
||||||
image: alpine:3
|
image: alpine:3
|
||||||
|
@ -253,7 +255,7 @@ steps:
|
||||||
- apk add curl
|
- apk add curl
|
||||||
- "curl -d'lemmy:${CI_COMMIT_TAG} deployed' ntfy.sh/lemmy_drone_ci"
|
- "curl -d'lemmy:${CI_COMMIT_TAG} deployed' ntfy.sh/lemmy_drone_ci"
|
||||||
when:
|
when:
|
||||||
event: tag
|
- event: tag
|
||||||
|
|
||||||
services:
|
services:
|
||||||
database:
|
database:
|
||||||
|
|
1052
Cargo.lock
generated
1052
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
32
Cargo.toml
32
Cargo.toml
|
@ -37,6 +37,8 @@ debug = 0
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
embed-pictrs = ["pict-rs"]
|
embed-pictrs = ["pict-rs"]
|
||||||
|
# This feature requires building with `tokio_unstable` flag, see documentation:
|
||||||
|
# https://docs.rs/tokio/latest/tokio/#unstable-features
|
||||||
console = [
|
console = [
|
||||||
"console-subscriber",
|
"console-subscriber",
|
||||||
"opentelemetry",
|
"opentelemetry",
|
||||||
|
@ -96,15 +98,15 @@ lemmy_routes = { version = "=0.19.3", path = "./crates/routes" }
|
||||||
lemmy_db_views = { version = "=0.19.3", path = "./crates/db_views" }
|
lemmy_db_views = { version = "=0.19.3", path = "./crates/db_views" }
|
||||||
lemmy_db_views_actor = { version = "=0.19.3", path = "./crates/db_views_actor" }
|
lemmy_db_views_actor = { version = "=0.19.3", path = "./crates/db_views_actor" }
|
||||||
lemmy_db_views_moderator = { version = "=0.19.3", path = "./crates/db_views_moderator" }
|
lemmy_db_views_moderator = { version = "=0.19.3", path = "./crates/db_views_moderator" }
|
||||||
activitypub_federation = { version = "0.5.1-beta.1", default-features = false, features = [
|
activitypub_federation = { version = "0.5.2", default-features = false, features = [
|
||||||
"actix-web",
|
"actix-web",
|
||||||
] }
|
] }
|
||||||
diesel = "2.1.4"
|
diesel = "2.1.4"
|
||||||
diesel_migrations = "2.1.0"
|
diesel_migrations = "2.1.0"
|
||||||
diesel-async = "0.4.1"
|
diesel-async = "0.4.1"
|
||||||
serde = { version = "1.0.195", features = ["derive"] }
|
serde = { version = "1.0.197", features = ["derive"] }
|
||||||
serde_with = "3.5.1"
|
serde_with = "3.7.0"
|
||||||
actix-web = { version = "4.4.1", default-features = false, features = [
|
actix-web = { version = "4.5.1", default-features = false, features = [
|
||||||
"macros",
|
"macros",
|
||||||
"rustls",
|
"rustls",
|
||||||
"compress-brotli",
|
"compress-brotli",
|
||||||
|
@ -113,39 +115,39 @@ actix-web = { version = "4.4.1", default-features = false, features = [
|
||||||
"cookies",
|
"cookies",
|
||||||
] }
|
] }
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
tracing-actix-web = { version = "0.7.9", default-features = false }
|
tracing-actix-web = { version = "0.7.10", default-features = false }
|
||||||
tracing-error = "0.2.0"
|
tracing-error = "0.2.0"
|
||||||
tracing-log = "0.2.0"
|
tracing-log = "0.2.0"
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||||
url = { version = "2.5.0", features = ["serde"] }
|
url = { version = "2.5.0", features = ["serde"] }
|
||||||
reqwest = { version = "0.11.23", features = ["json", "blocking", "gzip"] }
|
reqwest = { version = "0.11.26", features = ["json", "blocking", "gzip"] }
|
||||||
reqwest-middleware = "0.2.4"
|
reqwest-middleware = "0.2.4"
|
||||||
reqwest-tracing = "0.4.7"
|
reqwest-tracing = "0.4.7"
|
||||||
clokwerk = "0.4.0"
|
clokwerk = "0.4.0"
|
||||||
doku = { version = "0.21.1", features = ["url-2"] }
|
doku = { version = "0.21.1", features = ["url-2"] }
|
||||||
bcrypt = "0.15.0"
|
bcrypt = "0.15.0"
|
||||||
chrono = { version = "0.4.32", features = ["serde"], default-features = false }
|
chrono = { version = "0.4.35", features = ["serde"], default-features = false }
|
||||||
serde_json = { version = "1.0.111", features = ["preserve_order"] }
|
serde_json = { version = "1.0.114", features = ["preserve_order"] }
|
||||||
base64 = "0.21.7"
|
base64 = "0.21.7"
|
||||||
uuid = { version = "1.7.0", features = ["serde", "v4"] }
|
uuid = { version = "1.7.0", features = ["serde", "v4"] }
|
||||||
async-trait = "0.1.77"
|
async-trait = "0.1.77"
|
||||||
captcha = "0.0.9"
|
captcha = "0.0.9"
|
||||||
anyhow = { version = "1.0.79", features = [
|
anyhow = { version = "1.0.81", features = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
] } # backtrace is on by default on nightly, but not stable rust
|
] } # backtrace is on by default on nightly, but not stable rust
|
||||||
diesel_ltree = "0.3.1"
|
diesel_ltree = "0.3.1"
|
||||||
typed-builder = "0.18.1"
|
typed-builder = "0.18.1"
|
||||||
serial_test = "2.0.0"
|
serial_test = "2.0.0"
|
||||||
tokio = { version = "1.35.1", features = ["full"] }
|
tokio = { version = "1.36.0", features = ["full"] }
|
||||||
regex = "1.10.3"
|
regex = "1.10.3"
|
||||||
once_cell = "1.19.0"
|
once_cell = "1.19.0"
|
||||||
diesel-derive-newtype = "2.1.0"
|
diesel-derive-newtype = "2.1.0"
|
||||||
diesel-derive-enum = { version = "2.1.0", features = ["postgres"] }
|
diesel-derive-enum = { version = "2.1.0", features = ["postgres"] }
|
||||||
strum = "0.25.0"
|
strum = "0.25.0"
|
||||||
strum_macros = "0.25.3"
|
strum_macros = "0.25.3"
|
||||||
itertools = "0.12.0"
|
itertools = "0.12.1"
|
||||||
futures = "0.3.30"
|
futures = "0.3.30"
|
||||||
http = "0.2.11"
|
http = "0.2.12"
|
||||||
rosetta-i18n = "0.1.3"
|
rosetta-i18n = "0.1.3"
|
||||||
opentelemetry = { version = "0.19.0", features = ["rt-tokio"] }
|
opentelemetry = { version = "0.19.0", features = ["rt-tokio"] }
|
||||||
tracing-opentelemetry = { version = "0.19.0" }
|
tracing-opentelemetry = { version = "0.19.0" }
|
||||||
|
@ -160,9 +162,9 @@ tokio-postgres = "0.7.10"
|
||||||
tokio-postgres-rustls = "0.10.0"
|
tokio-postgres-rustls = "0.10.0"
|
||||||
urlencoding = "2.1.3"
|
urlencoding = "2.1.3"
|
||||||
enum-map = "2.7"
|
enum-map = "2.7"
|
||||||
moka = { version = "0.12.4", features = ["future"] }
|
moka = { version = "0.12.5", features = ["future"] }
|
||||||
i-love-jesus = { version = "0.1.0" }
|
i-love-jesus = { version = "0.1.0" }
|
||||||
clap = { version = "4.4.18", features = ["derive"] }
|
clap = { version = "4.5.2", features = ["derive"] }
|
||||||
pretty_assertions = "1.4.0"
|
pretty_assertions = "1.4.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -193,7 +195,7 @@ tracing-opentelemetry = { workspace = true, optional = true }
|
||||||
opentelemetry = { workspace = true, optional = true }
|
opentelemetry = { workspace = true, optional = true }
|
||||||
console-subscriber = { version = "0.1.10", optional = true }
|
console-subscriber = { version = "0.1.10", optional = true }
|
||||||
opentelemetry-otlp = { version = "0.12.0", optional = true }
|
opentelemetry-otlp = { version = "0.12.0", optional = true }
|
||||||
pict-rs = { version = "0.5.1", optional = true }
|
pict-rs = { version = "0.5.9", optional = true }
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
actix-cors = "0.6.5"
|
actix-cors = "0.6.5"
|
||||||
futures-util = { workspace = true }
|
futures-util = { workspace = true }
|
||||||
|
|
|
@ -20,16 +20,16 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.12",
|
"@types/jest": "^29.5.12",
|
||||||
"@types/node": "^20.11.22",
|
"@types/node": "^20.11.27",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
||||||
"@typescript-eslint/parser": "^7.1.0",
|
"@typescript-eslint/parser": "^7.2.0",
|
||||||
"download-file-sync": "^1.0.4",
|
"download-file-sync": "^1.0.4",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-plugin-prettier": "^5.0.1",
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
"jest": "^29.5.0",
|
"jest": "^29.5.0",
|
||||||
"lemmy-js-client": "0.19.4-alpha.6",
|
"lemmy-js-client": "0.19.4-alpha.8",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
"ts-jest": "^29.1.0",
|
"ts-jest": "^29.1.0",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.4.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,14 @@ devDependencies:
|
||||||
specifier: ^29.5.12
|
specifier: ^29.5.12
|
||||||
version: 29.5.12
|
version: 29.5.12
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^20.11.22
|
specifier: ^20.11.27
|
||||||
version: 20.11.22
|
version: 20.11.27
|
||||||
'@typescript-eslint/eslint-plugin':
|
'@typescript-eslint/eslint-plugin':
|
||||||
specifier: ^7.1.0
|
specifier: ^7.2.0
|
||||||
version: 7.1.0(@typescript-eslint/parser@7.1.0)(eslint@8.57.0)(typescript@5.3.3)
|
version: 7.2.0(@typescript-eslint/parser@7.2.0)(eslint@8.57.0)(typescript@5.4.2)
|
||||||
'@typescript-eslint/parser':
|
'@typescript-eslint/parser':
|
||||||
specifier: ^7.1.0
|
specifier: ^7.2.0
|
||||||
version: 7.1.0(eslint@8.57.0)(typescript@5.3.3)
|
version: 7.2.0(eslint@8.57.0)(typescript@5.4.2)
|
||||||
download-file-sync:
|
download-file-sync:
|
||||||
specifier: ^1.0.4
|
specifier: ^1.0.4
|
||||||
version: 1.0.4
|
version: 1.0.4
|
||||||
|
@ -24,23 +24,23 @@ devDependencies:
|
||||||
specifier: ^8.57.0
|
specifier: ^8.57.0
|
||||||
version: 8.57.0
|
version: 8.57.0
|
||||||
eslint-plugin-prettier:
|
eslint-plugin-prettier:
|
||||||
specifier: ^5.0.1
|
specifier: ^5.1.3
|
||||||
version: 5.1.3(eslint@8.57.0)(prettier@3.2.5)
|
version: 5.1.3(eslint@8.57.0)(prettier@3.2.5)
|
||||||
jest:
|
jest:
|
||||||
specifier: ^29.5.0
|
specifier: ^29.5.0
|
||||||
version: 29.7.0(@types/node@20.11.22)
|
version: 29.7.0(@types/node@20.11.27)
|
||||||
lemmy-js-client:
|
lemmy-js-client:
|
||||||
specifier: 0.19.4-alpha.6
|
specifier: 0.19.4-alpha.8
|
||||||
version: 0.19.4-alpha.6
|
version: 0.19.4-alpha.8
|
||||||
prettier:
|
prettier:
|
||||||
specifier: ^3.2.5
|
specifier: ^3.2.5
|
||||||
version: 3.2.5
|
version: 3.2.5
|
||||||
ts-jest:
|
ts-jest:
|
||||||
specifier: ^29.1.0
|
specifier: ^29.1.0
|
||||||
version: 29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.3.3)
|
version: 29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.4.2)
|
||||||
typescript:
|
typescript:
|
||||||
specifier: ^5.3.3
|
specifier: ^5.4.2
|
||||||
version: 5.3.3
|
version: 5.4.2
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ packages:
|
||||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
jest-message-util: 29.7.0
|
jest-message-util: 29.7.0
|
||||||
jest-util: 29.7.0
|
jest-util: 29.7.0
|
||||||
|
@ -485,14 +485,14 @@ packages:
|
||||||
'@jest/test-result': 29.7.0
|
'@jest/test-result': 29.7.0
|
||||||
'@jest/transform': 29.7.0
|
'@jest/transform': 29.7.0
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
ansi-escapes: 4.3.2
|
ansi-escapes: 4.3.2
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
ci-info: 3.9.0
|
ci-info: 3.9.0
|
||||||
exit: 0.1.2
|
exit: 0.1.2
|
||||||
graceful-fs: 4.2.11
|
graceful-fs: 4.2.11
|
||||||
jest-changed-files: 29.7.0
|
jest-changed-files: 29.7.0
|
||||||
jest-config: 29.7.0(@types/node@20.11.22)
|
jest-config: 29.7.0(@types/node@20.11.27)
|
||||||
jest-haste-map: 29.7.0
|
jest-haste-map: 29.7.0
|
||||||
jest-message-util: 29.7.0
|
jest-message-util: 29.7.0
|
||||||
jest-regex-util: 29.6.3
|
jest-regex-util: 29.6.3
|
||||||
|
@ -520,7 +520,7 @@ packages:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jest/fake-timers': 29.7.0
|
'@jest/fake-timers': 29.7.0
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
jest-mock: 29.7.0
|
jest-mock: 29.7.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ packages:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@sinonjs/fake-timers': 10.3.0
|
'@sinonjs/fake-timers': 10.3.0
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
jest-message-util: 29.7.0
|
jest-message-util: 29.7.0
|
||||||
jest-mock: 29.7.0
|
jest-mock: 29.7.0
|
||||||
jest-util: 29.7.0
|
jest-util: 29.7.0
|
||||||
|
@ -580,7 +580,7 @@ packages:
|
||||||
'@jest/transform': 29.7.0
|
'@jest/transform': 29.7.0
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@jridgewell/trace-mapping': 0.3.22
|
'@jridgewell/trace-mapping': 0.3.22
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
collect-v8-coverage: 1.0.2
|
collect-v8-coverage: 1.0.2
|
||||||
exit: 0.1.2
|
exit: 0.1.2
|
||||||
|
@ -668,7 +668,7 @@ packages:
|
||||||
'@jest/schemas': 29.6.3
|
'@jest/schemas': 29.6.3
|
||||||
'@types/istanbul-lib-coverage': 2.0.6
|
'@types/istanbul-lib-coverage': 2.0.6
|
||||||
'@types/istanbul-reports': 3.0.4
|
'@types/istanbul-reports': 3.0.4
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
'@types/yargs': 17.0.32
|
'@types/yargs': 17.0.32
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -777,7 +777,7 @@ packages:
|
||||||
/@types/graceful-fs@4.1.9:
|
/@types/graceful-fs@4.1.9:
|
||||||
resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==}
|
resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@types/istanbul-lib-coverage@2.0.6:
|
/@types/istanbul-lib-coverage@2.0.6:
|
||||||
|
@ -807,8 +807,8 @@ packages:
|
||||||
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
|
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@types/node@20.11.22:
|
/@types/node@20.11.27:
|
||||||
resolution: {integrity: sha512-/G+IxWxma6V3E+pqK1tSl2Fo1kl41pK1yeCyDsgkF9WlVAme4j5ISYM2zR11bgLFJGLN5sVK40T4RJNuiZbEjA==}
|
resolution: {integrity: sha512-qyUZfMnCg1KEz57r7pzFtSGt49f6RPkPBis3Vo4PbS7roQEDn22hiHzl/Lo1q4i4hDEgBJmBF/NTNg2XR0HbFg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
undici-types: 5.26.5
|
undici-types: 5.26.5
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -831,8 +831,8 @@ packages:
|
||||||
'@types/yargs-parser': 21.0.3
|
'@types/yargs-parser': 21.0.3
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@typescript-eslint/eslint-plugin@7.1.0(@typescript-eslint/parser@7.1.0)(eslint@8.57.0)(typescript@5.3.3):
|
/@typescript-eslint/eslint-plugin@7.2.0(@typescript-eslint/parser@7.2.0)(eslint@8.57.0)(typescript@5.4.2):
|
||||||
resolution: {integrity: sha512-j6vT/kCulhG5wBmGtstKeiVr1rdXE4nk+DT1k6trYkwlrvW9eOF5ZbgKnd/YR6PcM4uTEXa0h6Fcvf6X7Dxl0w==}
|
resolution: {integrity: sha512-mdekAHOqS9UjlmyF/LSs6AIEvfceV749GFxoBAjwAv0nkevfKHWQFDMcBZWUiIC5ft6ePWivXoS36aKQ0Cy3sw==}
|
||||||
engines: {node: ^16.0.0 || >=18.0.0}
|
engines: {node: ^16.0.0 || >=18.0.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@typescript-eslint/parser': ^7.0.0
|
'@typescript-eslint/parser': ^7.0.0
|
||||||
|
@ -843,25 +843,25 @@ packages:
|
||||||
optional: true
|
optional: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@eslint-community/regexpp': 4.10.0
|
'@eslint-community/regexpp': 4.10.0
|
||||||
'@typescript-eslint/parser': 7.1.0(eslint@8.57.0)(typescript@5.3.3)
|
'@typescript-eslint/parser': 7.2.0(eslint@8.57.0)(typescript@5.4.2)
|
||||||
'@typescript-eslint/scope-manager': 7.1.0
|
'@typescript-eslint/scope-manager': 7.2.0
|
||||||
'@typescript-eslint/type-utils': 7.1.0(eslint@8.57.0)(typescript@5.3.3)
|
'@typescript-eslint/type-utils': 7.2.0(eslint@8.57.0)(typescript@5.4.2)
|
||||||
'@typescript-eslint/utils': 7.1.0(eslint@8.57.0)(typescript@5.3.3)
|
'@typescript-eslint/utils': 7.2.0(eslint@8.57.0)(typescript@5.4.2)
|
||||||
'@typescript-eslint/visitor-keys': 7.1.0
|
'@typescript-eslint/visitor-keys': 7.2.0
|
||||||
debug: 4.3.4
|
debug: 4.3.4
|
||||||
eslint: 8.57.0
|
eslint: 8.57.0
|
||||||
graphemer: 1.4.0
|
graphemer: 1.4.0
|
||||||
ignore: 5.3.1
|
ignore: 5.3.1
|
||||||
natural-compare: 1.4.0
|
natural-compare: 1.4.0
|
||||||
semver: 7.6.0
|
semver: 7.6.0
|
||||||
ts-api-utils: 1.2.1(typescript@5.3.3)
|
ts-api-utils: 1.3.0(typescript@5.4.2)
|
||||||
typescript: 5.3.3
|
typescript: 5.4.2
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3):
|
/@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.4.2):
|
||||||
resolution: {integrity: sha512-V1EknKUubZ1gWFjiOZhDSNToOjs63/9O0puCgGS8aDOgpZY326fzFu15QAUjwaXzRZjf/qdsdBrckYdv9YxB8w==}
|
resolution: {integrity: sha512-5FKsVcHTk6TafQKQbuIVkXq58Fnbkd2wDL4LB7AURN7RUOu1utVP+G8+6u3ZhEroW3DF6hyo3ZEXxgKgp4KeCg==}
|
||||||
engines: {node: ^16.0.0 || >=18.0.0}
|
engines: {node: ^16.0.0 || >=18.0.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
eslint: ^8.56.0
|
eslint: ^8.56.0
|
||||||
|
@ -870,27 +870,27 @@ packages:
|
||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/scope-manager': 7.1.0
|
'@typescript-eslint/scope-manager': 7.2.0
|
||||||
'@typescript-eslint/types': 7.1.0
|
'@typescript-eslint/types': 7.2.0
|
||||||
'@typescript-eslint/typescript-estree': 7.1.0(typescript@5.3.3)
|
'@typescript-eslint/typescript-estree': 7.2.0(typescript@5.4.2)
|
||||||
'@typescript-eslint/visitor-keys': 7.1.0
|
'@typescript-eslint/visitor-keys': 7.2.0
|
||||||
debug: 4.3.4
|
debug: 4.3.4
|
||||||
eslint: 8.57.0
|
eslint: 8.57.0
|
||||||
typescript: 5.3.3
|
typescript: 5.4.2
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@typescript-eslint/scope-manager@7.1.0:
|
/@typescript-eslint/scope-manager@7.2.0:
|
||||||
resolution: {integrity: sha512-6TmN4OJiohHfoOdGZ3huuLhpiUgOGTpgXNUPJgeZOZR3DnIpdSgtt83RS35OYNNXxM4TScVlpVKC9jyQSETR1A==}
|
resolution: {integrity: sha512-Qh976RbQM/fYtjx9hs4XkayYujB/aPwglw2choHmf3zBjB4qOywWSdt9+KLRdHubGcoSwBnXUH2sR3hkyaERRg==}
|
||||||
engines: {node: ^16.0.0 || >=18.0.0}
|
engines: {node: ^16.0.0 || >=18.0.0}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/types': 7.1.0
|
'@typescript-eslint/types': 7.2.0
|
||||||
'@typescript-eslint/visitor-keys': 7.1.0
|
'@typescript-eslint/visitor-keys': 7.2.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@typescript-eslint/type-utils@7.1.0(eslint@8.57.0)(typescript@5.3.3):
|
/@typescript-eslint/type-utils@7.2.0(eslint@8.57.0)(typescript@5.4.2):
|
||||||
resolution: {integrity: sha512-UZIhv8G+5b5skkcuhgvxYWHjk7FW7/JP5lPASMEUoliAPwIH/rxoUSQPia2cuOj9AmDZmwUl1usKm85t5VUMew==}
|
resolution: {integrity: sha512-xHi51adBHo9O9330J8GQYQwrKBqbIPJGZZVQTHHmy200hvkLZFWJIFtAG/7IYTWUyun6DE6w5InDReePJYJlJA==}
|
||||||
engines: {node: ^16.0.0 || >=18.0.0}
|
engines: {node: ^16.0.0 || >=18.0.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
eslint: ^8.56.0
|
eslint: ^8.56.0
|
||||||
|
@ -899,23 +899,23 @@ packages:
|
||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/typescript-estree': 7.1.0(typescript@5.3.3)
|
'@typescript-eslint/typescript-estree': 7.2.0(typescript@5.4.2)
|
||||||
'@typescript-eslint/utils': 7.1.0(eslint@8.57.0)(typescript@5.3.3)
|
'@typescript-eslint/utils': 7.2.0(eslint@8.57.0)(typescript@5.4.2)
|
||||||
debug: 4.3.4
|
debug: 4.3.4
|
||||||
eslint: 8.57.0
|
eslint: 8.57.0
|
||||||
ts-api-utils: 1.2.1(typescript@5.3.3)
|
ts-api-utils: 1.3.0(typescript@5.4.2)
|
||||||
typescript: 5.3.3
|
typescript: 5.4.2
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@typescript-eslint/types@7.1.0:
|
/@typescript-eslint/types@7.2.0:
|
||||||
resolution: {integrity: sha512-qTWjWieJ1tRJkxgZYXx6WUYtWlBc48YRxgY2JN1aGeVpkhmnopq+SUC8UEVGNXIvWH7XyuTjwALfG6bFEgCkQA==}
|
resolution: {integrity: sha512-XFtUHPI/abFhm4cbCDc5Ykc8npOKBSJePY3a3s+lwumt7XWJuzP5cZcfZ610MIPHjQjNsOLlYK8ASPaNG8UiyA==}
|
||||||
engines: {node: ^16.0.0 || >=18.0.0}
|
engines: {node: ^16.0.0 || >=18.0.0}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@typescript-eslint/typescript-estree@7.1.0(typescript@5.3.3):
|
/@typescript-eslint/typescript-estree@7.2.0(typescript@5.4.2):
|
||||||
resolution: {integrity: sha512-k7MyrbD6E463CBbSpcOnwa8oXRdHzH1WiVzOipK3L5KSML92ZKgUBrTlehdi7PEIMT8k0bQixHUGXggPAlKnOQ==}
|
resolution: {integrity: sha512-cyxS5WQQCoBwSakpMrvMXuMDEbhOo9bNHHrNcEWis6XHx6KF518tkF1wBvKIn/tpq5ZpUYK7Bdklu8qY0MsFIA==}
|
||||||
engines: {node: ^16.0.0 || >=18.0.0}
|
engines: {node: ^16.0.0 || >=18.0.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
typescript: '*'
|
typescript: '*'
|
||||||
|
@ -923,21 +923,21 @@ packages:
|
||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/types': 7.1.0
|
'@typescript-eslint/types': 7.2.0
|
||||||
'@typescript-eslint/visitor-keys': 7.1.0
|
'@typescript-eslint/visitor-keys': 7.2.0
|
||||||
debug: 4.3.4
|
debug: 4.3.4
|
||||||
globby: 11.1.0
|
globby: 11.1.0
|
||||||
is-glob: 4.0.3
|
is-glob: 4.0.3
|
||||||
minimatch: 9.0.3
|
minimatch: 9.0.3
|
||||||
semver: 7.6.0
|
semver: 7.6.0
|
||||||
ts-api-utils: 1.2.1(typescript@5.3.3)
|
ts-api-utils: 1.3.0(typescript@5.4.2)
|
||||||
typescript: 5.3.3
|
typescript: 5.4.2
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@typescript-eslint/utils@7.1.0(eslint@8.57.0)(typescript@5.3.3):
|
/@typescript-eslint/utils@7.2.0(eslint@8.57.0)(typescript@5.4.2):
|
||||||
resolution: {integrity: sha512-WUFba6PZC5OCGEmbweGpnNJytJiLG7ZvDBJJoUcX4qZYf1mGZ97mO2Mps6O2efxJcJdRNpqweCistDbZMwIVHw==}
|
resolution: {integrity: sha512-YfHpnMAGb1Eekpm3XRK8hcMwGLGsnT6L+7b2XyRv6ouDuJU1tZir1GS2i0+VXRatMwSI1/UfcyPe53ADkU+IuA==}
|
||||||
engines: {node: ^16.0.0 || >=18.0.0}
|
engines: {node: ^16.0.0 || >=18.0.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
eslint: ^8.56.0
|
eslint: ^8.56.0
|
||||||
|
@ -945,9 +945,9 @@ packages:
|
||||||
'@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0)
|
'@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0)
|
||||||
'@types/json-schema': 7.0.15
|
'@types/json-schema': 7.0.15
|
||||||
'@types/semver': 7.5.8
|
'@types/semver': 7.5.8
|
||||||
'@typescript-eslint/scope-manager': 7.1.0
|
'@typescript-eslint/scope-manager': 7.2.0
|
||||||
'@typescript-eslint/types': 7.1.0
|
'@typescript-eslint/types': 7.2.0
|
||||||
'@typescript-eslint/typescript-estree': 7.1.0(typescript@5.3.3)
|
'@typescript-eslint/typescript-estree': 7.2.0(typescript@5.4.2)
|
||||||
eslint: 8.57.0
|
eslint: 8.57.0
|
||||||
semver: 7.6.0
|
semver: 7.6.0
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
@ -955,11 +955,11 @@ packages:
|
||||||
- typescript
|
- typescript
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@typescript-eslint/visitor-keys@7.1.0:
|
/@typescript-eslint/visitor-keys@7.2.0:
|
||||||
resolution: {integrity: sha512-FhUqNWluiGNzlvnDZiXad4mZRhtghdoKW6e98GoEOYSu5cND+E39rG5KwJMUzeENwm1ztYBRqof8wMLP+wNPIA==}
|
resolution: {integrity: sha512-c6EIQRHhcpl6+tO8EMR+kjkkV+ugUNXOmeASA1rlzkd8EPIriavpWoiEz1HR/VLhbVIdhqnV6E7JZm00cBDx2A==}
|
||||||
engines: {node: ^16.0.0 || >=18.0.0}
|
engines: {node: ^16.0.0 || >=18.0.0}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/types': 7.1.0
|
'@typescript-eslint/types': 7.2.0
|
||||||
eslint-visitor-keys: 3.4.3
|
eslint-visitor-keys: 3.4.3
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
@ -1276,7 +1276,7 @@ packages:
|
||||||
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
|
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/create-jest@29.7.0(@types/node@20.11.22):
|
/create-jest@29.7.0(@types/node@20.11.27):
|
||||||
resolution: {integrity: sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==}
|
resolution: {integrity: sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==}
|
||||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
@ -1285,7 +1285,7 @@ packages:
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
exit: 0.1.2
|
exit: 0.1.2
|
||||||
graceful-fs: 4.2.11
|
graceful-fs: 4.2.11
|
||||||
jest-config: 29.7.0(@types/node@20.11.22)
|
jest-config: 29.7.0(@types/node@20.11.27)
|
||||||
jest-util: 29.7.0
|
jest-util: 29.7.0
|
||||||
prompts: 2.4.2
|
prompts: 2.4.2
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
@ -1939,7 +1939,7 @@ packages:
|
||||||
'@jest/expect': 29.7.0
|
'@jest/expect': 29.7.0
|
||||||
'@jest/test-result': 29.7.0
|
'@jest/test-result': 29.7.0
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
co: 4.6.0
|
co: 4.6.0
|
||||||
dedent: 1.5.1
|
dedent: 1.5.1
|
||||||
|
@ -1960,7 +1960,7 @@ packages:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/jest-cli@29.7.0(@types/node@20.11.22):
|
/jest-cli@29.7.0(@types/node@20.11.27):
|
||||||
resolution: {integrity: sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==}
|
resolution: {integrity: sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==}
|
||||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
@ -1974,10 +1974,10 @@ packages:
|
||||||
'@jest/test-result': 29.7.0
|
'@jest/test-result': 29.7.0
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
create-jest: 29.7.0(@types/node@20.11.22)
|
create-jest: 29.7.0(@types/node@20.11.27)
|
||||||
exit: 0.1.2
|
exit: 0.1.2
|
||||||
import-local: 3.1.0
|
import-local: 3.1.0
|
||||||
jest-config: 29.7.0(@types/node@20.11.22)
|
jest-config: 29.7.0(@types/node@20.11.27)
|
||||||
jest-util: 29.7.0
|
jest-util: 29.7.0
|
||||||
jest-validate: 29.7.0
|
jest-validate: 29.7.0
|
||||||
yargs: 17.7.2
|
yargs: 17.7.2
|
||||||
|
@ -1988,7 +1988,7 @@ packages:
|
||||||
- ts-node
|
- ts-node
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/jest-config@29.7.0(@types/node@20.11.22):
|
/jest-config@29.7.0(@types/node@20.11.27):
|
||||||
resolution: {integrity: sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==}
|
resolution: {integrity: sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==}
|
||||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
@ -2003,7 +2003,7 @@ packages:
|
||||||
'@babel/core': 7.23.9
|
'@babel/core': 7.23.9
|
||||||
'@jest/test-sequencer': 29.7.0
|
'@jest/test-sequencer': 29.7.0
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
babel-jest: 29.7.0(@babel/core@7.23.9)
|
babel-jest: 29.7.0(@babel/core@7.23.9)
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
ci-info: 3.9.0
|
ci-info: 3.9.0
|
||||||
|
@ -2063,7 +2063,7 @@ packages:
|
||||||
'@jest/environment': 29.7.0
|
'@jest/environment': 29.7.0
|
||||||
'@jest/fake-timers': 29.7.0
|
'@jest/fake-timers': 29.7.0
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
jest-mock: 29.7.0
|
jest-mock: 29.7.0
|
||||||
jest-util: 29.7.0
|
jest-util: 29.7.0
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -2079,7 +2079,7 @@ packages:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/graceful-fs': 4.1.9
|
'@types/graceful-fs': 4.1.9
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
anymatch: 3.1.3
|
anymatch: 3.1.3
|
||||||
fb-watchman: 2.0.2
|
fb-watchman: 2.0.2
|
||||||
graceful-fs: 4.2.11
|
graceful-fs: 4.2.11
|
||||||
|
@ -2130,7 +2130,7 @@ packages:
|
||||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
jest-util: 29.7.0
|
jest-util: 29.7.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
@ -2185,7 +2185,7 @@ packages:
|
||||||
'@jest/test-result': 29.7.0
|
'@jest/test-result': 29.7.0
|
||||||
'@jest/transform': 29.7.0
|
'@jest/transform': 29.7.0
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
emittery: 0.13.1
|
emittery: 0.13.1
|
||||||
graceful-fs: 4.2.11
|
graceful-fs: 4.2.11
|
||||||
|
@ -2216,7 +2216,7 @@ packages:
|
||||||
'@jest/test-result': 29.7.0
|
'@jest/test-result': 29.7.0
|
||||||
'@jest/transform': 29.7.0
|
'@jest/transform': 29.7.0
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
cjs-module-lexer: 1.2.3
|
cjs-module-lexer: 1.2.3
|
||||||
collect-v8-coverage: 1.0.2
|
collect-v8-coverage: 1.0.2
|
||||||
|
@ -2268,7 +2268,7 @@ packages:
|
||||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
ci-info: 3.9.0
|
ci-info: 3.9.0
|
||||||
graceful-fs: 4.2.11
|
graceful-fs: 4.2.11
|
||||||
|
@ -2293,7 +2293,7 @@ packages:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jest/test-result': 29.7.0
|
'@jest/test-result': 29.7.0
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
ansi-escapes: 4.3.2
|
ansi-escapes: 4.3.2
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
emittery: 0.13.1
|
emittery: 0.13.1
|
||||||
|
@ -2305,13 +2305,13 @@ packages:
|
||||||
resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==}
|
resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==}
|
||||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 20.11.22
|
'@types/node': 20.11.27
|
||||||
jest-util: 29.7.0
|
jest-util: 29.7.0
|
||||||
merge-stream: 2.0.0
|
merge-stream: 2.0.0
|
||||||
supports-color: 8.1.1
|
supports-color: 8.1.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/jest@29.7.0(@types/node@20.11.22):
|
/jest@29.7.0(@types/node@20.11.27):
|
||||||
resolution: {integrity: sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==}
|
resolution: {integrity: sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==}
|
||||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
@ -2324,7 +2324,7 @@ packages:
|
||||||
'@jest/core': 29.7.0
|
'@jest/core': 29.7.0
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
import-local: 3.1.0
|
import-local: 3.1.0
|
||||||
jest-cli: 29.7.0(@types/node@20.11.22)
|
jest-cli: 29.7.0(@types/node@20.11.27)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@types/node'
|
- '@types/node'
|
||||||
- babel-plugin-macros
|
- babel-plugin-macros
|
||||||
|
@ -2390,8 +2390,8 @@ packages:
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/lemmy-js-client@0.19.4-alpha.6:
|
/lemmy-js-client@0.19.4-alpha.8:
|
||||||
resolution: {integrity: sha512-x4htMlpoZ7hzrhrIk82aompVxbpu2ZDWtmWNGraM0+27nUCDf6gYxJH5nb5R/o39BQe5KSHq6zoBdliBwAY40w==}
|
resolution: {integrity: sha512-8vjqUYVOhyUTcmG9FvPLjrWziVwNa2/Zi+kSflTrajJsK0V+5DclJ5dhdVMUQ4DEA70gb0OuNMDlipPG2FoS5A==}
|
||||||
dependencies:
|
dependencies:
|
||||||
cross-fetch: 4.0.0
|
cross-fetch: 4.0.0
|
||||||
form-data: 4.0.0
|
form-data: 4.0.0
|
||||||
|
@ -2956,16 +2956,16 @@ packages:
|
||||||
resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==}
|
resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/ts-api-utils@1.2.1(typescript@5.3.3):
|
/ts-api-utils@1.3.0(typescript@5.4.2):
|
||||||
resolution: {integrity: sha512-RIYA36cJn2WiH9Hy77hdF9r7oEwxAtB/TS9/S4Qd90Ap4z5FSiin5zEiTL44OII1Y3IIlEvxwxFUVgrHSZ/UpA==}
|
resolution: {integrity: sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==}
|
||||||
engines: {node: '>=16'}
|
engines: {node: '>=16'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
typescript: '>=4.2.0'
|
typescript: '>=4.2.0'
|
||||||
dependencies:
|
dependencies:
|
||||||
typescript: 5.3.3
|
typescript: 5.4.2
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/ts-jest@29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.3.3):
|
/ts-jest@29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.4.2):
|
||||||
resolution: {integrity: sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==}
|
resolution: {integrity: sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==}
|
||||||
engines: {node: ^16.10.0 || ^18.0.0 || >=20.0.0}
|
engines: {node: ^16.10.0 || ^18.0.0 || >=20.0.0}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
@ -2989,13 +2989,13 @@ packages:
|
||||||
'@babel/core': 7.23.9
|
'@babel/core': 7.23.9
|
||||||
bs-logger: 0.2.6
|
bs-logger: 0.2.6
|
||||||
fast-json-stable-stringify: 2.1.0
|
fast-json-stable-stringify: 2.1.0
|
||||||
jest: 29.7.0(@types/node@20.11.22)
|
jest: 29.7.0(@types/node@20.11.27)
|
||||||
jest-util: 29.7.0
|
jest-util: 29.7.0
|
||||||
json5: 2.2.3
|
json5: 2.2.3
|
||||||
lodash.memoize: 4.1.2
|
lodash.memoize: 4.1.2
|
||||||
make-error: 1.3.6
|
make-error: 1.3.6
|
||||||
semver: 7.5.4
|
semver: 7.5.4
|
||||||
typescript: 5.3.3
|
typescript: 5.4.2
|
||||||
yargs-parser: 21.1.1
|
yargs-parser: 21.1.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
@ -3025,8 +3025,8 @@ packages:
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/typescript@5.3.3:
|
/typescript@5.4.2:
|
||||||
resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==}
|
resolution: {integrity: sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==}
|
||||||
engines: {node: '>=14.17'}
|
engines: {node: '>=14.17'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: true
|
dev: true
|
||||||
|
|
|
@ -18,6 +18,7 @@ import {
|
||||||
resolveBetaCommunity,
|
resolveBetaCommunity,
|
||||||
createComment,
|
createComment,
|
||||||
deletePost,
|
deletePost,
|
||||||
|
delay,
|
||||||
removePost,
|
removePost,
|
||||||
getPost,
|
getPost,
|
||||||
unfollowRemotes,
|
unfollowRemotes,
|
||||||
|
@ -219,9 +220,10 @@ test("Sticky a post", async () => {
|
||||||
if (!gammaPost) {
|
if (!gammaPost) {
|
||||||
throw "Missing gamma post";
|
throw "Missing gamma post";
|
||||||
}
|
}
|
||||||
let gammaTrySticky = await featurePost(gamma, true, gammaPost.post);
|
// This has been failing occasionally
|
||||||
|
await featurePost(gamma, true, gammaPost.post);
|
||||||
let betaPost3 = (await resolvePost(beta, postRes.post_view.post)).post;
|
let betaPost3 = (await resolvePost(beta, postRes.post_view.post)).post;
|
||||||
expect(gammaTrySticky.post_view.post.featured_community).toBe(true);
|
// expect(gammaTrySticky.post_view.post.featured_community).toBe(true);
|
||||||
expect(betaPost3?.post.featured_community).toBe(false);
|
expect(betaPost3?.post.featured_community).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -710,3 +712,25 @@ test("Fetch post via redirect", async () => {
|
||||||
expect(gammaPost.post?.post.ap_id).toBe(alphaPost.post_view.post.ap_id);
|
expect(gammaPost.post?.post.ap_id).toBe(alphaPost.post_view.post.ap_id);
|
||||||
await unfollowRemotes(alpha);
|
await unfollowRemotes(alpha);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Block post that contains banned URL", async () => {
|
||||||
|
let editSiteForm: EditSite = {
|
||||||
|
blocked_urls: ["https://evil.com/"],
|
||||||
|
};
|
||||||
|
|
||||||
|
await epsilon.editSite(editSiteForm);
|
||||||
|
|
||||||
|
await delay(500);
|
||||||
|
|
||||||
|
if (!betaCommunity) {
|
||||||
|
throw "Missing beta community";
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(
|
||||||
|
createPost(epsilon, betaCommunity.community.id, "https://evil.com"),
|
||||||
|
).rejects.toStrictEqual(Error("blocked_url"));
|
||||||
|
|
||||||
|
// Later tests need this to be empty
|
||||||
|
editSiteForm.blocked_urls = [];
|
||||||
|
await epsilon.editSite(editSiteForm);
|
||||||
|
});
|
||||||
|
|
|
@ -45,7 +45,7 @@ test("Create user", async () => {
|
||||||
if (!site.my_user) {
|
if (!site.my_user) {
|
||||||
throw "Missing site user";
|
throw "Missing site user";
|
||||||
}
|
}
|
||||||
apShortname = `@${site.my_user.local_user_view.person.name}@lemmy-alpha:8541`;
|
apShortname = `${site.my_user.local_user_view.person.name}@lemmy-alpha:8541`;
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Set some user settings, check that they are federated", async () => {
|
test("Set some user settings, check that they are federated", async () => {
|
||||||
|
@ -68,7 +68,7 @@ test("Delete user", async () => {
|
||||||
let user = await registerUser(alpha, alphaUrl);
|
let user = await registerUser(alpha, alphaUrl);
|
||||||
|
|
||||||
// make a local post and comment
|
// make a local post and comment
|
||||||
let alphaCommunity = (await resolveCommunity(user, "!main@lemmy-alpha:8541"))
|
let alphaCommunity = (await resolveCommunity(user, "main@lemmy-alpha:8541"))
|
||||||
.community;
|
.community;
|
||||||
if (!alphaCommunity) {
|
if (!alphaCommunity) {
|
||||||
throw "Missing alpha community";
|
throw "Missing alpha community";
|
||||||
|
@ -134,8 +134,28 @@ test("Create user with Arabic name", async () => {
|
||||||
if (!site.my_user) {
|
if (!site.my_user) {
|
||||||
throw "Missing site user";
|
throw "Missing site user";
|
||||||
}
|
}
|
||||||
apShortname = `@${site.my_user.local_user_view.person.name}@lemmy-alpha:8541`;
|
apShortname = `${site.my_user.local_user_view.person.name}@lemmy-alpha:8541`;
|
||||||
|
|
||||||
let alphaPerson = (await resolvePerson(alpha, apShortname)).person;
|
let alphaPerson = (await resolvePerson(alpha, apShortname)).person;
|
||||||
expect(alphaPerson).toBeDefined();
|
expect(alphaPerson).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Create user with accept-language", async () => {
|
||||||
|
let lemmy_http = new LemmyHttp(alphaUrl, {
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language#syntax
|
||||||
|
headers: { "Accept-Language": "fr-CH, en;q=0.8, de;q=0.7, *;q=0.5" },
|
||||||
|
});
|
||||||
|
let user = await registerUser(lemmy_http, alphaUrl);
|
||||||
|
|
||||||
|
let site = await getSite(user);
|
||||||
|
expect(site.my_user).toBeDefined();
|
||||||
|
expect(site.my_user?.local_user_view.local_user.interface_language).toBe(
|
||||||
|
"fr",
|
||||||
|
);
|
||||||
|
let langs = site.all_languages
|
||||||
|
.filter(a => site.my_user?.discussion_languages.includes(a.id))
|
||||||
|
.map(l => l.code);
|
||||||
|
// should have languages from accept header, as well as "undetermined"
|
||||||
|
// which is automatically enabled by backend
|
||||||
|
expect(langs).toStrictEqual(["und", "de", "en", "fr"]);
|
||||||
|
});
|
||||||
|
|
86
cliff.toml
Normal file
86
cliff.toml
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
# git-cliff ~ configuration file
|
||||||
|
# https://git-cliff.org/docs/configuration
|
||||||
|
|
||||||
|
[remote.github]
|
||||||
|
owner = "LemmyNet"
|
||||||
|
repo = "lemmy"
|
||||||
|
# token = ""
|
||||||
|
|
||||||
|
[changelog]
|
||||||
|
# template for the changelog body
|
||||||
|
# https://keats.github.io/tera/docs/#introduction
|
||||||
|
body = """
|
||||||
|
## What's Changed
|
||||||
|
|
||||||
|
{%- if version %} in {{ version }}{%- endif -%}
|
||||||
|
{% for commit in commits %}
|
||||||
|
{% if commit.github.pr_title -%}
|
||||||
|
{%- set commit_message = commit.github.pr_title -%}
|
||||||
|
{%- else -%}
|
||||||
|
{%- set commit_message = commit.message -%}
|
||||||
|
{%- endif -%}
|
||||||
|
* {{ commit_message | split(pat="\n") | first | trim }}\
|
||||||
|
{% if commit.github.username %} by @{{ commit.github.username }}{%- endif -%}
|
||||||
|
{% if commit.github.pr_number %} in \
|
||||||
|
[#{{ commit.github.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.github.pr_number }}) \
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor -%}
|
||||||
|
|
||||||
|
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
|
||||||
|
{% raw %}\n{% endraw -%}
|
||||||
|
## New Contributors
|
||||||
|
{%- endif %}\
|
||||||
|
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
|
||||||
|
* @{{ contributor.username }} made their first contribution
|
||||||
|
{%- if contributor.pr_number %} in \
|
||||||
|
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor -%}
|
||||||
|
|
||||||
|
{% if version %}
|
||||||
|
{% if previous.version %}
|
||||||
|
**Full Changelog**: {{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}
|
||||||
|
{% endif %}
|
||||||
|
{% else -%}
|
||||||
|
{% raw %}\n{% endraw %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- macro remote_url() -%}
|
||||||
|
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
|
||||||
|
{%- endmacro -%}
|
||||||
|
"""
|
||||||
|
# remove the leading and trailing whitespace from the template
|
||||||
|
trim = true
|
||||||
|
# changelog footer
|
||||||
|
footer = """
|
||||||
|
<!-- generated by git-cliff -->
|
||||||
|
"""
|
||||||
|
# postprocessors
|
||||||
|
postprocessors = []
|
||||||
|
|
||||||
|
[git]
|
||||||
|
# parse the commits based on https://www.conventionalcommits.org
|
||||||
|
conventional_commits = false
|
||||||
|
# filter out the commits that are not conventional
|
||||||
|
filter_unconventional = true
|
||||||
|
# process each line of a commit as an individual commit
|
||||||
|
split_commits = false
|
||||||
|
# regex for preprocessing the commit messages
|
||||||
|
commit_preprocessors = [
|
||||||
|
# remove issue numbers from commits
|
||||||
|
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" },
|
||||||
|
]
|
||||||
|
# protect breaking changes from being skipped due to matching a skipping commit_parser
|
||||||
|
protect_breaking_commits = false
|
||||||
|
# filter out the commits that are not matched by commit parsers
|
||||||
|
filter_commits = false
|
||||||
|
# regex for matching git tags
|
||||||
|
tag_pattern = "[0-9].*"
|
||||||
|
# regex for skipping tags
|
||||||
|
skip_tags = "beta|alpha"
|
||||||
|
# regex for ignoring tags
|
||||||
|
ignore_tags = "rc"
|
||||||
|
# sort the tags topologically
|
||||||
|
topo_order = false
|
||||||
|
# sort the commits inside sections by oldest/newest order
|
||||||
|
sort_commits = "newest"
|
|
@ -34,7 +34,7 @@ tracing = { workspace = true }
|
||||||
chrono = { workspace = true }
|
chrono = { workspace = true }
|
||||||
url = { workspace = true }
|
url = { workspace = true }
|
||||||
wav = "1.0.0"
|
wav = "1.0.0"
|
||||||
sitemap-rs = "0.2.0"
|
sitemap-rs = "0.2.1"
|
||||||
totp-rs = { version = "5.5.1", features = ["gen_secret", "otpauth"] }
|
totp-rs = { version = "5.5.1", features = ["gen_secret", "otpauth"] }
|
||||||
actix-web-httpauth = "0.8.1"
|
actix-web-httpauth = "0.8.1"
|
||||||
|
|
||||||
|
|
|
@ -135,11 +135,7 @@ pub(crate) fn generate_totp_2fa_secret() -> String {
|
||||||
Secret::generate_secret().to_string()
|
Secret::generate_secret().to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn build_totp_2fa(
|
fn build_totp_2fa(hostname: &str, username: &str, secret: &str) -> Result<TOTP, LemmyError> {
|
||||||
site_name: &str,
|
|
||||||
username: &str,
|
|
||||||
secret: &str,
|
|
||||||
) -> Result<TOTP, LemmyError> {
|
|
||||||
let sec = Secret::Raw(secret.as_bytes().to_vec());
|
let sec = Secret::Raw(secret.as_bytes().to_vec());
|
||||||
let sec_bytes = sec
|
let sec_bytes = sec
|
||||||
.to_bytes()
|
.to_bytes()
|
||||||
|
@ -151,7 +147,7 @@ pub(crate) fn build_totp_2fa(
|
||||||
1,
|
1,
|
||||||
30,
|
30,
|
||||||
sec_bytes,
|
sec_bytes,
|
||||||
Some(site_name.to_string()),
|
Some(hostname.to_string()),
|
||||||
username.to_string(),
|
username.to_string(),
|
||||||
)
|
)
|
||||||
.with_lemmy_type(LemmyErrorType::CouldntGenerateTotp)
|
.with_lemmy_type(LemmyErrorType::CouldntGenerateTotp)
|
||||||
|
@ -263,16 +259,16 @@ pub async fn local_user_view_from_jwt(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_build_totp() {
|
fn test_build_totp() {
|
||||||
let generated_secret = generate_totp_2fa_secret();
|
let generated_secret = generate_totp_2fa_secret();
|
||||||
let totp = build_totp_2fa("lemmy", "my_name", &generated_secret);
|
let totp = build_totp_2fa("lemmy.ml", "my_name", &generated_secret);
|
||||||
assert!(totp.is_ok());
|
assert!(totp.is_ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,7 @@ use lemmy_api_common::{
|
||||||
person::GenerateTotpSecretResponse,
|
person::GenerateTotpSecretResponse,
|
||||||
sensitive::Sensitive,
|
sensitive::Sensitive,
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::source::local_user::{LocalUser, LocalUserUpdateForm};
|
||||||
source::local_user::{LocalUser, LocalUserUpdateForm},
|
|
||||||
traits::Crud,
|
|
||||||
};
|
|
||||||
use lemmy_db_views::structs::{LocalUserView, SiteView};
|
use lemmy_db_views::structs::{LocalUserView, SiteView};
|
||||||
use lemmy_utils::error::{LemmyError, LemmyErrorType};
|
use lemmy_utils::error::{LemmyError, LemmyErrorType};
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,11 @@ pub async fn login(
|
||||||
|
|
||||||
// Check the totp if enabled
|
// Check the totp if enabled
|
||||||
if local_user_view.local_user.totp_2fa_enabled {
|
if local_user_view.local_user.totp_2fa_enabled {
|
||||||
check_totp_2fa_valid(&local_user_view, &data.totp_2fa_token, &site_view.site.name)?;
|
check_totp_2fa_valid(
|
||||||
|
&local_user_view,
|
||||||
|
&data.totp_2fa_token,
|
||||||
|
&context.settings().hostname,
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let jwt = Claims::generate(local_user_view.local_user.id, req, &context).await?;
|
let jwt = Claims::generate(local_user_view.local_user.id, req, &context).await?;
|
||||||
|
|
|
@ -3,6 +3,7 @@ use lemmy_api_common::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
person::SaveUserSettings,
|
person::SaveUserSettings,
|
||||||
utils::{
|
utils::{
|
||||||
|
get_url_blocklist,
|
||||||
local_site_to_slur_regex,
|
local_site_to_slur_regex,
|
||||||
process_markdown_opt,
|
process_markdown_opt,
|
||||||
proxy_image_link_opt_api,
|
proxy_image_link_opt_api,
|
||||||
|
@ -14,6 +15,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
actor_language::LocalUserLanguage,
|
actor_language::LocalUserLanguage,
|
||||||
local_user::{LocalUser, LocalUserUpdateForm},
|
local_user::{LocalUser, LocalUserUpdateForm},
|
||||||
|
local_user_vote_display_mode::{LocalUserVoteDisplayMode, LocalUserVoteDisplayModeUpdateForm},
|
||||||
person::{Person, PersonUpdateForm},
|
person::{Person, PersonUpdateForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
|
@ -34,7 +36,10 @@ pub async fn save_user_settings(
|
||||||
let site_view = SiteView::read_local(&mut context.pool()).await?;
|
let site_view = SiteView::read_local(&mut context.pool()).await?;
|
||||||
|
|
||||||
let slur_regex = local_site_to_slur_regex(&site_view.local_site);
|
let slur_regex = local_site_to_slur_regex(&site_view.local_site);
|
||||||
let bio = diesel_option_overwrite(process_markdown_opt(&data.bio, &slur_regex, &context).await?);
|
let url_blocklist = get_url_blocklist(&context).await?;
|
||||||
|
let bio = diesel_option_overwrite(
|
||||||
|
process_markdown_opt(&data.bio, &slur_regex, &url_blocklist, &context).await?,
|
||||||
|
);
|
||||||
|
|
||||||
let avatar = proxy_image_link_opt_api(&data.avatar, &context).await?;
|
let avatar = proxy_image_link_opt_api(&data.avatar, &context).await?;
|
||||||
let banner = proxy_image_link_opt_api(&data.banner, &context).await?;
|
let banner = proxy_image_link_opt_api(&data.banner, &context).await?;
|
||||||
|
@ -136,5 +141,15 @@ pub async fn save_user_settings(
|
||||||
.await
|
.await
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
|
// Update the vote display modes
|
||||||
|
let vote_display_modes_form = LocalUserVoteDisplayModeUpdateForm {
|
||||||
|
score: data.show_scores,
|
||||||
|
upvotes: data.show_upvotes,
|
||||||
|
downvotes: data.show_downvotes,
|
||||||
|
upvote_percentage: data.show_upvote_percentage,
|
||||||
|
};
|
||||||
|
LocalUserVoteDisplayMode::update(&mut context.pool(), local_user_id, &vote_display_modes_form)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(Json(SuccessResponse::default()))
|
Ok(Json(SuccessResponse::default()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,8 @@ use lemmy_api_common::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
person::{UpdateTotp, UpdateTotpResponse},
|
person::{UpdateTotp, UpdateTotpResponse},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::source::local_user::{LocalUser, LocalUserUpdateForm};
|
||||||
source::local_user::{LocalUser, LocalUserUpdateForm},
|
use lemmy_db_views::structs::LocalUserView;
|
||||||
traits::Crud,
|
|
||||||
};
|
|
||||||
use lemmy_db_views::structs::{LocalUserView, SiteView};
|
|
||||||
use lemmy_utils::error::LemmyError;
|
use lemmy_utils::error::LemmyError;
|
||||||
|
|
||||||
/// Enable or disable two-factor-authentication. The current setting is determined from
|
/// Enable or disable two-factor-authentication. The current setting is determined from
|
||||||
|
@ -25,12 +22,10 @@ pub async fn update_totp(
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
) -> Result<Json<UpdateTotpResponse>, LemmyError> {
|
) -> Result<Json<UpdateTotpResponse>, LemmyError> {
|
||||||
let site_view = SiteView::read_local(&mut context.pool()).await?;
|
|
||||||
|
|
||||||
check_totp_2fa_valid(
|
check_totp_2fa_valid(
|
||||||
&local_user_view,
|
&local_user_view,
|
||||||
&Some(data.totp_token.clone()),
|
&Some(data.totp_token.clone()),
|
||||||
&site_view.site.name,
|
&context.settings().hostname,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// toggle the 2fa setting
|
// toggle the 2fa setting
|
||||||
|
|
|
@ -4,6 +4,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
actor_language::SiteLanguage,
|
actor_language::SiteLanguage,
|
||||||
language::Language,
|
language::Language,
|
||||||
|
local_site_url_blocklist::LocalSiteUrlBlocklist,
|
||||||
local_user::{LocalUser, LocalUserUpdateForm},
|
local_user::{LocalUser, LocalUserUpdateForm},
|
||||||
moderator::{ModAdd, ModAddForm},
|
moderator::{ModAdd, ModAddForm},
|
||||||
tagline::Tagline,
|
tagline::Tagline,
|
||||||
|
@ -62,6 +63,7 @@ pub async fn leave_admin(
|
||||||
let taglines = Tagline::get_all(&mut context.pool(), site_view.local_site.id).await?;
|
let taglines = Tagline::get_all(&mut context.pool(), site_view.local_site.id).await?;
|
||||||
let custom_emojis =
|
let custom_emojis =
|
||||||
CustomEmojiView::get_all(&mut context.pool(), site_view.local_site.id).await?;
|
CustomEmojiView::get_all(&mut context.pool(), site_view.local_site.id).await?;
|
||||||
|
let blocked_urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?;
|
||||||
|
|
||||||
Ok(Json(GetSiteResponse {
|
Ok(Json(GetSiteResponse {
|
||||||
site_view,
|
site_view,
|
||||||
|
@ -72,5 +74,6 @@ pub async fn leave_admin(
|
||||||
discussion_languages,
|
discussion_languages,
|
||||||
taglines,
|
taglines,
|
||||||
custom_emojis,
|
custom_emojis,
|
||||||
|
blocked_urls,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,8 @@ pub async fn get_sitemap(context: Data<LemmyContext>) -> LemmyResult<HttpRespons
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
pub(crate) mod tests {
|
pub(crate) mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
|
|
||||||
use crate::sitemap::generate_urlset;
|
use crate::sitemap::generate_urlset;
|
||||||
use chrono::{DateTime, NaiveDate, Utc};
|
use chrono::{DateTime, NaiveDate, Utc};
|
||||||
|
|
|
@ -54,17 +54,17 @@ tracing = { workspace = true, optional = true }
|
||||||
reqwest-middleware = { workspace = true, optional = true }
|
reqwest-middleware = { workspace = true, optional = true }
|
||||||
regex = { workspace = true }
|
regex = { workspace = true }
|
||||||
rosetta-i18n = { workspace = true, optional = true }
|
rosetta-i18n = { workspace = true, optional = true }
|
||||||
anyhow = { workspace = true }
|
|
||||||
futures = { workspace = true, optional = true }
|
futures = { workspace = true, optional = true }
|
||||||
uuid = { workspace = true, optional = true }
|
uuid = { workspace = true, optional = true }
|
||||||
tokio = { workspace = true, optional = true }
|
tokio = { workspace = true, optional = true }
|
||||||
reqwest = { workspace = true, optional = true }
|
reqwest = { workspace = true, optional = true }
|
||||||
ts-rs = { workspace = true, optional = true }
|
ts-rs = { workspace = true, optional = true }
|
||||||
|
moka.workspace = true
|
||||||
|
anyhow.workspace = true
|
||||||
once_cell = { workspace = true, optional = true }
|
once_cell = { workspace = true, optional = true }
|
||||||
actix-web = { workspace = true, optional = true }
|
actix-web = { workspace = true, optional = true }
|
||||||
enum-map = { workspace = true }
|
enum-map = { workspace = true }
|
||||||
urlencoding = { workspace = true }
|
urlencoding = { workspace = true }
|
||||||
async-trait = { workspace = true }
|
|
||||||
mime = { version = "0.3.17", optional = true }
|
mime = { version = "0.3.17", optional = true }
|
||||||
webpage = { version = "1.6", default-features = false, features = [
|
webpage = { version = "1.6", default-features = false, features = [
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -73,7 +73,6 @@ encoding = { version = "0.2.33", optional = true }
|
||||||
jsonwebtoken = { version = "8.3.0", optional = true }
|
jsonwebtoken = { version = "8.3.0", optional = true }
|
||||||
# necessary for wasmt compilation
|
# necessary for wasmt compilation
|
||||||
getrandom = { version = "0.2.12", features = ["js"] }
|
getrandom = { version = "0.2.12", features = ["js"] }
|
||||||
task-local-extensions = "0.1.4"
|
|
||||||
|
|
||||||
[package.metadata.cargo-machete]
|
[package.metadata.cargo-machete]
|
||||||
ignored = ["getrandom"]
|
ignored = ["getrandom"]
|
||||||
|
|
|
@ -87,7 +87,7 @@ pub async fn build_post_response(
|
||||||
Ok(Json(PostResponse { post_view }))
|
Ok(Json(PostResponse { post_view }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this function is a mess and should be split up to handle email seperately
|
// TODO: this function is a mess and should be split up to handle email separately
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
pub async fn send_local_notifs(
|
pub async fn send_local_notifs(
|
||||||
mentions: Vec<MentionData>,
|
mentions: Vec<MentionData>,
|
||||||
|
|
|
@ -72,9 +72,9 @@ impl Claims {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{claims::Claims, context::LemmyContext};
|
use crate::{claims::Claims, context::LemmyContext};
|
||||||
use actix_web::test::TestRequest;
|
use actix_web::test::TestRequest;
|
||||||
|
@ -124,7 +124,9 @@ mod tests {
|
||||||
.password_encrypted("123456".to_string())
|
.password_encrypted("123456".to_string())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let inserted_local_user = LocalUser::create(pool, &local_user_form).await.unwrap();
|
let inserted_local_user = LocalUser::create(pool, &local_user_form, vec![])
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let req = TestRequest::default().to_http_request();
|
let req = TestRequest::default().to_http_request();
|
||||||
let jwt = Claims::generate(inserted_local_user.id, req, &context)
|
let jwt = Claims::generate(inserted_local_user.id, req, &context)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::request::client_builder;
|
use crate::request::client_builder;
|
||||||
use activitypub_federation::config::{Data, FederationConfig};
|
use activitypub_federation::config::{Data, FederationConfig};
|
||||||
use anyhow::anyhow;
|
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::secret::Secret,
|
source::secret::Secret,
|
||||||
utils::{build_db_pool_for_tests, ActualDbPool, DbPool},
|
utils::{build_db_pool_for_tests, ActualDbPool, DbPool},
|
||||||
|
@ -9,10 +8,8 @@ use lemmy_utils::{
|
||||||
rate_limit::RateLimitCell,
|
rate_limit::RateLimitCell,
|
||||||
settings::{structs::Settings, SETTINGS},
|
settings::{structs::Settings, SETTINGS},
|
||||||
};
|
};
|
||||||
use reqwest::{Request, Response};
|
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
|
||||||
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware, Middleware, Next};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use task_local_extensions::Extensions;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct LemmyContext {
|
pub struct LemmyContext {
|
||||||
|
@ -55,32 +52,16 @@ impl LemmyContext {
|
||||||
&self.rate_limit_cell
|
&self.rate_limit_cell
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initialize a context for use in tests, optionally blocks network requests.
|
/// Initialize a context for use in tests which blocks federation network calls.
|
||||||
///
|
///
|
||||||
/// Do not use this in production code.
|
/// Do not use this in production code.
|
||||||
pub async fn init_test_context() -> Data<LemmyContext> {
|
pub async fn init_test_context() -> Data<LemmyContext> {
|
||||||
Self::build_test_context(true).await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Initialize a context for use in tests, with network requests allowed.
|
|
||||||
/// TODO: get rid of this if possible.
|
|
||||||
///
|
|
||||||
/// Do not use this in production code.
|
|
||||||
pub async fn init_test_context_with_networking() -> Data<LemmyContext> {
|
|
||||||
Self::build_test_context(false).await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn build_test_context(block_networking: bool) -> Data<LemmyContext> {
|
|
||||||
// call this to run migrations
|
// call this to run migrations
|
||||||
let pool = build_db_pool_for_tests().await;
|
let pool = build_db_pool_for_tests().await;
|
||||||
|
|
||||||
let client = client_builder(&SETTINGS).build().expect("build client");
|
let client = client_builder(&SETTINGS).build().expect("build client");
|
||||||
|
|
||||||
let mut client = ClientBuilder::new(client);
|
let client = ClientBuilder::new(client).build();
|
||||||
if block_networking {
|
|
||||||
client = client.with(BlockedMiddleware);
|
|
||||||
}
|
|
||||||
let client = client.build();
|
|
||||||
let secret = Secret {
|
let secret = Secret {
|
||||||
id: 0,
|
id: 0,
|
||||||
jwt_secret: String::new(),
|
jwt_secret: String::new(),
|
||||||
|
@ -92,24 +73,11 @@ impl LemmyContext {
|
||||||
let config = FederationConfig::builder()
|
let config = FederationConfig::builder()
|
||||||
.domain(context.settings().hostname.clone())
|
.domain(context.settings().hostname.clone())
|
||||||
.app_data(context)
|
.app_data(context)
|
||||||
|
// Dont allow any network fetches
|
||||||
|
.http_fetch_limit(0)
|
||||||
.build()
|
.build()
|
||||||
.await
|
.await
|
||||||
.expect("build federation config");
|
.expect("build federation config");
|
||||||
config.to_request_data()
|
config.to_request_data()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BlockedMiddleware;
|
|
||||||
|
|
||||||
/// A reqwest middleware which blocks all requests
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
impl Middleware for BlockedMiddleware {
|
|
||||||
async fn handle(
|
|
||||||
&self,
|
|
||||||
_req: Request,
|
|
||||||
_extensions: &mut Extensions,
|
|
||||||
_next: Next<'_>,
|
|
||||||
) -> reqwest_middleware::Result<Response> {
|
|
||||||
Err(anyhow!("Network requests not allowed").into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -86,8 +86,6 @@ pub struct SaveUserSettings {
|
||||||
pub show_nsfw: Option<bool>,
|
pub show_nsfw: Option<bool>,
|
||||||
pub blur_nsfw: Option<bool>,
|
pub blur_nsfw: Option<bool>,
|
||||||
pub auto_expand: Option<bool>,
|
pub auto_expand: Option<bool>,
|
||||||
/// Show post and comment scores.
|
|
||||||
pub show_scores: Option<bool>,
|
|
||||||
/// Your user's theme.
|
/// Your user's theme.
|
||||||
pub theme: Option<String>,
|
pub theme: Option<String>,
|
||||||
pub default_sort_type: Option<SortType>,
|
pub default_sort_type: Option<SortType>,
|
||||||
|
@ -122,6 +120,7 @@ pub struct SaveUserSettings {
|
||||||
pub open_links_in_new_tab: Option<bool>,
|
pub open_links_in_new_tab: Option<bool>,
|
||||||
/// Enable infinite scroll
|
/// Enable infinite scroll
|
||||||
pub infinite_scroll_enabled: Option<bool>,
|
pub infinite_scroll_enabled: Option<bool>,
|
||||||
|
/// A post-view mode that changes how multiple post listings look.
|
||||||
pub post_listing_mode: Option<PostListingMode>,
|
pub post_listing_mode: Option<PostListingMode>,
|
||||||
/// Whether to allow keyboard navigation (for browsing and interacting with posts and comments).
|
/// Whether to allow keyboard navigation (for browsing and interacting with posts and comments).
|
||||||
pub enable_keyboard_navigation: Option<bool>,
|
pub enable_keyboard_navigation: Option<bool>,
|
||||||
|
@ -129,6 +128,11 @@ pub struct SaveUserSettings {
|
||||||
pub enable_animated_images: Option<bool>,
|
pub enable_animated_images: Option<bool>,
|
||||||
/// Whether to auto-collapse bot comments.
|
/// Whether to auto-collapse bot comments.
|
||||||
pub collapse_bot_comments: Option<bool>,
|
pub collapse_bot_comments: Option<bool>,
|
||||||
|
/// Some vote display mode settings
|
||||||
|
pub show_scores: Option<bool>,
|
||||||
|
pub show_upvotes: Option<bool>,
|
||||||
|
pub show_downvotes: Option<bool>,
|
||||||
|
pub show_upvote_percentage: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||||
|
|
|
@ -4,7 +4,10 @@ use crate::{
|
||||||
utils::proxy_image_link,
|
utils::proxy_image_link,
|
||||||
};
|
};
|
||||||
use encoding::{all::encodings, DecoderTrap};
|
use encoding::{all::encodings, DecoderTrap};
|
||||||
use lemmy_db_schema::newtypes::DbUrl;
|
use lemmy_db_schema::{
|
||||||
|
newtypes::DbUrl,
|
||||||
|
source::images::{LocalImage, LocalImageForm},
|
||||||
|
};
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
error::{LemmyError, LemmyErrorType},
|
error::{LemmyError, LemmyErrorType},
|
||||||
settings::structs::{PictrsImageMode, Settings},
|
settings::structs::{PictrsImageMode, Settings},
|
||||||
|
@ -56,14 +59,8 @@ pub async fn fetch_link_metadata(
|
||||||
let opengraph_data = extract_opengraph_data(&html_bytes, url)
|
let opengraph_data = extract_opengraph_data(&html_bytes, url)
|
||||||
.map_err(|e| info!("{e}"))
|
.map_err(|e| info!("{e}"))
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let thumbnail = extract_thumbnail_from_opengraph_data(
|
let thumbnail =
|
||||||
url,
|
extract_thumbnail_from_opengraph_data(url, &opengraph_data, generate_thumbnail, context).await;
|
||||||
&opengraph_data,
|
|
||||||
&content_type,
|
|
||||||
generate_thumbnail,
|
|
||||||
context,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
Ok(LinkMetadata {
|
Ok(LinkMetadata {
|
||||||
opengraph_data,
|
opengraph_data,
|
||||||
|
@ -155,23 +152,21 @@ fn extract_opengraph_data(html_bytes: &[u8], url: &Url) -> Result<OpenGraphData,
|
||||||
pub async fn extract_thumbnail_from_opengraph_data(
|
pub async fn extract_thumbnail_from_opengraph_data(
|
||||||
url: &Url,
|
url: &Url,
|
||||||
opengraph_data: &OpenGraphData,
|
opengraph_data: &OpenGraphData,
|
||||||
content_type: &Option<Mime>,
|
|
||||||
generate_thumbnail: bool,
|
generate_thumbnail: bool,
|
||||||
context: &LemmyContext,
|
context: &LemmyContext,
|
||||||
) -> Option<DbUrl> {
|
) -> Option<DbUrl> {
|
||||||
let is_image = content_type.as_ref().unwrap_or(&mime::TEXT_PLAIN).type_() == mime::IMAGE;
|
if generate_thumbnail {
|
||||||
if generate_thumbnail && is_image {
|
|
||||||
let image_url = opengraph_data
|
let image_url = opengraph_data
|
||||||
.image
|
.image
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(lemmy_db_schema::newtypes::DbUrl::inner)
|
.map(DbUrl::inner)
|
||||||
.unwrap_or(url);
|
.unwrap_or(url);
|
||||||
generate_pictrs_thumbnail(image_url, context)
|
generate_pictrs_thumbnail(image_url, context)
|
||||||
.await
|
.await
|
||||||
.ok()
|
.ok()
|
||||||
.map(Into::into)
|
.map(Into::into)
|
||||||
} else {
|
} else {
|
||||||
None
|
opengraph_data.image.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +179,6 @@ struct PictrsResponse {
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
struct PictrsFile {
|
struct PictrsFile {
|
||||||
file: String,
|
file: String,
|
||||||
#[allow(dead_code)]
|
|
||||||
delete_token: String,
|
delete_token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,6 +281,14 @@ async fn generate_pictrs_thumbnail(
|
||||||
context.settings().get_protocol_and_hostname(),
|
context.settings().get_protocol_and_hostname(),
|
||||||
response.files.first().expect("missing pictrs file").file
|
response.files.first().expect("missing pictrs file").file
|
||||||
))?;
|
))?;
|
||||||
|
for uploaded_image in response.files {
|
||||||
|
let form = LocalImageForm {
|
||||||
|
local_user_id: None,
|
||||||
|
pictrs_alias: uploaded_image.file.to_string(),
|
||||||
|
pictrs_delete_token: uploaded_image.delete_token.to_string(),
|
||||||
|
};
|
||||||
|
LocalImage::create(&mut context.pool(), &form).await?;
|
||||||
|
}
|
||||||
Ok(thumbnail_url)
|
Ok(thumbnail_url)
|
||||||
} else {
|
} else {
|
||||||
Err(LemmyErrorType::PictrsResponseError(response.msg))?
|
Err(LemmyErrorType::PictrsResponseError(response.msg))?
|
||||||
|
@ -311,9 +313,9 @@ async fn is_image_content_type(client: &ClientWithMiddleware, url: &Url) -> Resu
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
|
@ -327,7 +329,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn test_link_metadata() {
|
async fn test_link_metadata() {
|
||||||
let context = LemmyContext::init_test_context_with_networking().await;
|
let context = LemmyContext::init_test_context().await;
|
||||||
let sample_url = Url::parse("https://gitlab.com/IzzyOnDroid/repo/-/wikis/FAQ").unwrap();
|
let sample_url = Url::parse("https://gitlab.com/IzzyOnDroid/repo/-/wikis/FAQ").unwrap();
|
||||||
let sample_res = fetch_link_metadata(&sample_url, false, &context)
|
let sample_res = fetch_link_metadata(&sample_url, false, &context)
|
||||||
.await
|
.await
|
||||||
|
@ -353,7 +355,7 @@ mod tests {
|
||||||
Some(mime::TEXT_HTML_UTF_8.to_string()),
|
Some(mime::TEXT_HTML_UTF_8.to_string()),
|
||||||
sample_res.content_type
|
sample_res.content_type
|
||||||
);
|
);
|
||||||
assert_eq!(None, sample_res.thumbnail);
|
assert!(sample_res.thumbnail.is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[test]
|
// #[test]
|
||||||
|
|
|
@ -6,6 +6,7 @@ use lemmy_db_schema::{
|
||||||
federation_queue_state::FederationQueueState,
|
federation_queue_state::FederationQueueState,
|
||||||
instance::Instance,
|
instance::Instance,
|
||||||
language::Language,
|
language::Language,
|
||||||
|
local_site_url_blocklist::LocalSiteUrlBlocklist,
|
||||||
tagline::Tagline,
|
tagline::Tagline,
|
||||||
},
|
},
|
||||||
ListingType,
|
ListingType,
|
||||||
|
@ -268,6 +269,8 @@ pub struct EditSite {
|
||||||
pub allowed_instances: Option<Vec<String>>,
|
pub allowed_instances: Option<Vec<String>>,
|
||||||
/// A list of blocked instances.
|
/// A list of blocked instances.
|
||||||
pub blocked_instances: Option<Vec<String>>,
|
pub blocked_instances: Option<Vec<String>>,
|
||||||
|
/// A list of blocked URLs
|
||||||
|
pub blocked_urls: Option<Vec<String>>,
|
||||||
/// A list of taglines shown at the top of the front page.
|
/// A list of taglines shown at the top of the front page.
|
||||||
pub taglines: Option<Vec<String>>,
|
pub taglines: Option<Vec<String>>,
|
||||||
pub registration_mode: Option<RegistrationMode>,
|
pub registration_mode: Option<RegistrationMode>,
|
||||||
|
@ -305,6 +308,7 @@ pub struct GetSiteResponse {
|
||||||
pub taglines: Vec<Tagline>,
|
pub taglines: Vec<Tagline>,
|
||||||
/// A list of custom emojis your site supports.
|
/// A list of custom emojis your site supports.
|
||||||
pub custom_emojis: Vec<CustomEmojiView>,
|
pub custom_emojis: Vec<CustomEmojiView>,
|
||||||
|
pub blocked_urls: Vec<LocalSiteUrlBlocklist>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[skip_serializing_none]
|
#[skip_serializing_none]
|
||||||
|
|
|
@ -17,6 +17,7 @@ use lemmy_db_schema::{
|
||||||
instance_block::InstanceBlock,
|
instance_block::InstanceBlock,
|
||||||
local_site::LocalSite,
|
local_site::LocalSite,
|
||||||
local_site_rate_limit::LocalSiteRateLimit,
|
local_site_rate_limit::LocalSiteRateLimit,
|
||||||
|
local_site_url_blocklist::LocalSiteUrlBlocklist,
|
||||||
password_reset_request::PasswordResetRequest,
|
password_reset_request::PasswordResetRequest,
|
||||||
person::{Person, PersonUpdateForm},
|
person::{Person, PersonUpdateForm},
|
||||||
person_block::PersonBlock,
|
person_block::PersonBlock,
|
||||||
|
@ -38,18 +39,24 @@ use lemmy_utils::{
|
||||||
rate_limit::{ActionType, BucketConfig},
|
rate_limit::{ActionType, BucketConfig},
|
||||||
settings::structs::{PictrsImageMode, Settings},
|
settings::structs::{PictrsImageMode, Settings},
|
||||||
utils::{
|
utils::{
|
||||||
markdown::markdown_rewrite_image_links,
|
markdown::{markdown_check_for_blocked_urls, markdown_rewrite_image_links},
|
||||||
slurs::{build_slur_regex, remove_slurs},
|
slurs::{build_slur_regex, remove_slurs},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use regex::Regex;
|
use moka::future::Cache;
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
use regex::{escape, Regex, RegexSet};
|
||||||
use rosetta_i18n::{Language, LanguageId};
|
use rosetta_i18n::{Language, LanguageId};
|
||||||
use std::collections::HashSet;
|
use std::{collections::HashSet, time::Duration};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
use url::{ParseError, Url};
|
use url::{ParseError, Url};
|
||||||
use urlencoding::encode;
|
use urlencoding::encode;
|
||||||
|
|
||||||
pub static AUTH_COOKIE_NAME: &str = "jwt";
|
pub static AUTH_COOKIE_NAME: &str = "jwt";
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
static URL_BLOCKLIST_RECHECK_DELAY: Duration = Duration::from_millis(500);
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
static URL_BLOCKLIST_RECHECK_DELAY: Duration = Duration::from_secs(60);
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
pub async fn is_mod_or_admin(
|
pub async fn is_mod_or_admin(
|
||||||
|
@ -516,6 +523,47 @@ pub fn local_site_opt_to_sensitive(local_site: &Option<LocalSite>) -> bool {
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_url_blocklist(context: &LemmyContext) -> LemmyResult<RegexSet> {
|
||||||
|
static URL_BLOCKLIST: Lazy<Cache<(), RegexSet>> = Lazy::new(|| {
|
||||||
|
Cache::builder()
|
||||||
|
.max_capacity(1)
|
||||||
|
.time_to_live(URL_BLOCKLIST_RECHECK_DELAY)
|
||||||
|
.build()
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(
|
||||||
|
URL_BLOCKLIST
|
||||||
|
.try_get_with::<_, LemmyError>((), async {
|
||||||
|
let urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?;
|
||||||
|
|
||||||
|
let regexes = urls.iter().map(|url| {
|
||||||
|
let url = &url.url;
|
||||||
|
let parsed = Url::parse(url).expect("Coundln't parse URL.");
|
||||||
|
if url.ends_with('/') {
|
||||||
|
format!(
|
||||||
|
"({}://)?{}{}?",
|
||||||
|
parsed.scheme(),
|
||||||
|
escape(parsed.domain().expect("No domain.")),
|
||||||
|
escape(parsed.path())
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
format!(
|
||||||
|
"({}://)?{}{}",
|
||||||
|
parsed.scheme(),
|
||||||
|
escape(parsed.domain().expect("No domain.")),
|
||||||
|
escape(parsed.path())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let set = RegexSet::new(regexes)?;
|
||||||
|
Ok(set)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow::anyhow!("Failed to build URL blocklist due to `{}`", e))?,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn send_application_approved_email(
|
pub async fn send_application_approved_email(
|
||||||
user: &LocalUserView,
|
user: &LocalUserView,
|
||||||
settings: &Settings,
|
settings: &Settings,
|
||||||
|
@ -890,9 +938,13 @@ fn limit_expire_time(expires: DateTime<Utc>) -> LemmyResult<Option<DateTime<Utc>
|
||||||
pub async fn process_markdown(
|
pub async fn process_markdown(
|
||||||
text: &str,
|
text: &str,
|
||||||
slur_regex: &Option<Regex>,
|
slur_regex: &Option<Regex>,
|
||||||
|
url_blocklist: &RegexSet,
|
||||||
context: &LemmyContext,
|
context: &LemmyContext,
|
||||||
) -> LemmyResult<String> {
|
) -> LemmyResult<String> {
|
||||||
let text = remove_slurs(text, slur_regex);
|
let text = remove_slurs(text, slur_regex);
|
||||||
|
|
||||||
|
markdown_check_for_blocked_urls(&text, url_blocklist)?;
|
||||||
|
|
||||||
if context.settings().pictrs_config()?.image_mode() == PictrsImageMode::ProxyAllImages {
|
if context.settings().pictrs_config()?.image_mode() == PictrsImageMode::ProxyAllImages {
|
||||||
let (text, links) = markdown_rewrite_image_links(text);
|
let (text, links) = markdown_rewrite_image_links(text);
|
||||||
RemoteImage::create(&mut context.pool(), links).await?;
|
RemoteImage::create(&mut context.pool(), links).await?;
|
||||||
|
@ -905,10 +957,13 @@ pub async fn process_markdown(
|
||||||
pub async fn process_markdown_opt(
|
pub async fn process_markdown_opt(
|
||||||
text: &Option<String>,
|
text: &Option<String>,
|
||||||
slur_regex: &Option<Regex>,
|
slur_regex: &Option<Regex>,
|
||||||
|
url_blocklist: &RegexSet,
|
||||||
context: &LemmyContext,
|
context: &LemmyContext,
|
||||||
) -> LemmyResult<Option<String>> {
|
) -> LemmyResult<Option<String>> {
|
||||||
match text {
|
match text {
|
||||||
Some(t) => process_markdown(t, slur_regex, context).await.map(Some),
|
Some(t) => process_markdown(t, slur_regex, url_blocklist, context)
|
||||||
|
.await
|
||||||
|
.map(Some),
|
||||||
None => Ok(None),
|
None => Ok(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -987,9 +1042,9 @@ pub async fn proxy_image_link_opt_apub(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
|
@ -10,6 +10,7 @@ use lemmy_api_common::{
|
||||||
check_post_deleted_or_removed,
|
check_post_deleted_or_removed,
|
||||||
generate_local_apub_endpoint,
|
generate_local_apub_endpoint,
|
||||||
get_post,
|
get_post,
|
||||||
|
get_url_blocklist,
|
||||||
is_mod_or_admin,
|
is_mod_or_admin,
|
||||||
local_site_to_slur_regex,
|
local_site_to_slur_regex,
|
||||||
process_markdown,
|
process_markdown,
|
||||||
|
@ -44,7 +45,8 @@ pub async fn create_comment(
|
||||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||||
|
|
||||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||||
let content = process_markdown(&data.content, &slur_regex, &context).await?;
|
let url_blocklist = get_url_blocklist(&context).await?;
|
||||||
|
let content = process_markdown(&data.content, &slur_regex, &url_blocklist, &context).await?;
|
||||||
is_valid_body_field(&Some(content.clone()), false)?;
|
is_valid_body_field(&Some(content.clone()), false)?;
|
||||||
|
|
||||||
// Check for a community ban
|
// Check for a community ban
|
||||||
|
@ -162,10 +164,15 @@ pub async fn create_comment(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// If its a reply, mark the parent as read
|
// If we're responding to a comment where we're the recipient,
|
||||||
|
// (ie we're the grandparent, or the recipient of the parent comment_reply),
|
||||||
|
// then mark the parent as read.
|
||||||
|
// Then we don't have to do it manually after we respond to a comment.
|
||||||
if let Some(parent) = parent_opt {
|
if let Some(parent) = parent_opt {
|
||||||
|
let person_id = local_user_view.person.id;
|
||||||
let parent_id = parent.id;
|
let parent_id = parent.id;
|
||||||
let comment_reply = CommentReply::read_by_comment(&mut context.pool(), parent_id).await;
|
let comment_reply =
|
||||||
|
CommentReply::read_by_comment_and_person(&mut context.pool(), parent_id, person_id).await;
|
||||||
if let Ok(reply) = comment_reply {
|
if let Ok(reply) = comment_reply {
|
||||||
CommentReply::update(
|
CommentReply::update(
|
||||||
&mut context.pool(),
|
&mut context.pool(),
|
||||||
|
@ -177,7 +184,6 @@ pub async fn create_comment(
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the parent has PersonMentions mark them as read too
|
// If the parent has PersonMentions mark them as read too
|
||||||
let person_id = local_user_view.person.id;
|
|
||||||
let person_mention =
|
let person_mention =
|
||||||
PersonMention::read_by_comment_and_person(&mut context.pool(), parent_id, person_id).await;
|
PersonMention::read_by_comment_and_person(&mut context.pool(), parent_id, person_id).await;
|
||||||
if let Ok(mention) = person_mention {
|
if let Ok(mention) = person_mention {
|
||||||
|
|
|
@ -5,7 +5,12 @@ use lemmy_api_common::{
|
||||||
comment::{CommentResponse, EditComment},
|
comment::{CommentResponse, EditComment},
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
send_activity::{ActivityChannel, SendActivityData},
|
send_activity::{ActivityChannel, SendActivityData},
|
||||||
utils::{check_community_user_action, local_site_to_slur_regex, process_markdown_opt},
|
utils::{
|
||||||
|
check_community_user_action,
|
||||||
|
get_url_blocklist,
|
||||||
|
local_site_to_slur_regex,
|
||||||
|
process_markdown_opt,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
|
@ -54,7 +59,8 @@ pub async fn update_comment(
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||||
let content = process_markdown_opt(&data.content, &slur_regex, &context).await?;
|
let url_blocklist = get_url_blocklist(&context).await?;
|
||||||
|
let content = process_markdown_opt(&data.content, &slur_regex, &url_blocklist, &context).await?;
|
||||||
is_valid_body_field(&content, false)?;
|
is_valid_body_field(&content, false)?;
|
||||||
|
|
||||||
let comment_id = data.comment_id;
|
let comment_id = data.comment_id;
|
||||||
|
|
|
@ -9,6 +9,7 @@ use lemmy_api_common::{
|
||||||
generate_inbox_url,
|
generate_inbox_url,
|
||||||
generate_local_apub_endpoint,
|
generate_local_apub_endpoint,
|
||||||
generate_shared_inbox_url,
|
generate_shared_inbox_url,
|
||||||
|
get_url_blocklist,
|
||||||
is_admin,
|
is_admin,
|
||||||
local_site_to_slur_regex,
|
local_site_to_slur_regex,
|
||||||
process_markdown_opt,
|
process_markdown_opt,
|
||||||
|
@ -53,9 +54,11 @@ pub async fn create_community(
|
||||||
}
|
}
|
||||||
|
|
||||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||||
|
let url_blocklist = get_url_blocklist(&context).await?;
|
||||||
check_slurs(&data.name, &slur_regex)?;
|
check_slurs(&data.name, &slur_regex)?;
|
||||||
check_slurs(&data.title, &slur_regex)?;
|
check_slurs(&data.title, &slur_regex)?;
|
||||||
let description = process_markdown_opt(&data.description, &slur_regex, &context).await?;
|
let description =
|
||||||
|
process_markdown_opt(&data.description, &slur_regex, &url_blocklist, &context).await?;
|
||||||
let icon = proxy_image_link_api(&data.icon, &context).await?;
|
let icon = proxy_image_link_api(&data.icon, &context).await?;
|
||||||
let banner = proxy_image_link_api(&data.banner, &context).await?;
|
let banner = proxy_image_link_api(&data.banner, &context).await?;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ use lemmy_api_common::{
|
||||||
send_activity::{ActivityChannel, SendActivityData},
|
send_activity::{ActivityChannel, SendActivityData},
|
||||||
utils::{
|
utils::{
|
||||||
check_community_mod_action,
|
check_community_mod_action,
|
||||||
|
get_url_blocklist,
|
||||||
local_site_to_slur_regex,
|
local_site_to_slur_regex,
|
||||||
process_markdown_opt,
|
process_markdown_opt,
|
||||||
proxy_image_link_opt_api,
|
proxy_image_link_opt_api,
|
||||||
|
@ -36,8 +37,10 @@ pub async fn update_community(
|
||||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||||
|
|
||||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||||
|
let url_blocklist = get_url_blocklist(&context).await?;
|
||||||
check_slurs_opt(&data.title, &slur_regex)?;
|
check_slurs_opt(&data.title, &slur_regex)?;
|
||||||
let description = process_markdown_opt(&data.description, &slur_regex, &context).await?;
|
let description =
|
||||||
|
process_markdown_opt(&data.description, &slur_regex, &url_blocklist, &context).await?;
|
||||||
is_valid_body_field(&data.description, false)?;
|
is_valid_body_field(&data.description, false)?;
|
||||||
|
|
||||||
let description = diesel_option_overwrite(description);
|
let description = diesel_option_overwrite(description);
|
||||||
|
|
|
@ -9,6 +9,7 @@ use lemmy_api_common::{
|
||||||
utils::{
|
utils::{
|
||||||
check_community_user_action,
|
check_community_user_action,
|
||||||
generate_local_apub_endpoint,
|
generate_local_apub_endpoint,
|
||||||
|
get_url_blocklist,
|
||||||
honeypot_check,
|
honeypot_check,
|
||||||
local_site_to_slur_regex,
|
local_site_to_slur_regex,
|
||||||
mark_post_as_read,
|
mark_post_as_read,
|
||||||
|
@ -29,7 +30,7 @@ use lemmy_db_schema::{
|
||||||
CommunityVisibility,
|
CommunityVisibility,
|
||||||
};
|
};
|
||||||
use lemmy_db_views::structs::LocalUserView;
|
use lemmy_db_views::structs::LocalUserView;
|
||||||
use lemmy_db_views_actor::structs::CommunityView;
|
use lemmy_db_views_actor::structs::CommunityModeratorView;
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
||||||
spawn_try_task,
|
spawn_try_task,
|
||||||
|
@ -38,6 +39,7 @@ use lemmy_utils::{
|
||||||
validation::{
|
validation::{
|
||||||
check_url_scheme,
|
check_url_scheme,
|
||||||
clean_url_params,
|
clean_url_params,
|
||||||
|
is_url_blocked,
|
||||||
is_valid_alt_text_field,
|
is_valid_alt_text_field,
|
||||||
is_valid_body_field,
|
is_valid_body_field,
|
||||||
is_valid_post_title,
|
is_valid_post_title,
|
||||||
|
@ -60,8 +62,9 @@ pub async fn create_post(
|
||||||
|
|
||||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||||
check_slurs(&data.name, &slur_regex)?;
|
check_slurs(&data.name, &slur_regex)?;
|
||||||
|
let url_blocklist = get_url_blocklist(&context).await?;
|
||||||
|
|
||||||
let body = process_markdown_opt(&data.body, &slur_regex, &context).await?;
|
let body = process_markdown_opt(&data.body, &slur_regex, &url_blocklist, &context).await?;
|
||||||
let data_url = data.url.as_ref();
|
let data_url = data.url.as_ref();
|
||||||
let url = data_url.map(clean_url_params); // TODO no good way to handle a "clear"
|
let url = data_url.map(clean_url_params); // TODO no good way to handle a "clear"
|
||||||
let custom_thumbnail = data.custom_thumbnail.as_ref().map(clean_url_params);
|
let custom_thumbnail = data.custom_thumbnail.as_ref().map(clean_url_params);
|
||||||
|
@ -69,6 +72,7 @@ pub async fn create_post(
|
||||||
is_valid_post_title(&data.name)?;
|
is_valid_post_title(&data.name)?;
|
||||||
is_valid_body_field(&body, true)?;
|
is_valid_body_field(&body, true)?;
|
||||||
is_valid_alt_text_field(&data.alt_text)?;
|
is_valid_alt_text_field(&data.alt_text)?;
|
||||||
|
is_url_blocked(&url, &url_blocklist)?;
|
||||||
check_url_scheme(&url)?;
|
check_url_scheme(&url)?;
|
||||||
check_url_scheme(&custom_thumbnail)?;
|
check_url_scheme(&custom_thumbnail)?;
|
||||||
|
|
||||||
|
@ -83,10 +87,10 @@ pub async fn create_post(
|
||||||
let community = Community::read(&mut context.pool(), community_id).await?;
|
let community = Community::read(&mut context.pool(), community_id).await?;
|
||||||
if community.posting_restricted_to_mods {
|
if community.posting_restricted_to_mods {
|
||||||
let community_id = data.community_id;
|
let community_id = data.community_id;
|
||||||
let is_mod = CommunityView::is_mod_or_admin(
|
let is_mod = CommunityModeratorView::is_community_moderator(
|
||||||
&mut context.pool(),
|
&mut context.pool(),
|
||||||
local_user_view.local_user.person_id,
|
|
||||||
community_id,
|
community_id,
|
||||||
|
local_user_view.local_user.person_id,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
if !is_mod {
|
if !is_mod {
|
||||||
|
|
|
@ -8,6 +8,7 @@ use lemmy_api_common::{
|
||||||
send_activity::{ActivityChannel, SendActivityData},
|
send_activity::{ActivityChannel, SendActivityData},
|
||||||
utils::{
|
utils::{
|
||||||
check_community_user_action,
|
check_community_user_action,
|
||||||
|
get_url_blocklist,
|
||||||
local_site_to_slur_regex,
|
local_site_to_slur_regex,
|
||||||
process_markdown_opt,
|
process_markdown_opt,
|
||||||
proxy_image_link_opt_apub,
|
proxy_image_link_opt_apub,
|
||||||
|
@ -30,6 +31,7 @@ use lemmy_utils::{
|
||||||
validation::{
|
validation::{
|
||||||
check_url_scheme,
|
check_url_scheme,
|
||||||
clean_url_params,
|
clean_url_params,
|
||||||
|
is_url_blocked,
|
||||||
is_valid_alt_text_field,
|
is_valid_alt_text_field,
|
||||||
is_valid_body_field,
|
is_valid_body_field,
|
||||||
is_valid_post_title,
|
is_valid_post_title,
|
||||||
|
@ -51,9 +53,11 @@ pub async fn update_post(
|
||||||
let url = data.url.as_ref().map(clean_url_params);
|
let url = data.url.as_ref().map(clean_url_params);
|
||||||
let custom_thumbnail = data.custom_thumbnail.as_ref().map(clean_url_params);
|
let custom_thumbnail = data.custom_thumbnail.as_ref().map(clean_url_params);
|
||||||
|
|
||||||
|
let url_blocklist = get_url_blocklist(&context).await?;
|
||||||
|
|
||||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||||
check_slurs_opt(&data.name, &slur_regex)?;
|
check_slurs_opt(&data.name, &slur_regex)?;
|
||||||
let body = process_markdown_opt(&data.body, &slur_regex, &context).await?;
|
let body = process_markdown_opt(&data.body, &slur_regex, &url_blocklist, &context).await?;
|
||||||
|
|
||||||
if let Some(name) = &data.name {
|
if let Some(name) = &data.name {
|
||||||
is_valid_post_title(name)?;
|
is_valid_post_title(name)?;
|
||||||
|
@ -61,6 +65,7 @@ pub async fn update_post(
|
||||||
|
|
||||||
is_valid_body_field(&body, true)?;
|
is_valid_body_field(&body, true)?;
|
||||||
is_valid_alt_text_field(&data.alt_text)?;
|
is_valid_alt_text_field(&data.alt_text)?;
|
||||||
|
is_url_blocked(&url, &url_blocklist)?;
|
||||||
check_url_scheme(&url)?;
|
check_url_scheme(&url)?;
|
||||||
check_url_scheme(&custom_thumbnail)?;
|
check_url_scheme(&custom_thumbnail)?;
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ use lemmy_api_common::{
|
||||||
check_person_block,
|
check_person_block,
|
||||||
generate_local_apub_endpoint,
|
generate_local_apub_endpoint,
|
||||||
get_interface_language,
|
get_interface_language,
|
||||||
|
get_url_blocklist,
|
||||||
local_site_to_slur_regex,
|
local_site_to_slur_regex,
|
||||||
process_markdown,
|
process_markdown,
|
||||||
send_email_to_user,
|
send_email_to_user,
|
||||||
|
@ -36,7 +37,8 @@ pub async fn create_private_message(
|
||||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||||
|
|
||||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||||
let content = process_markdown(&data.content, &slur_regex, &context).await?;
|
let url_blocklist = get_url_blocklist(&context).await?;
|
||||||
|
let content = process_markdown(&data.content, &slur_regex, &url_blocklist, &context).await?;
|
||||||
is_valid_body_field(&Some(content.clone()), false)?;
|
is_valid_body_field(&Some(content.clone()), false)?;
|
||||||
|
|
||||||
check_person_block(
|
check_person_block(
|
||||||
|
|
|
@ -4,7 +4,7 @@ use lemmy_api_common::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
private_message::{EditPrivateMessage, PrivateMessageResponse},
|
private_message::{EditPrivateMessage, PrivateMessageResponse},
|
||||||
send_activity::{ActivityChannel, SendActivityData},
|
send_activity::{ActivityChannel, SendActivityData},
|
||||||
utils::{local_site_to_slur_regex, process_markdown},
|
utils::{get_url_blocklist, local_site_to_slur_regex, process_markdown},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
|
@ -37,7 +37,8 @@ pub async fn update_private_message(
|
||||||
|
|
||||||
// Doing the update
|
// Doing the update
|
||||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||||
let content = process_markdown(&data.content, &slur_regex, &context).await?;
|
let url_blocklist = get_url_blocklist(&context).await?;
|
||||||
|
let content = process_markdown(&data.content, &slur_regex, &url_blocklist, &context).await?;
|
||||||
is_valid_body_field(&Some(content.clone()), false)?;
|
is_valid_body_field(&Some(content.clone()), false)?;
|
||||||
|
|
||||||
let private_message_id = data.private_message_id;
|
let private_message_id = data.private_message_id;
|
||||||
|
|
|
@ -6,6 +6,7 @@ use lemmy_api_common::{
|
||||||
site::{CreateSite, SiteResponse},
|
site::{CreateSite, SiteResponse},
|
||||||
utils::{
|
utils::{
|
||||||
generate_shared_inbox_url,
|
generate_shared_inbox_url,
|
||||||
|
get_url_blocklist,
|
||||||
is_admin,
|
is_admin,
|
||||||
local_site_rate_limit_to_rate_limit_config,
|
local_site_rate_limit_to_rate_limit_config,
|
||||||
local_site_to_slur_regex,
|
local_site_to_slur_regex,
|
||||||
|
@ -58,7 +59,8 @@ pub async fn create_site(
|
||||||
let keypair = generate_actor_keypair()?;
|
let keypair = generate_actor_keypair()?;
|
||||||
|
|
||||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||||
let sidebar = process_markdown_opt(&data.sidebar, &slur_regex, &context).await?;
|
let url_blocklist = get_url_blocklist(&context).await?;
|
||||||
|
let sidebar = process_markdown_opt(&data.sidebar, &slur_regex, &url_blocklist, &context).await?;
|
||||||
let icon = proxy_image_link_opt_api(&data.icon, &context).await?;
|
let icon = proxy_image_link_opt_api(&data.icon, &context).await?;
|
||||||
let banner = proxy_image_link_opt_api(&data.banner, &context).await?;
|
let banner = proxy_image_link_opt_api(&data.banner, &context).await?;
|
||||||
|
|
||||||
|
@ -187,9 +189,9 @@ fn validate_create_payload(local_site: &LocalSite, create_site: &CreateSite) ->
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::site::create::validate_create_payload;
|
use crate::site::create::validate_create_payload;
|
||||||
use lemmy_api_common::site::CreateSite;
|
use lemmy_api_common::site::CreateSite;
|
||||||
|
|
|
@ -41,9 +41,9 @@ pub fn application_question_check(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::site::{application_question_check, site_default_post_listing_type_check};
|
use crate::site::{application_question_check, site_default_post_listing_type_check};
|
||||||
use lemmy_db_schema::{ListingType, RegistrationMode};
|
use lemmy_db_schema::{ListingType, RegistrationMode};
|
||||||
|
|
|
@ -6,6 +6,7 @@ use lemmy_api_common::{
|
||||||
use lemmy_db_schema::source::{
|
use lemmy_db_schema::source::{
|
||||||
actor_language::{LocalUserLanguage, SiteLanguage},
|
actor_language::{LocalUserLanguage, SiteLanguage},
|
||||||
language::Language,
|
language::Language,
|
||||||
|
local_site_url_blocklist::LocalSiteUrlBlocklist,
|
||||||
tagline::Tagline,
|
tagline::Tagline,
|
||||||
};
|
};
|
||||||
use lemmy_db_views::structs::{CustomEmojiView, LocalUserView, SiteView};
|
use lemmy_db_views::structs::{CustomEmojiView, LocalUserView, SiteView};
|
||||||
|
@ -47,6 +48,7 @@ pub async fn get_site(
|
||||||
let taglines = Tagline::get_all(&mut context.pool(), site_view.local_site.id).await?;
|
let taglines = Tagline::get_all(&mut context.pool(), site_view.local_site.id).await?;
|
||||||
let custom_emojis =
|
let custom_emojis =
|
||||||
CustomEmojiView::get_all(&mut context.pool(), site_view.local_site.id).await?;
|
CustomEmojiView::get_all(&mut context.pool(), site_view.local_site.id).await?;
|
||||||
|
let blocked_urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?;
|
||||||
Ok(GetSiteResponse {
|
Ok(GetSiteResponse {
|
||||||
site_view,
|
site_view,
|
||||||
admins,
|
admins,
|
||||||
|
@ -56,6 +58,7 @@ pub async fn get_site(
|
||||||
discussion_languages,
|
discussion_languages,
|
||||||
taglines,
|
taglines,
|
||||||
custom_emojis,
|
custom_emojis,
|
||||||
|
blocked_urls,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
|
|
|
@ -4,6 +4,7 @@ use lemmy_api_common::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
site::{EditSite, SiteResponse},
|
site::{EditSite, SiteResponse},
|
||||||
utils::{
|
utils::{
|
||||||
|
get_url_blocklist,
|
||||||
is_admin,
|
is_admin,
|
||||||
local_site_rate_limit_to_rate_limit_config,
|
local_site_rate_limit_to_rate_limit_config,
|
||||||
local_site_to_slur_regex,
|
local_site_to_slur_regex,
|
||||||
|
@ -18,6 +19,7 @@ use lemmy_db_schema::{
|
||||||
federation_blocklist::FederationBlockList,
|
federation_blocklist::FederationBlockList,
|
||||||
local_site::{LocalSite, LocalSiteUpdateForm},
|
local_site::{LocalSite, LocalSiteUpdateForm},
|
||||||
local_site_rate_limit::{LocalSiteRateLimit, LocalSiteRateLimitUpdateForm},
|
local_site_rate_limit::{LocalSiteRateLimit, LocalSiteRateLimitUpdateForm},
|
||||||
|
local_site_url_blocklist::LocalSiteUrlBlocklist,
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
site::{Site, SiteUpdateForm},
|
site::{Site, SiteUpdateForm},
|
||||||
tagline::Tagline,
|
tagline::Tagline,
|
||||||
|
@ -34,6 +36,7 @@ use lemmy_utils::{
|
||||||
validation::{
|
validation::{
|
||||||
build_and_check_regex,
|
build_and_check_regex,
|
||||||
check_site_visibility_valid,
|
check_site_visibility_valid,
|
||||||
|
check_urls_are_valid,
|
||||||
is_valid_body_field,
|
is_valid_body_field,
|
||||||
site_description_length_check,
|
site_description_length_check,
|
||||||
site_name_length_check,
|
site_name_length_check,
|
||||||
|
@ -61,7 +64,8 @@ pub async fn update_site(
|
||||||
}
|
}
|
||||||
|
|
||||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||||
let sidebar = process_markdown_opt(&data.sidebar, &slur_regex, &context).await?;
|
let url_blocklist = get_url_blocklist(&context).await?;
|
||||||
|
let sidebar = process_markdown_opt(&data.sidebar, &slur_regex, &url_blocklist, &context).await?;
|
||||||
let icon = proxy_image_link_opt_api(&data.icon, &context).await?;
|
let icon = proxy_image_link_opt_api(&data.icon, &context).await?;
|
||||||
let banner = proxy_image_link_opt_api(&data.banner, &context).await?;
|
let banner = proxy_image_link_opt_api(&data.banner, &context).await?;
|
||||||
|
|
||||||
|
@ -137,6 +141,11 @@ pub async fn update_site(
|
||||||
let blocked = data.blocked_instances.clone();
|
let blocked = data.blocked_instances.clone();
|
||||||
FederationBlockList::replace(&mut context.pool(), blocked).await?;
|
FederationBlockList::replace(&mut context.pool(), blocked).await?;
|
||||||
|
|
||||||
|
if let Some(url_blocklist) = data.blocked_urls.clone() {
|
||||||
|
let parsed_urls = check_urls_are_valid(&url_blocklist)?;
|
||||||
|
LocalSiteUrlBlocklist::replace(&mut context.pool(), parsed_urls).await?;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO can't think of a better way to do this.
|
// TODO can't think of a better way to do this.
|
||||||
// If the server suddenly requires email verification, or required applications, no old users
|
// If the server suddenly requires email verification, or required applications, no old users
|
||||||
// will be able to log in. It really only wants this to be a requirement for NEW signups.
|
// will be able to log in. It really only wants this to be a requirement for NEW signups.
|
||||||
|
@ -222,9 +231,9 @@ fn validate_update_payload(local_site: &LocalSite, edit_site: &EditSite) -> Lemm
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::site::update::validate_update_payload;
|
use crate::site::update::validate_update_payload;
|
||||||
use lemmy_api_common::site::EditSite;
|
use lemmy_api_common::site::EditSite;
|
||||||
|
@ -578,6 +587,7 @@ mod tests {
|
||||||
captcha_difficulty: None,
|
captcha_difficulty: None,
|
||||||
allowed_instances: None,
|
allowed_instances: None,
|
||||||
blocked_instances: None,
|
blocked_instances: None,
|
||||||
|
blocked_urls: None,
|
||||||
taglines: None,
|
taglines: None,
|
||||||
registration_mode: site_registration_mode,
|
registration_mode: site_registration_mode,
|
||||||
reports_email_admins: None,
|
reports_email_admins: None,
|
||||||
|
|
|
@ -20,7 +20,9 @@ use lemmy_db_schema::{
|
||||||
aggregates::structs::PersonAggregates,
|
aggregates::structs::PersonAggregates,
|
||||||
source::{
|
source::{
|
||||||
captcha_answer::{CaptchaAnswer, CheckCaptchaAnswer},
|
captcha_answer::{CaptchaAnswer, CheckCaptchaAnswer},
|
||||||
|
language::Language,
|
||||||
local_user::{LocalUser, LocalUserInsertForm},
|
local_user::{LocalUser, LocalUserInsertForm},
|
||||||
|
local_user_vote_display_mode::LocalUserVoteDisplayMode,
|
||||||
person::{Person, PersonInsertForm},
|
person::{Person, PersonInsertForm},
|
||||||
registration_application::{RegistrationApplication, RegistrationApplicationInsertForm},
|
registration_application::{RegistrationApplication, RegistrationApplicationInsertForm},
|
||||||
},
|
},
|
||||||
|
@ -35,6 +37,7 @@ use lemmy_utils::{
|
||||||
validation::is_valid_actor_name,
|
validation::is_valid_actor_name,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
#[tracing::instrument(skip(context))]
|
#[tracing::instrument(skip(context))]
|
||||||
pub async fn register(
|
pub async fn register(
|
||||||
|
@ -127,12 +130,15 @@ pub async fn register(
|
||||||
let accepted_application = Some(!require_registration_application);
|
let accepted_application = Some(!require_registration_application);
|
||||||
|
|
||||||
// Get the user's preferred language using the Accept-Language header
|
// Get the user's preferred language using the Accept-Language header
|
||||||
let language_tag = req.headers().get("Accept-Language").and_then(|hdr| {
|
let language_tags: Vec<String> = req
|
||||||
accept_language::parse(hdr.to_str().unwrap_or_default())
|
.headers()
|
||||||
.first()
|
.get("Accept-Language")
|
||||||
|
.map(|hdr| accept_language::parse(hdr.to_str().unwrap_or_default()))
|
||||||
|
.iter()
|
||||||
|
.flatten()
|
||||||
// Remove the optional region code
|
// Remove the optional region code
|
||||||
.map(|lang_str| lang_str.split('-').next().unwrap_or_default().to_string())
|
.map(|lang_str| lang_str.split('-').next().unwrap_or_default().to_string())
|
||||||
});
|
.collect();
|
||||||
|
|
||||||
// Create the local user
|
// Create the local user
|
||||||
let local_user_form = LocalUserInsertForm::builder()
|
let local_user_form = LocalUserInsertForm::builder()
|
||||||
|
@ -143,12 +149,23 @@ pub async fn register(
|
||||||
.accepted_application(accepted_application)
|
.accepted_application(accepted_application)
|
||||||
.default_listing_type(Some(local_site.default_post_listing_type))
|
.default_listing_type(Some(local_site.default_post_listing_type))
|
||||||
.post_listing_mode(Some(local_site.default_post_listing_mode))
|
.post_listing_mode(Some(local_site.default_post_listing_mode))
|
||||||
.interface_language(language_tag)
|
.interface_language(language_tags.first().cloned())
|
||||||
// If its the initial site setup, they are an admin
|
// If its the initial site setup, they are an admin
|
||||||
.admin(Some(!local_site.site_setup))
|
.admin(Some(!local_site.site_setup))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let inserted_local_user = LocalUser::create(&mut context.pool(), &local_user_form).await?;
|
let all_languages = Language::read_all(&mut context.pool()).await?;
|
||||||
|
// use hashset to avoid duplicates
|
||||||
|
let mut language_ids = HashSet::new();
|
||||||
|
for l in language_tags {
|
||||||
|
if let Some(found) = all_languages.iter().find(|all| all.code == l) {
|
||||||
|
language_ids.insert(found.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let language_ids = language_ids.into_iter().collect();
|
||||||
|
|
||||||
|
let inserted_local_user =
|
||||||
|
LocalUser::create(&mut context.pool(), &local_user_form, language_ids).await?;
|
||||||
|
|
||||||
if local_site.site_setup && require_registration_application {
|
if local_site.site_setup && require_registration_application {
|
||||||
// Create the registration application
|
// Create the registration application
|
||||||
|
@ -183,6 +200,7 @@ pub async fn register(
|
||||||
if local_site.require_email_verification {
|
if local_site.require_email_verification {
|
||||||
let local_user_view = LocalUserView {
|
let local_user_view = LocalUserView {
|
||||||
local_user: inserted_local_user,
|
local_user: inserted_local_user,
|
||||||
|
local_user_vote_display_mode: LocalUserVoteDisplayMode::default(),
|
||||||
person: inserted_person,
|
person: inserted_person,
|
||||||
counts: PersonAggregates::default(),
|
counts: PersonAggregates::default(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,5 +3,6 @@
|
||||||
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
||||||
"object": "http://ds9.lemmy.ml/u/lemmy_alpha",
|
"object": "http://ds9.lemmy.ml/u/lemmy_alpha",
|
||||||
"type": "Delete",
|
"type": "Delete",
|
||||||
"id": "http://ds9.lemmy.ml/activities/delete/f2abee48-c7bb-41d5-9e27-8775ff32db12"
|
"id": "http://ds9.lemmy.ml/activities/delete/f2abee48-c7bb-41d5-9e27-8775ff32db12",
|
||||||
|
"removeData": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
"type": "Application",
|
"type": "Application",
|
||||||
"id": "https://enterprise.lemmy.ml/",
|
"id": "https://enterprise.lemmy.ml/",
|
||||||
"name": "Enterprise",
|
"name": "Enterprise",
|
||||||
|
"preferredUsername": "enterprise.lemmy.ml",
|
||||||
"summary": "A test instance",
|
"summary": "A test instance",
|
||||||
"content": "<p>Enterprise sidebar</p>\\n",
|
"content": "<p>Enterprise sidebar</p>\\n",
|
||||||
"mediaType": "text/html",
|
"mediaType": "text/html",
|
||||||
|
|
|
@ -11,21 +11,21 @@
|
||||||
"votersCount": "toot:votersCount"
|
"votersCount": "toot:votersCount"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"id": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519",
|
"id": "https://masto.qa.urbanwildlife.biz/users/mastodon/statuses/110830743680706519",
|
||||||
"type": "Note",
|
"type": "Note",
|
||||||
"summary": null,
|
"summary": null,
|
||||||
"inReplyTo": null,
|
"inReplyTo": null,
|
||||||
"published": "2023-08-04T09:55:39Z",
|
"published": "2023-08-04T09:55:39Z",
|
||||||
"url": "https://dice.camp/@thekernelinyellow/110830743680706519",
|
"url": "https://masto.qa.urbanwildlife.biz/110830743680706519",
|
||||||
"attributedTo": "https://dice.camp/users/thekernelinyellow",
|
"attributedTo": "https://masto.qa.urbanwildlife.biz/users/mastodon",
|
||||||
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
||||||
"cc": [
|
"cc": [
|
||||||
"https://dice.camp/users/thekernelinyellow/followers",
|
"https://masto.qa.urbanwildlife.biz/users/mastodon/followers",
|
||||||
"https://enterprise.lemmy.ml/c/tenforward",
|
"https://enterprise.lemmy.ml/c/tenforward",
|
||||||
"https://enterprise.lemmy.ml/c/tenforward/followers"
|
"https://enterprise.lemmy.ml/c/tenforward/followers"
|
||||||
],
|
],
|
||||||
"sensitive": false,
|
"sensitive": false,
|
||||||
"atomUri": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519",
|
"atomUri": "https://masto.qa.urbanwildlife.biz/statuses/110830743680706519",
|
||||||
"inReplyToAtomUri": null,
|
"inReplyToAtomUri": null,
|
||||||
"conversation": "tag:dice.camp,2023-08-04:objectId=29969291:objectType=Conversation",
|
"conversation": "tag:dice.camp,2023-08-04:objectId=29969291:objectType=Conversation",
|
||||||
"content": "<p><span class=\"h-card\" translate=\"no\"><a href=\"https://enterprise.lemmy.ml/c/tenforward\" class=\"u-url mention\">@<span>tenforward</span></a></span> Variable never resetting at refresh</p><p>Hi! I'm using a variable to count elements in my generator but every time I generate a new character, the counter's value carries on from the previous one. Is there a function to reset it (I set it to 0 at the beginning of the file)</p>",
|
"content": "<p><span class=\"h-card\" translate=\"no\"><a href=\"https://enterprise.lemmy.ml/c/tenforward\" class=\"u-url mention\">@<span>tenforward</span></a></span> Variable never resetting at refresh</p><p>Hi! I'm using a variable to count elements in my generator but every time I generate a new character, the counter's value carries on from the previous one. Is there a function to reset it (I set it to 0 at the beginning of the file)</p>",
|
||||||
|
@ -41,12 +41,12 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"replies": {
|
"replies": {
|
||||||
"id": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519/replies",
|
"id": "https://masto.qa.urbanwildlife.biz/users/mastodon/statuses/110830743680706519/replies",
|
||||||
"type": "Collection",
|
"type": "Collection",
|
||||||
"first": {
|
"first": {
|
||||||
"type": "CollectionPage",
|
"type": "CollectionPage",
|
||||||
"next": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519/replies?only_other_accounts=true&page=true",
|
"next": "https://masto.qa.urbanwildlife.biz/users/mastodon/statuses/110830743680706519/replies?only_other_accounts=true&page=true",
|
||||||
"partOf": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519/replies",
|
"partOf": "https://masto.qa.urbanwildlife.biz/users/mastodon/statuses/110830743680706519/replies",
|
||||||
"items": []
|
"items": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ impl BlockUser {
|
||||||
)?,
|
)?,
|
||||||
audience,
|
audience,
|
||||||
expires,
|
expires,
|
||||||
|
end_time: expires,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +150,7 @@ impl ActivityHandler for BlockUser {
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||||
insert_received_activity(&self.id, context).await?;
|
insert_received_activity(&self.id, context).await?;
|
||||||
let expires = self.expires.map(Into::into);
|
let expires = self.expires.or(self.end_time).map(Into::into);
|
||||||
let mod_person = self.actor.dereference(context).await?;
|
let mod_person = self.actor.dereference(context).await?;
|
||||||
let blocked_person = self.object.dereference(context).await?;
|
let blocked_person = self.object.dereference(context).await?;
|
||||||
let target = self.target.dereference(context).await?;
|
let target = self.target.dereference(context).await?;
|
||||||
|
|
|
@ -98,7 +98,7 @@ impl ActivityHandler for UndoBlockUser {
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||||
insert_received_activity(&self.id, context).await?;
|
insert_received_activity(&self.id, context).await?;
|
||||||
let expires = self.object.expires.map(Into::into);
|
let expires = self.object.expires.or(self.object.end_time).map(Into::into);
|
||||||
let mod_person = self.actor.dereference(context).await?;
|
let mod_person = self.actor.dereference(context).await?;
|
||||||
let blocked_person = self.object.object.dereference(context).await?;
|
let blocked_person = self.object.object.dereference(context).await?;
|
||||||
match self.object.target.dereference(context).await? {
|
match self.object.target.dereference(context).await? {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::{
|
||||||
activities::{
|
activities::{
|
||||||
generate_activity_id,
|
generate_activity_id,
|
||||||
verify_person_in_community,
|
verify_person_in_community,
|
||||||
voting::{vote_comment, vote_post},
|
voting::{undo_vote_comment, undo_vote_post, vote_comment, vote_post},
|
||||||
},
|
},
|
||||||
insert_received_activity,
|
insert_received_activity,
|
||||||
objects::{community::ApubCommunity, person::ApubPerson},
|
objects::{community::ApubCommunity, person::ApubPerson},
|
||||||
|
@ -17,7 +17,6 @@ use activitypub_federation::{
|
||||||
fetch::object_id::ObjectId,
|
fetch::object_id::ObjectId,
|
||||||
traits::{ActivityHandler, Actor},
|
traits::{ActivityHandler, Actor},
|
||||||
};
|
};
|
||||||
use anyhow::anyhow;
|
|
||||||
use lemmy_api_common::{context::LemmyContext, utils::check_bot_account};
|
use lemmy_api_common::{context::LemmyContext, utils::check_bot_account};
|
||||||
use lemmy_db_schema::source::local_site::LocalSite;
|
use lemmy_db_schema::source::local_site::LocalSite;
|
||||||
use lemmy_utils::error::LemmyError;
|
use lemmy_utils::error::LemmyError;
|
||||||
|
@ -58,16 +57,8 @@ impl ActivityHandler for Vote {
|
||||||
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||||
let community = self.community(context).await?;
|
let community = self.community(context).await?;
|
||||||
verify_person_in_community(&self.actor, &community, context).await?;
|
verify_person_in_community(&self.actor, &community, context).await?;
|
||||||
let enable_downvotes = LocalSite::read(&mut context.pool())
|
|
||||||
.await
|
|
||||||
.map(|l| l.enable_downvotes)
|
|
||||||
.unwrap_or(true);
|
|
||||||
if self.kind == VoteType::Dislike && !enable_downvotes {
|
|
||||||
Err(anyhow!("Downvotes disabled").into())
|
|
||||||
} else {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||||
|
@ -77,9 +68,22 @@ impl ActivityHandler for Vote {
|
||||||
|
|
||||||
check_bot_account(&actor.0)?;
|
check_bot_account(&actor.0)?;
|
||||||
|
|
||||||
|
let enable_downvotes = LocalSite::read(&mut context.pool())
|
||||||
|
.await
|
||||||
|
.map(|l| l.enable_downvotes)
|
||||||
|
.unwrap_or(true);
|
||||||
|
if self.kind == VoteType::Dislike && !enable_downvotes {
|
||||||
|
// If this is a downvote but downvotes are ignored, only undo any existing vote
|
||||||
|
match object {
|
||||||
|
PostOrComment::Post(p) => undo_vote_post(actor, &p, context).await,
|
||||||
|
PostOrComment::Comment(c) => undo_vote_comment(actor, &c, context).await,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Otherwise apply the vote normally
|
||||||
match object {
|
match object {
|
||||||
PostOrComment::Post(p) => vote_post(&self.kind, actor, &p, context).await,
|
PostOrComment::Post(p) => vote_post(&self.kind, actor, &p, context).await,
|
||||||
PostOrComment::Comment(c) => vote_comment(&self.kind, actor, &c, context).await,
|
PostOrComment::Comment(c) => vote_comment(&self.kind, actor, &c, context).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,8 +123,8 @@ impl InCommunity for AnnouncableActivities {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
activity_lists::{GroupInboxActivities, PersonInboxActivities, SharedInboxActivities},
|
activity_lists::{GroupInboxActivities, PersonInboxActivities, SharedInboxActivities},
|
||||||
|
|
|
@ -27,7 +27,10 @@ pub async fn list_comments(
|
||||||
check_private_instance(&local_user_view, &local_site)?;
|
check_private_instance(&local_user_view, &local_site)?;
|
||||||
|
|
||||||
let community_id = if let Some(name) = &data.community_name {
|
let community_id = if let Some(name) = &data.community_name {
|
||||||
Some(resolve_actor_identifier::<ApubCommunity, Community>(name, &context, &None, true).await?)
|
Some(
|
||||||
|
resolve_actor_identifier::<ApubCommunity, Community>(name, &context, &local_user_view, true)
|
||||||
|
.await?,
|
||||||
|
)
|
||||||
.map(|c| c.id)
|
.map(|c| c.id)
|
||||||
} else {
|
} else {
|
||||||
data.community_id
|
data.community_id
|
||||||
|
|
|
@ -30,7 +30,10 @@ pub async fn list_posts(
|
||||||
let page = data.page;
|
let page = data.page;
|
||||||
let limit = data.limit;
|
let limit = data.limit;
|
||||||
let community_id = if let Some(name) = &data.community_name {
|
let community_id = if let Some(name) = &data.community_name {
|
||||||
Some(resolve_actor_identifier::<ApubCommunity, Community>(name, &context, &None, true).await?)
|
Some(
|
||||||
|
resolve_actor_identifier::<ApubCommunity, Community>(name, &context, &local_user_view, true)
|
||||||
|
.await?,
|
||||||
|
)
|
||||||
.map(|c| c.id)
|
.map(|c| c.id)
|
||||||
} else {
|
} else {
|
||||||
data.community_id
|
data.community_id
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::fetcher::search::{
|
use crate::fetcher::{
|
||||||
search_query_to_object_id,
|
search::{search_query_to_object_id, search_query_to_object_id_local, SearchableObjects},
|
||||||
search_query_to_object_id_local,
|
user_or_community::UserOrCommunity,
|
||||||
SearchableObjects,
|
|
||||||
};
|
};
|
||||||
use activitypub_federation::config::Data;
|
use activitypub_federation::config::Data;
|
||||||
use actix_web::web::{Json, Query};
|
use actix_web::web::{Json, Query};
|
||||||
|
@ -31,7 +30,7 @@ pub async fn resolve_object(
|
||||||
|
|
||||||
let res = if is_authenticated {
|
let res = if is_authenticated {
|
||||||
// user is fully authenticated; allow remote lookups as well.
|
// user is fully authenticated; allow remote lookups as well.
|
||||||
search_query_to_object_id(&data.q, &context).await
|
search_query_to_object_id(data.q.clone(), &context).await
|
||||||
} else {
|
} else {
|
||||||
// user isn't authenticated only allow a local search.
|
// user isn't authenticated only allow a local search.
|
||||||
search_query_to_object_id_local(&data.q, &context).await
|
search_query_to_object_id_local(&data.q, &context).await
|
||||||
|
@ -52,14 +51,6 @@ async fn convert_response(
|
||||||
let removed_or_deleted;
|
let removed_or_deleted;
|
||||||
let mut res = ResolveObjectResponse::default();
|
let mut res = ResolveObjectResponse::default();
|
||||||
match object {
|
match object {
|
||||||
Person(p) => {
|
|
||||||
removed_or_deleted = p.deleted;
|
|
||||||
res.person = Some(PersonView::read(pool, p.id).await?)
|
|
||||||
}
|
|
||||||
Community(c) => {
|
|
||||||
removed_or_deleted = c.deleted || c.removed;
|
|
||||||
res.community = Some(CommunityView::read(pool, c.id, user_id, false).await?)
|
|
||||||
}
|
|
||||||
Post(p) => {
|
Post(p) => {
|
||||||
removed_or_deleted = p.deleted || p.removed;
|
removed_or_deleted = p.deleted || p.removed;
|
||||||
res.post = Some(PostView::read(pool, p.id, user_id, false).await?)
|
res.post = Some(PostView::read(pool, p.id, user_id, false).await?)
|
||||||
|
@ -68,6 +59,16 @@ async fn convert_response(
|
||||||
removed_or_deleted = c.deleted || c.removed;
|
removed_or_deleted = c.deleted || c.removed;
|
||||||
res.comment = Some(CommentView::read(pool, c.id, user_id).await?)
|
res.comment = Some(CommentView::read(pool, c.id, user_id).await?)
|
||||||
}
|
}
|
||||||
|
PersonOrCommunity(p) => match *p {
|
||||||
|
UserOrCommunity::User(u) => {
|
||||||
|
removed_or_deleted = u.deleted;
|
||||||
|
res.person = Some(PersonView::read(pool, u.id).await?)
|
||||||
|
}
|
||||||
|
UserOrCommunity::Community(c) => {
|
||||||
|
removed_or_deleted = c.deleted || c.removed;
|
||||||
|
res.community = Some(CommunityView::read(pool, c.id, user_id, false).await?)
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
// if the object was deleted from database, dont return it
|
// if the object was deleted from database, dont return it
|
||||||
if removed_or_deleted {
|
if removed_or_deleted {
|
||||||
|
|
|
@ -17,6 +17,7 @@ use lemmy_db_schema::{
|
||||||
instance::Instance,
|
instance::Instance,
|
||||||
instance_block::{InstanceBlock, InstanceBlockForm},
|
instance_block::{InstanceBlock, InstanceBlockForm},
|
||||||
local_user::{LocalUser, LocalUserUpdateForm},
|
local_user::{LocalUser, LocalUserUpdateForm},
|
||||||
|
local_user_vote_display_mode::{LocalUserVoteDisplayMode, LocalUserVoteDisplayModeUpdateForm},
|
||||||
person::{Person, PersonUpdateForm},
|
person::{Person, PersonUpdateForm},
|
||||||
person_block::{PersonBlock, PersonBlockForm},
|
person_block::{PersonBlock, PersonBlockForm},
|
||||||
post::{PostSaved, PostSavedForm},
|
post::{PostSaved, PostSavedForm},
|
||||||
|
@ -50,6 +51,7 @@ pub struct UserSettingsBackup {
|
||||||
// TODO: might be worth making a separate struct for settings backup, to avoid breakage in case
|
// TODO: might be worth making a separate struct for settings backup, to avoid breakage in case
|
||||||
// fields are renamed, and to avoid storing unnecessary fields like person_id or email
|
// fields are renamed, and to avoid storing unnecessary fields like person_id or email
|
||||||
pub settings: Option<LocalUser>,
|
pub settings: Option<LocalUser>,
|
||||||
|
pub vote_display_mode_settings: Option<LocalUserVoteDisplayMode>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub followed_communities: Vec<ObjectId<ApubCommunity>>,
|
pub followed_communities: Vec<ObjectId<ApubCommunity>>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
@ -80,6 +82,7 @@ pub async fn export_settings(
|
||||||
matrix_id: local_user_view.person.matrix_user_id,
|
matrix_id: local_user_view.person.matrix_user_id,
|
||||||
bot_account: local_user_view.person.bot_account.into(),
|
bot_account: local_user_view.person.bot_account.into(),
|
||||||
settings: Some(local_user_view.local_user),
|
settings: Some(local_user_view.local_user),
|
||||||
|
vote_display_mode_settings: Some(local_user_view.local_user_vote_display_mode),
|
||||||
followed_communities: vec_into(lists.followed_communities),
|
followed_communities: vec_into(lists.followed_communities),
|
||||||
blocked_communities: vec_into(lists.blocked_communities),
|
blocked_communities: vec_into(lists.blocked_communities),
|
||||||
blocked_instances: lists.blocked_instances,
|
blocked_instances: lists.blocked_instances,
|
||||||
|
@ -132,6 +135,27 @@ pub async fn import_settings(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
// Update the vote display mode settings
|
||||||
|
let vote_display_mode_form = LocalUserVoteDisplayModeUpdateForm {
|
||||||
|
score: data.vote_display_mode_settings.as_ref().map(|s| s.score),
|
||||||
|
upvotes: data.vote_display_mode_settings.as_ref().map(|s| s.upvotes),
|
||||||
|
downvotes: data
|
||||||
|
.vote_display_mode_settings
|
||||||
|
.as_ref()
|
||||||
|
.map(|s| s.downvotes),
|
||||||
|
upvote_percentage: data
|
||||||
|
.vote_display_mode_settings
|
||||||
|
.as_ref()
|
||||||
|
.map(|s| s.upvote_percentage),
|
||||||
|
};
|
||||||
|
|
||||||
|
LocalUserVoteDisplayMode::update(
|
||||||
|
&mut context.pool(),
|
||||||
|
local_user_view.local_user.id,
|
||||||
|
&vote_display_mode_form,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
let url_count = data.followed_communities.len()
|
let url_count = data.followed_communities.len()
|
||||||
+ data.blocked_communities.len()
|
+ data.blocked_communities.len()
|
||||||
+ data.blocked_users.len()
|
+ data.blocked_users.len()
|
||||||
|
@ -295,8 +319,8 @@ pub async fn import_settings(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::api::user_settings_backup::{export_settings, import_settings};
|
use crate::api::user_settings_backup::{export_settings, import_settings};
|
||||||
use activitypub_federation::config::Data;
|
use activitypub_federation::config::Data;
|
||||||
|
@ -337,7 +361,7 @@ mod tests {
|
||||||
.person_id(person.id)
|
.person_id(person.id)
|
||||||
.password_encrypted("pass".to_string())
|
.password_encrypted("pass".to_string())
|
||||||
.build();
|
.build();
|
||||||
let local_user = LocalUser::create(&mut context.pool(), &user_form).await?;
|
let local_user = LocalUser::create(&mut context.pool(), &user_form, vec![]).await?;
|
||||||
|
|
||||||
Ok(LocalUserView::read(&mut context.pool(), local_user.id).await?)
|
Ok(LocalUserView::read(&mut context.pool(), local_user.id).await?)
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,8 +101,8 @@ impl Collection for ApubCommunityModerators {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
|
fetcher::user_or_community::{PersonOrGroup, UserOrCommunity},
|
||||||
objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson, post::ApubPost},
|
objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson, post::ApubPost},
|
||||||
protocol::objects::{group::Group, note::Note, page::Page, person::Person},
|
protocol::objects::{note::Note, page::Page},
|
||||||
};
|
};
|
||||||
use activitypub_federation::{
|
use activitypub_federation::{
|
||||||
config::Data,
|
config::Data,
|
||||||
|
@ -9,7 +10,7 @@ use activitypub_federation::{
|
||||||
};
|
};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use lemmy_api_common::context::LemmyContext;
|
use lemmy_api_common::context::LemmyContext;
|
||||||
use lemmy_utils::error::{LemmyError, LemmyErrorType};
|
use lemmy_utils::error::LemmyError;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -18,28 +19,22 @@ use url::Url;
|
||||||
/// which gets resolved to an URL.
|
/// which gets resolved to an URL.
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
pub(crate) async fn search_query_to_object_id(
|
pub(crate) async fn search_query_to_object_id(
|
||||||
query: &str,
|
mut query: String,
|
||||||
context: &Data<LemmyContext>,
|
context: &Data<LemmyContext>,
|
||||||
) -> Result<SearchableObjects, LemmyError> {
|
) -> Result<SearchableObjects, LemmyError> {
|
||||||
Ok(match Url::parse(query) {
|
Ok(match Url::parse(&query) {
|
||||||
Ok(url) => {
|
Ok(url) => {
|
||||||
// its already an url, just go with it
|
// its already an url, just go with it
|
||||||
ObjectId::from(url).dereference(context).await?
|
ObjectId::from(url).dereference(context).await?
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// not an url, try to resolve via webfinger
|
// not an url, try to resolve via webfinger
|
||||||
let mut chars = query.chars();
|
if query.starts_with('!') || query.starts_with('@') {
|
||||||
let kind = chars.next();
|
query.remove(0);
|
||||||
let identifier = chars.as_str();
|
|
||||||
match kind {
|
|
||||||
Some('@') => SearchableObjects::Person(
|
|
||||||
webfinger_resolve_actor::<LemmyContext, ApubPerson>(identifier, context).await?,
|
|
||||||
),
|
|
||||||
Some('!') => SearchableObjects::Community(
|
|
||||||
webfinger_resolve_actor::<LemmyContext, ApubCommunity>(identifier, context).await?,
|
|
||||||
),
|
|
||||||
_ => return Err(LemmyErrorType::InvalidQuery)?,
|
|
||||||
}
|
}
|
||||||
|
SearchableObjects::PersonOrCommunity(Box::new(
|
||||||
|
webfinger_resolve_actor::<LemmyContext, UserOrCommunity>(&query, context).await?,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -59,19 +54,17 @@ pub(crate) async fn search_query_to_object_id_local(
|
||||||
/// The types of ActivityPub objects that can be fetched directly by searching for their ID.
|
/// The types of ActivityPub objects that can be fetched directly by searching for their ID.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) enum SearchableObjects {
|
pub(crate) enum SearchableObjects {
|
||||||
Person(ApubPerson),
|
|
||||||
Community(ApubCommunity),
|
|
||||||
Post(ApubPost),
|
Post(ApubPost),
|
||||||
Comment(ApubComment),
|
Comment(ApubComment),
|
||||||
|
PersonOrCommunity(Box<UserOrCommunity>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub(crate) enum SearchableKinds {
|
pub(crate) enum SearchableKinds {
|
||||||
Group(Group),
|
Page(Box<Page>),
|
||||||
Person(Person),
|
|
||||||
Page(Page),
|
|
||||||
Note(Note),
|
Note(Note),
|
||||||
|
PersonOrGroup(Box<PersonOrGroup>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
|
@ -82,10 +75,9 @@ impl Object for SearchableObjects {
|
||||||
|
|
||||||
fn last_refreshed_at(&self) -> Option<DateTime<Utc>> {
|
fn last_refreshed_at(&self) -> Option<DateTime<Utc>> {
|
||||||
match self {
|
match self {
|
||||||
SearchableObjects::Person(p) => p.last_refreshed_at(),
|
|
||||||
SearchableObjects::Community(c) => c.last_refreshed_at(),
|
|
||||||
SearchableObjects::Post(p) => p.last_refreshed_at(),
|
SearchableObjects::Post(p) => p.last_refreshed_at(),
|
||||||
SearchableObjects::Comment(c) => c.last_refreshed_at(),
|
SearchableObjects::Comment(c) => c.last_refreshed_at(),
|
||||||
|
SearchableObjects::PersonOrCommunity(p) => p.last_refreshed_at(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,13 +91,9 @@ impl Object for SearchableObjects {
|
||||||
object_id: Url,
|
object_id: Url,
|
||||||
context: &Data<Self::DataType>,
|
context: &Data<Self::DataType>,
|
||||||
) -> Result<Option<Self>, LemmyError> {
|
) -> Result<Option<Self>, LemmyError> {
|
||||||
let c = ApubCommunity::read_from_id(object_id.clone(), context).await?;
|
let uc = UserOrCommunity::read_from_id(object_id.clone(), context).await?;
|
||||||
if let Some(c) = c {
|
if let Some(uc) = uc {
|
||||||
return Ok(Some(SearchableObjects::Community(c)));
|
return Ok(Some(SearchableObjects::PersonOrCommunity(Box::new(uc))));
|
||||||
}
|
|
||||||
let p = ApubPerson::read_from_id(object_id.clone(), context).await?;
|
|
||||||
if let Some(p) = p {
|
|
||||||
return Ok(Some(SearchableObjects::Person(p)));
|
|
||||||
}
|
}
|
||||||
let p = ApubPost::read_from_id(object_id.clone(), context).await?;
|
let p = ApubPost::read_from_id(object_id.clone(), context).await?;
|
||||||
if let Some(p) = p {
|
if let Some(p) = p {
|
||||||
|
@ -121,10 +109,12 @@ impl Object for SearchableObjects {
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
async fn delete(self, data: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
async fn delete(self, data: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||||
match self {
|
match self {
|
||||||
SearchableObjects::Person(p) => p.delete(data).await,
|
|
||||||
SearchableObjects::Community(c) => c.delete(data).await,
|
|
||||||
SearchableObjects::Post(p) => p.delete(data).await,
|
SearchableObjects::Post(p) => p.delete(data).await,
|
||||||
SearchableObjects::Comment(c) => c.delete(data).await,
|
SearchableObjects::Comment(c) => c.delete(data).await,
|
||||||
|
SearchableObjects::PersonOrCommunity(pc) => match *pc {
|
||||||
|
UserOrCommunity::User(p) => p.delete(data).await,
|
||||||
|
UserOrCommunity::Community(c) => c.delete(data).await,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,10 +129,12 @@ impl Object for SearchableObjects {
|
||||||
data: &Data<Self::DataType>,
|
data: &Data<Self::DataType>,
|
||||||
) -> Result<(), LemmyError> {
|
) -> Result<(), LemmyError> {
|
||||||
match apub {
|
match apub {
|
||||||
SearchableKinds::Group(a) => ApubCommunity::verify(a, expected_domain, data).await,
|
|
||||||
SearchableKinds::Person(a) => ApubPerson::verify(a, expected_domain, data).await,
|
|
||||||
SearchableKinds::Page(a) => ApubPost::verify(a, expected_domain, data).await,
|
SearchableKinds::Page(a) => ApubPost::verify(a, expected_domain, data).await,
|
||||||
SearchableKinds::Note(a) => ApubComment::verify(a, expected_domain, data).await,
|
SearchableKinds::Note(a) => ApubComment::verify(a, expected_domain, data).await,
|
||||||
|
SearchableKinds::PersonOrGroup(pg) => match pg.as_ref() {
|
||||||
|
PersonOrGroup::Person(a) => ApubPerson::verify(a, expected_domain, data).await,
|
||||||
|
PersonOrGroup::Group(a) => ApubCommunity::verify(a, expected_domain, data).await,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,10 +143,11 @@ impl Object for SearchableObjects {
|
||||||
use SearchableKinds as SAT;
|
use SearchableKinds as SAT;
|
||||||
use SearchableObjects as SO;
|
use SearchableObjects as SO;
|
||||||
Ok(match apub {
|
Ok(match apub {
|
||||||
SAT::Group(g) => SO::Community(ApubCommunity::from_json(g, context).await?),
|
SAT::Page(p) => SO::Post(ApubPost::from_json(*p, context).await?),
|
||||||
SAT::Person(p) => SO::Person(ApubPerson::from_json(p, context).await?),
|
|
||||||
SAT::Page(p) => SO::Post(ApubPost::from_json(p, context).await?),
|
|
||||||
SAT::Note(n) => SO::Comment(ApubComment::from_json(n, context).await?),
|
SAT::Note(n) => SO::Comment(ApubComment::from_json(n, context).await?),
|
||||||
|
SAT::PersonOrGroup(pg) => {
|
||||||
|
SO::PersonOrCommunity(Box::new(UserOrCommunity::from_json(*pg, context).await?))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ pub(crate) async fn get_apub_community_followers(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the community outbox, which is populated by a maximum of 20 posts (but no other
|
/// Returns the community outbox, which is populated by a maximum of 20 posts (but no other
|
||||||
/// activites like votes or comments).
|
/// activities like votes or comments).
|
||||||
pub(crate) async fn get_apub_community_outbox(
|
pub(crate) async fn get_apub_community_outbox(
|
||||||
info: web::Path<CommunityQuery>,
|
info: web::Path<CommunityQuery>,
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
|
@ -115,9 +115,9 @@ pub(crate) async fn get_apub_community_featured(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
pub(crate) mod tests {
|
pub(crate) mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::protocol::objects::{group::Group, tombstone::Tombstone};
|
use crate::protocol::objects::{group::Group, tombstone::Tombstone};
|
||||||
|
|
|
@ -18,7 +18,7 @@ use activitypub_federation::{
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
utils::{is_mod_or_admin, local_site_opt_to_slur_regex, process_markdown},
|
utils::{get_url_blocklist, is_mod_or_admin, local_site_opt_to_slur_regex, process_markdown},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
|
@ -165,7 +165,8 @@ impl Object for ApubComment {
|
||||||
|
|
||||||
let local_site = LocalSite::read(&mut context.pool()).await.ok();
|
let local_site = LocalSite::read(&mut context.pool()).await.ok();
|
||||||
let slur_regex = &local_site_opt_to_slur_regex(&local_site);
|
let slur_regex = &local_site_opt_to_slur_regex(&local_site);
|
||||||
let content = process_markdown(&content, slur_regex, context).await?;
|
let url_blocklist = get_url_blocklist(context).await?;
|
||||||
|
let content = process_markdown(&content, slur_regex, &url_blocklist, context).await?;
|
||||||
let language_id =
|
let language_id =
|
||||||
LanguageTag::to_language_id_single(note.language, &mut context.pool()).await?;
|
LanguageTag::to_language_id_single(note.language, &mut context.pool()).await?;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ use lemmy_api_common::{
|
||||||
generate_featured_url,
|
generate_featured_url,
|
||||||
generate_moderators_url,
|
generate_moderators_url,
|
||||||
generate_outbox_url,
|
generate_outbox_url,
|
||||||
|
get_url_blocklist,
|
||||||
local_site_opt_to_slur_regex,
|
local_site_opt_to_slur_regex,
|
||||||
process_markdown_opt,
|
process_markdown_opt,
|
||||||
proxy_image_link_opt_apub,
|
proxy_image_link_opt_apub,
|
||||||
|
@ -141,8 +142,10 @@ impl Object for ApubCommunity {
|
||||||
|
|
||||||
let local_site = LocalSite::read(&mut context.pool()).await.ok();
|
let local_site = LocalSite::read(&mut context.pool()).await.ok();
|
||||||
let slur_regex = &local_site_opt_to_slur_regex(&local_site);
|
let slur_regex = &local_site_opt_to_slur_regex(&local_site);
|
||||||
|
let url_blocklist = get_url_blocklist(context).await?;
|
||||||
let description = read_from_string_or_source_opt(&group.summary, &None, &group.source);
|
let description = read_from_string_or_source_opt(&group.summary, &None, &group.source);
|
||||||
let description = process_markdown_opt(&description, slur_regex, context).await?;
|
let description =
|
||||||
|
process_markdown_opt(&description, slur_regex, &url_blocklist, context).await?;
|
||||||
let icon = proxy_image_link_opt_apub(group.icon.map(|i| i.url), context).await?;
|
let icon = proxy_image_link_opt_apub(group.icon.map(|i| i.url), context).await?;
|
||||||
let banner = proxy_image_link_opt_apub(group.image.map(|i| i.url), context).await?;
|
let banner = proxy_image_link_opt_apub(group.image.map(|i| i.url), context).await?;
|
||||||
|
|
||||||
|
@ -177,18 +180,21 @@ impl Object for ApubCommunity {
|
||||||
|
|
||||||
let community: ApubCommunity = community.into();
|
let community: ApubCommunity = community.into();
|
||||||
|
|
||||||
// Fetching mods and outbox is not necessary for Lemmy to work, so ignore errors. Besides,
|
// These collections are not necessary for Lemmy to work, so ignore errors.
|
||||||
// we need to ignore these errors so that tests can work entirely offline.
|
|
||||||
let community_ = community.clone();
|
let community_ = community.clone();
|
||||||
let context_ = context.reset_request_count();
|
let context_ = context.reset_request_count();
|
||||||
spawn_try_task(async move {
|
spawn_try_task(async move {
|
||||||
group.outbox.dereference(&community_, &context_).await?;
|
group.outbox.dereference(&community_, &context_).await.ok();
|
||||||
group.followers.dereference(&community_, &context_).await?;
|
group
|
||||||
|
.followers
|
||||||
|
.dereference(&community_, &context_)
|
||||||
|
.await
|
||||||
|
.ok();
|
||||||
if let Some(featured) = group.featured {
|
if let Some(featured) = group.featured {
|
||||||
featured.dereference(&community_, &context_).await?;
|
featured.dereference(&community_, &context_).await.ok();
|
||||||
}
|
}
|
||||||
if let Some(moderators) = group.attributed_to {
|
if let Some(moderators) = group.attributed_to {
|
||||||
moderators.dereference(&community_, &context_).await?;
|
moderators.dereference(&community_, &context_).await.ok();
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,7 +19,12 @@ use activitypub_federation::{
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
utils::{local_site_opt_to_slur_regex, process_markdown_opt, proxy_image_link_opt_apub},
|
utils::{
|
||||||
|
get_url_blocklist,
|
||||||
|
local_site_opt_to_slur_regex,
|
||||||
|
process_markdown_opt,
|
||||||
|
proxy_image_link_opt_apub,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
newtypes::InstanceId,
|
newtypes::InstanceId,
|
||||||
|
@ -96,6 +101,7 @@ impl Object for ApubSite {
|
||||||
kind: ApplicationType::Application,
|
kind: ApplicationType::Application,
|
||||||
id: self.id().into(),
|
id: self.id().into(),
|
||||||
name: self.name.clone(),
|
name: self.name.clone(),
|
||||||
|
preferred_username: data.domain().to_string(),
|
||||||
content: self.sidebar.as_ref().map(|d| markdown_to_html(d)),
|
content: self.sidebar.as_ref().map(|d| markdown_to_html(d)),
|
||||||
source: self.sidebar.clone().map(Source::new),
|
source: self.sidebar.clone().map(Source::new),
|
||||||
summary: self.description.clone(),
|
summary: self.description.clone(),
|
||||||
|
@ -137,8 +143,9 @@ impl Object for ApubSite {
|
||||||
|
|
||||||
let local_site = LocalSite::read(&mut context.pool()).await.ok();
|
let local_site = LocalSite::read(&mut context.pool()).await.ok();
|
||||||
let slur_regex = &local_site_opt_to_slur_regex(&local_site);
|
let slur_regex = &local_site_opt_to_slur_regex(&local_site);
|
||||||
|
let url_blocklist = get_url_blocklist(context).await?;
|
||||||
let sidebar = read_from_string_or_source_opt(&apub.content, &None, &apub.source);
|
let sidebar = read_from_string_or_source_opt(&apub.content, &None, &apub.source);
|
||||||
let sidebar = process_markdown_opt(&sidebar, slur_regex, context).await?;
|
let sidebar = process_markdown_opt(&sidebar, slur_regex, &url_blocklist, context).await?;
|
||||||
let icon = proxy_image_link_opt_apub(apub.icon.map(|i| i.url), context).await?;
|
let icon = proxy_image_link_opt_apub(apub.icon.map(|i| i.url), context).await?;
|
||||||
let banner = proxy_image_link_opt_apub(apub.image.map(|i| i.url), context).await?;
|
let banner = proxy_image_link_opt_apub(apub.image.map(|i| i.url), context).await?;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ use lemmy_api_common::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
utils::{
|
utils::{
|
||||||
generate_outbox_url,
|
generate_outbox_url,
|
||||||
|
get_url_blocklist,
|
||||||
local_site_opt_to_slur_regex,
|
local_site_opt_to_slur_regex,
|
||||||
process_markdown_opt,
|
process_markdown_opt,
|
||||||
proxy_image_link_opt_apub,
|
proxy_image_link_opt_apub,
|
||||||
|
@ -152,8 +153,9 @@ impl Object for ApubPerson {
|
||||||
|
|
||||||
let local_site = LocalSite::read(&mut context.pool()).await.ok();
|
let local_site = LocalSite::read(&mut context.pool()).await.ok();
|
||||||
let slur_regex = &local_site_opt_to_slur_regex(&local_site);
|
let slur_regex = &local_site_opt_to_slur_regex(&local_site);
|
||||||
|
let url_blocklist = get_url_blocklist(context).await?;
|
||||||
let bio = read_from_string_or_source_opt(&person.summary, &None, &person.source);
|
let bio = read_from_string_or_source_opt(&person.summary, &None, &person.source);
|
||||||
let bio = process_markdown_opt(&bio, slur_regex, context).await?;
|
let bio = process_markdown_opt(&bio, slur_regex, &url_blocklist, context).await?;
|
||||||
let avatar = proxy_image_link_opt_apub(person.icon.map(|i| i.url), context).await?;
|
let avatar = proxy_image_link_opt_apub(person.icon.map(|i| i.url), context).await?;
|
||||||
let banner = proxy_image_link_opt_apub(person.image.map(|i| i.url), context).await?;
|
let banner = proxy_image_link_opt_apub(person.image.map(|i| i.url), context).await?;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
||||||
objects::{read_from_string_or_source_opt, verify_is_remote_object},
|
objects::{read_from_string_or_source_opt, verify_is_remote_object},
|
||||||
protocol::{
|
protocol::{
|
||||||
objects::{
|
objects::{
|
||||||
page::{Attachment, AttributedTo, Page, PageType},
|
page::{Attachment, AttributedTo, Hashtag, HashtagType, Page, PageType},
|
||||||
LanguageTag,
|
LanguageTag,
|
||||||
},
|
},
|
||||||
ImageObject,
|
ImageObject,
|
||||||
|
@ -26,7 +26,7 @@ use lemmy_api_common::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
request::fetch_link_metadata_opt,
|
request::fetch_link_metadata_opt,
|
||||||
utils::{
|
utils::{
|
||||||
is_mod_or_admin,
|
get_url_blocklist,
|
||||||
local_site_opt_to_sensitive,
|
local_site_opt_to_sensitive,
|
||||||
local_site_opt_to_slur_regex,
|
local_site_opt_to_slur_regex,
|
||||||
process_markdown_opt,
|
process_markdown_opt,
|
||||||
|
@ -43,6 +43,7 @@ use lemmy_db_schema::{
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
|
use lemmy_db_views_actor::structs::CommunityModeratorView;
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
error::LemmyError,
|
error::LemmyError,
|
||||||
utils::{markdown::markdown_to_html, slurs::check_slurs_opt, validation::check_url_scheme},
|
utils::{markdown::markdown_to_html, slurs::check_slurs_opt, validation::check_url_scheme},
|
||||||
|
@ -124,6 +125,11 @@ impl Object for ApubPost {
|
||||||
})
|
})
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect();
|
.collect();
|
||||||
|
let hashtag = Hashtag {
|
||||||
|
href: self.ap_id.clone().into(),
|
||||||
|
name: format!("#{}", &community.name),
|
||||||
|
kind: HashtagType::Hashtag,
|
||||||
|
};
|
||||||
|
|
||||||
let page = Page {
|
let page = Page {
|
||||||
kind: PageType::Page,
|
kind: PageType::Page,
|
||||||
|
@ -144,6 +150,7 @@ impl Object for ApubPost {
|
||||||
updated: self.updated,
|
updated: self.updated,
|
||||||
audience: Some(community.actor_id.into()),
|
audience: Some(community.actor_id.into()),
|
||||||
in_reply_to: None,
|
in_reply_to: None,
|
||||||
|
tag: vec![hashtag],
|
||||||
};
|
};
|
||||||
Ok(page)
|
Ok(page)
|
||||||
}
|
}
|
||||||
|
@ -179,7 +186,8 @@ impl Object for ApubPost {
|
||||||
let creator = page.creator()?.dereference(context).await?;
|
let creator = page.creator()?.dereference(context).await?;
|
||||||
let community = page.community(context).await?;
|
let community = page.community(context).await?;
|
||||||
if community.posting_restricted_to_mods {
|
if community.posting_restricted_to_mods {
|
||||||
is_mod_or_admin(&mut context.pool(), &creator, community.id).await?;
|
CommunityModeratorView::is_community_moderator(&mut context.pool(), community.id, creator.id)
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
let mut name = page
|
let mut name = page
|
||||||
.name
|
.name
|
||||||
|
@ -239,9 +247,10 @@ impl Object for ApubPost {
|
||||||
let thumbnail_url = proxy_image_link_opt_apub(thumbnail_url, context).await?;
|
let thumbnail_url = proxy_image_link_opt_apub(thumbnail_url, context).await?;
|
||||||
|
|
||||||
let slur_regex = &local_site_opt_to_slur_regex(&local_site);
|
let slur_regex = &local_site_opt_to_slur_regex(&local_site);
|
||||||
|
let url_blocklist = get_url_blocklist(context).await?;
|
||||||
|
|
||||||
let body = read_from_string_or_source_opt(&page.content, &page.media_type, &page.source);
|
let body = read_from_string_or_source_opt(&page.content, &page.media_type, &page.source);
|
||||||
let body = process_markdown_opt(&body, slur_regex, context).await?;
|
let body = process_markdown_opt(&body, slur_regex, &url_blocklist, context).await?;
|
||||||
let language_id =
|
let language_id =
|
||||||
LanguageTag::to_language_id_single(page.language, &mut context.pool()).await?;
|
LanguageTag::to_language_id_single(page.language, &mut context.pool()).await?;
|
||||||
|
|
||||||
|
@ -302,8 +311,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
objects::{
|
objects::{
|
||||||
community::{tests::parse_lemmy_community, ApubCommunity},
|
community::tests::parse_lemmy_community,
|
||||||
instance::ApubSite,
|
|
||||||
person::{tests::parse_lemmy_person, ApubPerson},
|
person::{tests::parse_lemmy_person, ApubPerson},
|
||||||
},
|
},
|
||||||
protocol::tests::file_to_json_object,
|
protocol::tests::file_to_json_object,
|
||||||
|
@ -333,7 +341,10 @@ mod tests {
|
||||||
assert!(!post.featured_community);
|
assert!(!post.featured_community);
|
||||||
assert_eq!(context.request_count(), 0);
|
assert_eq!(context.request_count(), 0);
|
||||||
|
|
||||||
cleanup(&context, person, site, community, post).await?;
|
Post::delete(&mut context.pool(), post.id).await?;
|
||||||
|
Person::delete(&mut context.pool(), person.id).await?;
|
||||||
|
Community::delete(&mut context.pool(), community.id).await?;
|
||||||
|
Site::delete(&mut context.pool(), site.id).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,29 +352,19 @@ mod tests {
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn test_convert_mastodon_post_title() -> LemmyResult<()> {
|
async fn test_convert_mastodon_post_title() -> LemmyResult<()> {
|
||||||
let context = LemmyContext::init_test_context().await;
|
let context = LemmyContext::init_test_context().await;
|
||||||
let (person, site) = parse_lemmy_person(&context).await?;
|
|
||||||
let community = parse_lemmy_community(&context).await?;
|
let community = parse_lemmy_community(&context).await?;
|
||||||
|
|
||||||
|
let json = file_to_json_object("assets/mastodon/objects/person.json")?;
|
||||||
|
let person = ApubPerson::from_json(json, &context).await?;
|
||||||
|
|
||||||
let json = file_to_json_object("assets/mastodon/objects/page.json")?;
|
let json = file_to_json_object("assets/mastodon/objects/page.json")?;
|
||||||
let post = ApubPost::from_json(json, &context).await?;
|
let post = ApubPost::from_json(json, &context).await?;
|
||||||
|
|
||||||
assert_eq!(post.name, "Variable never resetting at refresh");
|
assert_eq!(post.name, "Variable never resetting at refresh");
|
||||||
|
|
||||||
cleanup(&context, person, site, community, post).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn cleanup(
|
|
||||||
context: &Data<LemmyContext>,
|
|
||||||
person: ApubPerson,
|
|
||||||
site: ApubSite,
|
|
||||||
community: ApubCommunity,
|
|
||||||
post: ApubPost,
|
|
||||||
) -> LemmyResult<()> {
|
|
||||||
Post::delete(&mut context.pool(), post.id).await?;
|
Post::delete(&mut context.pool(), post.id).await?;
|
||||||
Person::delete(&mut context.pool(), person.id).await?;
|
Person::delete(&mut context.pool(), person.id).await?;
|
||||||
Community::delete(&mut context.pool(), community.id).await?;
|
Community::delete(&mut context.pool(), community.id).await?;
|
||||||
Site::delete(&mut context.pool(), site.id).await?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ use activitypub_federation::{
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
utils::{check_person_block, local_site_opt_to_slur_regex, process_markdown},
|
utils::{check_person_block, get_url_blocklist, local_site_opt_to_slur_regex, process_markdown},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
|
@ -127,8 +127,9 @@ impl Object for ApubPrivateMessage {
|
||||||
|
|
||||||
let local_site = LocalSite::read(&mut context.pool()).await.ok();
|
let local_site = LocalSite::read(&mut context.pool()).await.ok();
|
||||||
let slur_regex = &local_site_opt_to_slur_regex(&local_site);
|
let slur_regex = &local_site_opt_to_slur_regex(&local_site);
|
||||||
|
let url_blocklist = get_url_blocklist(context).await?;
|
||||||
let content = read_from_string_or_source(¬e.content, &None, ¬e.source);
|
let content = read_from_string_or_source(¬e.content, &None, ¬e.source);
|
||||||
let content = process_markdown(&content, slur_regex, context).await?;
|
let content = process_markdown(&content, slur_regex, &url_blocklist, context).await?;
|
||||||
|
|
||||||
let form = PrivateMessageInsertForm {
|
let form = PrivateMessageInsertForm {
|
||||||
creator_id: creator.id,
|
creator_id: creator.id,
|
||||||
|
|
|
@ -38,7 +38,9 @@ pub struct BlockUser {
|
||||||
pub(crate) remove_data: Option<bool>,
|
pub(crate) remove_data: Option<bool>,
|
||||||
/// block reason, written to mod log
|
/// block reason, written to mod log
|
||||||
pub(crate) summary: Option<String>,
|
pub(crate) summary: Option<String>,
|
||||||
|
/// TODO: deprecated
|
||||||
pub(crate) expires: Option<DateTime<Utc>>,
|
pub(crate) expires: Option<DateTime<Utc>>,
|
||||||
|
pub(crate) end_time: Option<DateTime<Utc>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
|
|
|
@ -19,8 +19,10 @@ pub struct Instance {
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
pub(crate) kind: ApplicationType,
|
pub(crate) kind: ApplicationType,
|
||||||
pub(crate) id: ObjectId<ApubSite>,
|
pub(crate) id: ObjectId<ApubSite>,
|
||||||
// site name
|
/// site name
|
||||||
pub(crate) name: String,
|
pub(crate) name: String,
|
||||||
|
/// instance domain, necessary for mastodon authorized fetch
|
||||||
|
pub(crate) preferred_username: String,
|
||||||
pub(crate) inbox: Url,
|
pub(crate) inbox: Url,
|
||||||
/// mandatory field in activitypub, lemmy currently serves an empty outbox
|
/// mandatory field in activitypub, lemmy currently serves an empty outbox
|
||||||
pub(crate) outbox: Url,
|
pub(crate) outbox: Url,
|
||||||
|
|
|
@ -66,6 +66,8 @@ pub struct Page {
|
||||||
pub(crate) updated: Option<DateTime<Utc>>,
|
pub(crate) updated: Option<DateTime<Utc>>,
|
||||||
pub(crate) language: Option<LanguageTag>,
|
pub(crate) language: Option<LanguageTag>,
|
||||||
pub(crate) audience: Option<ObjectId<ApubCommunity>>,
|
pub(crate) audience: Option<ObjectId<ApubCommunity>>,
|
||||||
|
#[serde(deserialize_with = "deserialize_skip_error", default)]
|
||||||
|
pub(crate) tag: Vec<Hashtag>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
@ -140,6 +142,19 @@ pub(crate) struct AttributedToPeertube {
|
||||||
pub id: ObjectId<UserOrCommunity>,
|
pub id: ObjectId<UserOrCommunity>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
pub struct Hashtag {
|
||||||
|
pub(crate) href: Url,
|
||||||
|
pub(crate) name: String,
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
pub(crate) kind: HashtagType,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
pub enum HashtagType {
|
||||||
|
Hashtag,
|
||||||
|
}
|
||||||
|
|
||||||
impl Page {
|
impl Page {
|
||||||
/// Only mods can change the post's locked status. So if it is changed from the default value,
|
/// Only mods can change the post's locked status. So if it is changed from the default value,
|
||||||
/// it is a mod action and needs to be verified as such.
|
/// it is a mod action and needs to be verified as such.
|
||||||
|
|
|
@ -33,9 +33,9 @@ impl CommentAggregates {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
aggregates::comment_aggregates::CommentAggregates,
|
aggregates::comment_aggregates::CommentAggregates,
|
||||||
|
|
|
@ -31,9 +31,9 @@ impl CommunityAggregates {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
aggregates::community_aggregates::CommunityAggregates,
|
aggregates::community_aggregates::CommunityAggregates,
|
||||||
|
|
|
@ -18,9 +18,9 @@ impl PersonAggregates {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
aggregates::person_aggregates::PersonAggregates,
|
aggregates::person_aggregates::PersonAggregates,
|
||||||
|
|
|
@ -52,9 +52,9 @@ impl PostAggregates {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
aggregates::post_aggregates::PostAggregates,
|
aggregates::post_aggregates::PostAggregates,
|
||||||
|
|
|
@ -14,9 +14,9 @@ impl SiteAggregates {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
aggregates::site_aggregates::SiteAggregates,
|
aggregates::site_aggregates::SiteAggregates,
|
||||||
|
|
|
@ -61,9 +61,9 @@ impl ReceivedActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{source::activity::ActorType, utils::build_db_pool_for_tests};
|
use crate::{source::activity::ActorType, utils::build_db_pool_for_tests};
|
||||||
|
|
|
@ -385,9 +385,9 @@ async fn convert_read_languages(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -523,10 +523,6 @@ mod tests {
|
||||||
let pool = &mut pool.into();
|
let pool = &mut pool.into();
|
||||||
|
|
||||||
let (site, instance) = create_test_site(pool).await;
|
let (site, instance) = create_test_site(pool).await;
|
||||||
let mut test_langs = test_langs1(pool).await;
|
|
||||||
SiteLanguage::update(pool, test_langs.clone(), &site)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let person_form = PersonInsertForm::builder()
|
let person_form = PersonInsertForm::builder()
|
||||||
.name("my test person".to_string())
|
.name("my test person".to_string())
|
||||||
|
@ -539,14 +535,13 @@ mod tests {
|
||||||
.password_encrypted("my_pw".to_string())
|
.password_encrypted("my_pw".to_string())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let local_user = LocalUser::create(pool, &local_user_form).await.unwrap();
|
let local_user = LocalUser::create(pool, &local_user_form, vec![])
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
let local_user_langs1 = LocalUserLanguage::read(pool, local_user.id).await.unwrap();
|
let local_user_langs1 = LocalUserLanguage::read(pool, local_user.id).await.unwrap();
|
||||||
|
|
||||||
// new user should be initialized with site languages and undetermined
|
// new user should be initialized with all languages
|
||||||
//test_langs.push(UNDETERMINED_ID);
|
assert_eq!(0, local_user_langs1.len());
|
||||||
//test_langs.sort();
|
|
||||||
test_langs.insert(0, UNDETERMINED_ID);
|
|
||||||
assert_eq!(test_langs, local_user_langs1);
|
|
||||||
|
|
||||||
// update user languages
|
// update user languages
|
||||||
let test_langs2 = test_langs2(pool).await;
|
let test_langs2 = test_langs2(pool).await;
|
||||||
|
@ -655,7 +650,9 @@ mod tests {
|
||||||
.person_id(person.id)
|
.person_id(person.id)
|
||||||
.password_encrypted("my_pw".to_string())
|
.password_encrypted("my_pw".to_string())
|
||||||
.build();
|
.build();
|
||||||
let local_user = LocalUser::create(pool, &local_user_form).await.unwrap();
|
let local_user = LocalUser::create(pool, &local_user_form, vec![])
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
LocalUserLanguage::update(pool, test_langs2, local_user.id)
|
LocalUserLanguage::update(pool, test_langs2, local_user.id)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -48,9 +48,9 @@ impl CaptchaAnswer {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
source::captcha_answer::{CaptchaAnswer, CaptchaAnswerForm, CheckCaptchaAnswer},
|
source::captcha_answer::{CaptchaAnswer, CaptchaAnswerForm, CheckCaptchaAnswer},
|
||||||
|
|
|
@ -241,9 +241,9 @@ impl Saveable for CommentSaved {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
newtypes::LanguageId,
|
newtypes::LanguageId,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
newtypes::{CommentId, CommentReplyId, PersonId},
|
newtypes::{CommentId, CommentReplyId, PersonId},
|
||||||
schema::comment_reply::dsl::{comment_id, comment_reply, read, recipient_id},
|
schema::comment_reply,
|
||||||
source::comment_reply::{CommentReply, CommentReplyInsertForm, CommentReplyUpdateForm},
|
source::comment_reply::{CommentReply, CommentReplyInsertForm, CommentReplyUpdateForm},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
utils::{get_conn, DbPool},
|
utils::{get_conn, DbPool},
|
||||||
|
@ -22,9 +22,9 @@ impl Crud for CommentReply {
|
||||||
|
|
||||||
// since the return here isnt utilized, we dont need to do an update
|
// since the return here isnt utilized, we dont need to do an update
|
||||||
// but get_result doesnt return the existing row here
|
// but get_result doesnt return the existing row here
|
||||||
insert_into(comment_reply)
|
insert_into(comment_reply::table)
|
||||||
.values(comment_reply_form)
|
.values(comment_reply_form)
|
||||||
.on_conflict((recipient_id, comment_id))
|
.on_conflict((comment_reply::recipient_id, comment_reply::comment_id))
|
||||||
.do_update()
|
.do_update()
|
||||||
.set(comment_reply_form)
|
.set(comment_reply_form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
|
@ -37,7 +37,7 @@ impl Crud for CommentReply {
|
||||||
comment_reply_form: &Self::UpdateForm,
|
comment_reply_form: &Self::UpdateForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(comment_reply.find(comment_reply_id))
|
diesel::update(comment_reply::table.find(comment_reply_id))
|
||||||
.set(comment_reply_form)
|
.set(comment_reply_form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
|
@ -51,11 +51,11 @@ impl CommentReply {
|
||||||
) -> Result<Vec<CommentReply>, Error> {
|
) -> Result<Vec<CommentReply>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(
|
diesel::update(
|
||||||
comment_reply
|
comment_reply::table
|
||||||
.filter(recipient_id.eq(for_recipient_id))
|
.filter(comment_reply::recipient_id.eq(for_recipient_id))
|
||||||
.filter(read.eq(false)),
|
.filter(comment_reply::read.eq(false)),
|
||||||
)
|
)
|
||||||
.set(read.eq(true))
|
.set(comment_reply::read.eq(true))
|
||||||
.get_results::<Self>(conn)
|
.get_results::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@ -65,17 +65,30 @@ impl CommentReply {
|
||||||
for_comment_id: CommentId,
|
for_comment_id: CommentId,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
comment_reply
|
comment_reply::table
|
||||||
.filter(comment_id.eq(for_comment_id))
|
.filter(comment_reply::comment_id.eq(for_comment_id))
|
||||||
|
.first::<Self>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn read_by_comment_and_person(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
for_comment_id: CommentId,
|
||||||
|
for_recipient_id: PersonId,
|
||||||
|
) -> Result<Self, Error> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
comment_reply::table
|
||||||
|
.filter(comment_reply::comment_id.eq(for_comment_id))
|
||||||
|
.filter(comment_reply::recipient_id.eq(for_recipient_id))
|
||||||
.first::<Self>(conn)
|
.first::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
source::{
|
source::{
|
||||||
|
|
|
@ -381,9 +381,9 @@ impl ApubActor for Community {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
source::{
|
source::{
|
||||||
|
|
|
@ -48,9 +48,9 @@ impl FederationAllowList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
source::{federation_allowlist::FederationAllowList, instance::Instance},
|
source::{federation_allowlist::FederationAllowList, instance::Instance},
|
||||||
|
|
|
@ -41,9 +41,9 @@ impl Language {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{source::language::Language, utils::build_db_pool_for_tests};
|
use crate::{source::language::Language, utils::build_db_pool_for_tests};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
49
crates/db_schema/src/impls/local_site_url_blocklist.rs
Normal file
49
crates/db_schema/src/impls/local_site_url_blocklist.rs
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
use crate::{
|
||||||
|
schema::local_site_url_blocklist,
|
||||||
|
source::local_site_url_blocklist::{LocalSiteUrlBlocklist, LocalSiteUrlBlocklistForm},
|
||||||
|
utils::{get_conn, DbPool},
|
||||||
|
};
|
||||||
|
use diesel::{dsl::insert_into, result::Error};
|
||||||
|
use diesel_async::{AsyncPgConnection, RunQueryDsl};
|
||||||
|
|
||||||
|
impl LocalSiteUrlBlocklist {
|
||||||
|
pub async fn replace(pool: &mut DbPool<'_>, url_blocklist: Vec<String>) -> Result<(), Error> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
|
||||||
|
conn
|
||||||
|
.build_transaction()
|
||||||
|
.run(|conn| {
|
||||||
|
Box::pin(async move {
|
||||||
|
use crate::schema::local_site_url_blocklist::dsl::local_site_url_blocklist;
|
||||||
|
|
||||||
|
Self::clear(conn).await?;
|
||||||
|
|
||||||
|
let forms = url_blocklist
|
||||||
|
.into_iter()
|
||||||
|
.map(|url| LocalSiteUrlBlocklistForm { url, updated: None })
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
insert_into(local_site_url_blocklist)
|
||||||
|
.values(forms)
|
||||||
|
.execute(conn)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}) as _
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn clear(conn: &mut AsyncPgConnection) -> Result<usize, Error> {
|
||||||
|
diesel::delete(local_site_url_blocklist::table)
|
||||||
|
.execute(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_all(pool: &mut DbPool<'_>) -> Result<Vec<Self>, Error> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
local_site_url_blocklist::table
|
||||||
|
.get_results::<Self>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
newtypes::{DbUrl, LocalUserId, PersonId},
|
newtypes::{DbUrl, LanguageId, LocalUserId, PersonId},
|
||||||
schema::{local_user, person, registration_application},
|
schema::{local_user, person, registration_application},
|
||||||
source::{
|
source::{
|
||||||
actor_language::{LocalUserLanguage, SiteLanguage},
|
actor_language::LocalUserLanguage,
|
||||||
local_user::{LocalUser, LocalUserInsertForm, LocalUserUpdateForm},
|
local_user::{LocalUser, LocalUserInsertForm, LocalUserUpdateForm},
|
||||||
|
local_user_vote_display_mode::{LocalUserVoteDisplayMode, LocalUserVoteDisplayModeInsertForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
|
||||||
utils::{
|
utils::{
|
||||||
functions::{coalesce, lower},
|
functions::{coalesce, lower},
|
||||||
get_conn,
|
get_conn,
|
||||||
|
@ -24,6 +24,52 @@ use diesel::{
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
impl LocalUser {
|
impl LocalUser {
|
||||||
|
pub async fn create(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
form: &LocalUserInsertForm,
|
||||||
|
languages: Vec<LanguageId>,
|
||||||
|
) -> Result<LocalUser, Error> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
let mut form_with_encrypted_password = form.clone();
|
||||||
|
let password_hash =
|
||||||
|
hash(&form.password_encrypted, DEFAULT_COST).expect("Couldn't hash password");
|
||||||
|
form_with_encrypted_password.password_encrypted = password_hash;
|
||||||
|
|
||||||
|
let local_user_ = insert_into(local_user::table)
|
||||||
|
.values(form_with_encrypted_password)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
LocalUserLanguage::update(pool, languages, local_user_.id).await?;
|
||||||
|
|
||||||
|
// Create their vote_display_modes
|
||||||
|
let vote_display_mode_form = LocalUserVoteDisplayModeInsertForm::builder()
|
||||||
|
.local_user_id(local_user_.id)
|
||||||
|
.build();
|
||||||
|
LocalUserVoteDisplayMode::create(pool, &vote_display_mode_form).await?;
|
||||||
|
|
||||||
|
Ok(local_user_)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
local_user_id: LocalUserId,
|
||||||
|
form: &LocalUserUpdateForm,
|
||||||
|
) -> Result<LocalUser, Error> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
diesel::update(local_user::table.find(local_user_id))
|
||||||
|
.set(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn delete(pool: &mut DbPool<'_>, id: LocalUserId) -> Result<usize, Error> {
|
||||||
|
let conn = &mut *get_conn(pool).await?;
|
||||||
|
diesel::delete(local_user::table.find(id))
|
||||||
|
.execute(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn update_password(
|
pub async fn update_password(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
local_user_id: LocalUserId,
|
local_user_id: LocalUserId,
|
||||||
|
@ -182,46 +228,3 @@ pub struct UserBackupLists {
|
||||||
pub blocked_users: Vec<DbUrl>,
|
pub blocked_users: Vec<DbUrl>,
|
||||||
pub blocked_instances: Vec<String>,
|
pub blocked_instances: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl Crud for LocalUser {
|
|
||||||
type InsertForm = LocalUserInsertForm;
|
|
||||||
type UpdateForm = LocalUserUpdateForm;
|
|
||||||
type IdType = LocalUserId;
|
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
let mut form_with_encrypted_password = form.clone();
|
|
||||||
let password_hash =
|
|
||||||
hash(&form.password_encrypted, DEFAULT_COST).expect("Couldn't hash password");
|
|
||||||
form_with_encrypted_password.password_encrypted = password_hash;
|
|
||||||
|
|
||||||
let local_user_ = insert_into(local_user::table)
|
|
||||||
.values(form_with_encrypted_password)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let site_languages = SiteLanguage::read_local_raw(pool).await;
|
|
||||||
if let Ok(langs) = site_languages {
|
|
||||||
// if site exists, init user with site languages
|
|
||||||
LocalUserLanguage::update(pool, langs, local_user_.id).await?;
|
|
||||||
} else {
|
|
||||||
// otherwise, init with all languages (this only happens during tests and
|
|
||||||
// for first admin user, which is created before site)
|
|
||||||
LocalUserLanguage::update(pool, vec![], local_user_.id).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(local_user_)
|
|
||||||
}
|
|
||||||
async fn update(
|
|
||||||
pool: &mut DbPool<'_>,
|
|
||||||
local_user_id: LocalUserId,
|
|
||||||
form: &Self::UpdateForm,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
diesel::update(local_user::table.find(local_user_id))
|
|
||||||
.set(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
57
crates/db_schema/src/impls/local_user_vote_display_mode.rs
Normal file
57
crates/db_schema/src/impls/local_user_vote_display_mode.rs
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
use crate::{
|
||||||
|
newtypes::LocalUserId,
|
||||||
|
schema::local_user_vote_display_mode,
|
||||||
|
source::local_user_vote_display_mode::{
|
||||||
|
LocalUserVoteDisplayMode,
|
||||||
|
LocalUserVoteDisplayModeInsertForm,
|
||||||
|
LocalUserVoteDisplayModeUpdateForm,
|
||||||
|
},
|
||||||
|
utils::{get_conn, DbPool},
|
||||||
|
};
|
||||||
|
use diesel::{dsl::insert_into, result::Error, QueryDsl};
|
||||||
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
|
impl LocalUserVoteDisplayMode {
|
||||||
|
pub async fn read(pool: &mut DbPool<'_>) -> Result<Self, Error> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
local_user_vote_display_mode::table
|
||||||
|
.first::<Self>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn create(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
form: &LocalUserVoteDisplayModeInsertForm,
|
||||||
|
) -> Result<Self, Error> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
insert_into(local_user_vote_display_mode::table)
|
||||||
|
.values(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
pub async fn update(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
local_user_id: LocalUserId,
|
||||||
|
form: &LocalUserVoteDisplayModeUpdateForm,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
// avoid error "There are no changes to save. This query cannot be built"
|
||||||
|
if form.is_empty() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
diesel::update(local_user_vote_display_mode::table.find(local_user_id))
|
||||||
|
.set(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LocalUserVoteDisplayModeUpdateForm {
|
||||||
|
fn is_empty(&self) -> bool {
|
||||||
|
self.score.is_none()
|
||||||
|
&& self.upvotes.is_none()
|
||||||
|
&& self.downvotes.is_none()
|
||||||
|
&& self.upvote_percentage.is_none()
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,7 +17,9 @@ pub mod instance_block;
|
||||||
pub mod language;
|
pub mod language;
|
||||||
pub mod local_site;
|
pub mod local_site;
|
||||||
pub mod local_site_rate_limit;
|
pub mod local_site_rate_limit;
|
||||||
|
pub mod local_site_url_blocklist;
|
||||||
pub mod local_user;
|
pub mod local_user;
|
||||||
|
pub mod local_user_vote_display_mode;
|
||||||
pub mod login_token;
|
pub mod login_token;
|
||||||
pub mod moderator;
|
pub mod moderator;
|
||||||
pub mod password_reset_request;
|
pub mod password_reset_request;
|
||||||
|
|
|
@ -465,9 +465,9 @@ impl Crud for AdminPurgeComment {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
source::{
|
source::{
|
||||||
|
|
|
@ -81,9 +81,9 @@ impl PasswordResetRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
source::{
|
source::{
|
||||||
|
@ -121,7 +121,9 @@ mod tests {
|
||||||
.password_encrypted("pass".to_string())
|
.password_encrypted("pass".to_string())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let inserted_local_user = LocalUser::create(pool, &new_local_user).await.unwrap();
|
let inserted_local_user = LocalUser::create(pool, &new_local_user, vec![])
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let token = "nope";
|
let token = "nope";
|
||||||
|
|
||||||
|
|
|
@ -212,9 +212,9 @@ impl PersonFollower {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
source::{
|
source::{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
newtypes::{CommentId, PersonId, PersonMentionId},
|
newtypes::{CommentId, PersonId, PersonMentionId},
|
||||||
schema::person_mention::dsl::{comment_id, person_mention, read, recipient_id},
|
schema::person_mention,
|
||||||
source::person_mention::{PersonMention, PersonMentionInsertForm, PersonMentionUpdateForm},
|
source::person_mention::{PersonMention, PersonMentionInsertForm, PersonMentionUpdateForm},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
utils::{get_conn, DbPool},
|
utils::{get_conn, DbPool},
|
||||||
|
@ -21,9 +21,9 @@ impl Crud for PersonMention {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
// since the return here isnt utilized, we dont need to do an update
|
// since the return here isnt utilized, we dont need to do an update
|
||||||
// but get_result doesnt return the existing row here
|
// but get_result doesnt return the existing row here
|
||||||
insert_into(person_mention)
|
insert_into(person_mention::table)
|
||||||
.values(person_mention_form)
|
.values(person_mention_form)
|
||||||
.on_conflict((recipient_id, comment_id))
|
.on_conflict((person_mention::recipient_id, person_mention::comment_id))
|
||||||
.do_update()
|
.do_update()
|
||||||
.set(person_mention_form)
|
.set(person_mention_form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
|
@ -36,7 +36,7 @@ impl Crud for PersonMention {
|
||||||
person_mention_form: &Self::UpdateForm,
|
person_mention_form: &Self::UpdateForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(person_mention.find(person_mention_id))
|
diesel::update(person_mention::table.find(person_mention_id))
|
||||||
.set(person_mention_form)
|
.set(person_mention_form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
|
@ -50,11 +50,11 @@ impl PersonMention {
|
||||||
) -> Result<Vec<PersonMention>, Error> {
|
) -> Result<Vec<PersonMention>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(
|
diesel::update(
|
||||||
person_mention
|
person_mention::table
|
||||||
.filter(recipient_id.eq(for_recipient_id))
|
.filter(person_mention::recipient_id.eq(for_recipient_id))
|
||||||
.filter(read.eq(false)),
|
.filter(person_mention::read.eq(false)),
|
||||||
)
|
)
|
||||||
.set(read.eq(true))
|
.set(person_mention::read.eq(true))
|
||||||
.get_results::<Self>(conn)
|
.get_results::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@ -65,18 +65,18 @@ impl PersonMention {
|
||||||
for_recipient_id: PersonId,
|
for_recipient_id: PersonId,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
person_mention
|
person_mention::table
|
||||||
.filter(comment_id.eq(for_comment_id))
|
.filter(person_mention::comment_id.eq(for_comment_id))
|
||||||
.filter(recipient_id.eq(for_recipient_id))
|
.filter(person_mention::recipient_id.eq(for_recipient_id))
|
||||||
.first::<Self>(conn)
|
.first::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
source::{
|
source::{
|
||||||
|
|
|
@ -27,7 +27,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use ::url::Url;
|
use ::url::Url;
|
||||||
use chrono::{Duration, Utc};
|
use chrono::Utc;
|
||||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl, TextExpressionMethods};
|
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl, TextExpressionMethods};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
@ -104,7 +104,9 @@ impl Post {
|
||||||
.filter(post::local.eq(true))
|
.filter(post::local.eq(true))
|
||||||
.filter(post::deleted.eq(false))
|
.filter(post::deleted.eq(false))
|
||||||
.filter(post::removed.eq(false))
|
.filter(post::removed.eq(false))
|
||||||
.filter(post::published.ge(Utc::now().naive_utc() - Duration::days(SITEMAP_DAYS)))
|
.filter(
|
||||||
|
post::published.ge(Utc::now().naive_utc() - SITEMAP_DAYS.expect("TimeDelta out of bounds")),
|
||||||
|
)
|
||||||
.order(post::published.desc())
|
.order(post::published.desc())
|
||||||
.limit(SITEMAP_LIMIT)
|
.limit(SITEMAP_LIMIT)
|
||||||
.load::<(DbUrl, chrono::DateTime<Utc>)>(conn)
|
.load::<(DbUrl, chrono::DateTime<Utc>)>(conn)
|
||||||
|
@ -360,9 +362,9 @@ impl PostHide {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
source::{
|
source::{
|
||||||
|
|
|
@ -80,9 +80,9 @@ impl Reportable for PostReport {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -74,9 +74,9 @@ impl PrivateMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
source::{
|
source::{
|
||||||
|
|
|
@ -342,7 +342,7 @@ diesel::table! {
|
||||||
|
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
local_image (pictrs_alias) {
|
local_image (pictrs_alias) {
|
||||||
local_user_id -> Int4,
|
local_user_id -> Nullable<Int4>,
|
||||||
pictrs_alias -> Text,
|
pictrs_alias -> Text,
|
||||||
pictrs_delete_token -> Text,
|
pictrs_delete_token -> Text,
|
||||||
published -> Timestamptz,
|
published -> Timestamptz,
|
||||||
|
@ -409,6 +409,15 @@ diesel::table! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
local_site_url_blocklist (id) {
|
||||||
|
id -> Int4,
|
||||||
|
url -> Text,
|
||||||
|
published -> Timestamptz,
|
||||||
|
updated -> Nullable<Timestamptz>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
use diesel::sql_types::*;
|
use diesel::sql_types::*;
|
||||||
use super::sql_types::SortTypeEnum;
|
use super::sql_types::SortTypeEnum;
|
||||||
|
@ -454,6 +463,16 @@ diesel::table! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
local_user_vote_display_mode (local_user_id) {
|
||||||
|
local_user_id -> Int4,
|
||||||
|
score -> Bool,
|
||||||
|
upvotes -> Bool,
|
||||||
|
downvotes -> Bool,
|
||||||
|
upvote_percentage -> Bool,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
login_token (token) {
|
login_token (token) {
|
||||||
token -> Text,
|
token -> Text,
|
||||||
|
@ -961,6 +980,7 @@ diesel::joinable!(local_site_rate_limit -> local_site (local_site_id));
|
||||||
diesel::joinable!(local_user -> person (person_id));
|
diesel::joinable!(local_user -> person (person_id));
|
||||||
diesel::joinable!(local_user_language -> language (language_id));
|
diesel::joinable!(local_user_language -> language (language_id));
|
||||||
diesel::joinable!(local_user_language -> local_user (local_user_id));
|
diesel::joinable!(local_user_language -> local_user (local_user_id));
|
||||||
|
diesel::joinable!(local_user_vote_display_mode -> local_user (local_user_id));
|
||||||
diesel::joinable!(login_token -> local_user (user_id));
|
diesel::joinable!(login_token -> local_user (user_id));
|
||||||
diesel::joinable!(mod_add_community -> community (community_id));
|
diesel::joinable!(mod_add_community -> community (community_id));
|
||||||
diesel::joinable!(mod_ban_from_community -> community (community_id));
|
diesel::joinable!(mod_ban_from_community -> community (community_id));
|
||||||
|
@ -1041,8 +1061,10 @@ diesel::allow_tables_to_appear_in_same_query!(
|
||||||
local_image,
|
local_image,
|
||||||
local_site,
|
local_site,
|
||||||
local_site_rate_limit,
|
local_site_rate_limit,
|
||||||
|
local_site_url_blocklist,
|
||||||
local_user,
|
local_user,
|
||||||
local_user_language,
|
local_user_language,
|
||||||
|
local_user_vote_display_mode,
|
||||||
login_token,
|
login_token,
|
||||||
mod_add,
|
mod_add,
|
||||||
mod_add_community,
|
mod_add_community,
|
||||||
|
|
|
@ -2,11 +2,9 @@ use crate::newtypes::{DbUrl, LocalUserId};
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
use crate::schema::{local_image, remote_image};
|
use crate::schema::{local_image, remote_image};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde_with::skip_serializing_none;
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use typed_builder::TypedBuilder;
|
use typed_builder::TypedBuilder;
|
||||||
|
|
||||||
#[skip_serializing_none]
|
|
||||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||||
#[cfg_attr(feature = "full", derive(Queryable, Associations))]
|
#[cfg_attr(feature = "full", derive(Queryable, Associations))]
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = local_image))]
|
#[cfg_attr(feature = "full", diesel(table_name = local_image))]
|
||||||
|
@ -15,7 +13,7 @@ use typed_builder::TypedBuilder;
|
||||||
diesel(belongs_to(crate::source::local_user::LocalUser))
|
diesel(belongs_to(crate::source::local_user::LocalUser))
|
||||||
)]
|
)]
|
||||||
pub struct LocalImage {
|
pub struct LocalImage {
|
||||||
pub local_user_id: LocalUserId,
|
pub local_user_id: Option<LocalUserId>,
|
||||||
pub pictrs_alias: String,
|
pub pictrs_alias: String,
|
||||||
pub pictrs_delete_token: String,
|
pub pictrs_delete_token: String,
|
||||||
pub published: DateTime<Utc>,
|
pub published: DateTime<Utc>,
|
||||||
|
@ -25,14 +23,13 @@ pub struct LocalImage {
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = local_image))]
|
#[cfg_attr(feature = "full", diesel(table_name = local_image))]
|
||||||
pub struct LocalImageForm {
|
pub struct LocalImageForm {
|
||||||
pub local_user_id: LocalUserId,
|
pub local_user_id: Option<LocalUserId>,
|
||||||
pub pictrs_alias: String,
|
pub pictrs_alias: String,
|
||||||
pub pictrs_delete_token: String,
|
pub pictrs_delete_token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stores all images which are hosted on remote domains. When attempting to proxy an image, it
|
/// Stores all images which are hosted on remote domains. When attempting to proxy an image, it
|
||||||
/// is checked against this table to avoid Lemmy being used as a general purpose proxy.
|
/// is checked against this table to avoid Lemmy being used as a general purpose proxy.
|
||||||
#[skip_serializing_none]
|
|
||||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||||
#[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
|
#[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = remote_image))]
|
#[cfg_attr(feature = "full", diesel(table_name = remote_image))]
|
||||||
|
|
28
crates/db_schema/src/source/local_site_url_blocklist.rs
Normal file
28
crates/db_schema/src/source/local_site_url_blocklist.rs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#[cfg(feature = "full")]
|
||||||
|
use crate::schema::local_site_url_blocklist;
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_with::skip_serializing_none;
|
||||||
|
#[cfg(feature = "full")]
|
||||||
|
use ts_rs::TS;
|
||||||
|
|
||||||
|
#[skip_serializing_none]
|
||||||
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||||
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = local_site_url_blocklist))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||||
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
|
pub struct LocalSiteUrlBlocklist {
|
||||||
|
pub id: i32,
|
||||||
|
pub url: String,
|
||||||
|
pub published: DateTime<Utc>,
|
||||||
|
pub updated: Option<DateTime<Utc>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Clone)]
|
||||||
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = local_site_url_blocklist))]
|
||||||
|
pub struct LocalSiteUrlBlocklistForm {
|
||||||
|
pub url: String,
|
||||||
|
pub updated: Option<DateTime<Utc>>,
|
||||||
|
}
|
|
@ -36,6 +36,7 @@ pub struct LocalUser {
|
||||||
pub show_avatars: bool,
|
pub show_avatars: bool,
|
||||||
pub send_notifications_to_email: bool,
|
pub send_notifications_to_email: bool,
|
||||||
/// Whether to show comment / post scores.
|
/// Whether to show comment / post scores.
|
||||||
|
// TODO now that there is a vote_display_mode, this can be gotten rid of in future releases.
|
||||||
pub show_scores: bool,
|
pub show_scores: bool,
|
||||||
/// Whether to show bot accounts.
|
/// Whether to show bot accounts.
|
||||||
pub show_bot_accounts: bool,
|
pub show_bot_accounts: bool,
|
||||||
|
@ -55,6 +56,7 @@ pub struct LocalUser {
|
||||||
pub infinite_scroll_enabled: bool,
|
pub infinite_scroll_enabled: bool,
|
||||||
/// Whether the person is an admin.
|
/// Whether the person is an admin.
|
||||||
pub admin: bool,
|
pub admin: bool,
|
||||||
|
/// A post-view mode that changes how multiple post listings look.
|
||||||
pub post_listing_mode: PostListingMode,
|
pub post_listing_mode: PostListingMode,
|
||||||
pub totp_2fa_enabled: bool,
|
pub totp_2fa_enabled: bool,
|
||||||
/// Whether to allow keyboard navigation (for browsing and interacting with posts and comments).
|
/// Whether to allow keyboard navigation (for browsing and interacting with posts and comments).
|
||||||
|
|
51
crates/db_schema/src/source/local_user_vote_display_mode.rs
Normal file
51
crates/db_schema/src/source/local_user_vote_display_mode.rs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
use crate::newtypes::LocalUserId;
|
||||||
|
#[cfg(feature = "full")]
|
||||||
|
use crate::schema::local_user_vote_display_mode;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_with::skip_serializing_none;
|
||||||
|
#[cfg(feature = "full")]
|
||||||
|
use ts_rs::TS;
|
||||||
|
use typed_builder::TypedBuilder;
|
||||||
|
|
||||||
|
#[skip_serializing_none]
|
||||||
|
#[derive(PartialEq, Eq, Debug, Clone, Default, Serialize, Deserialize)]
|
||||||
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = local_user_vote_display_mode))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(primary_key(local_user_id)))]
|
||||||
|
#[cfg_attr(
|
||||||
|
feature = "full",
|
||||||
|
diesel(belongs_to(crate::source::local_site::LocalUser))
|
||||||
|
)]
|
||||||
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||||
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
|
/// The vote display settings for your user.
|
||||||
|
pub struct LocalUserVoteDisplayMode {
|
||||||
|
pub local_user_id: LocalUserId,
|
||||||
|
pub score: bool,
|
||||||
|
pub upvotes: bool,
|
||||||
|
pub downvotes: bool,
|
||||||
|
pub upvote_percentage: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, TypedBuilder)]
|
||||||
|
#[builder(field_defaults(default))]
|
||||||
|
#[cfg_attr(feature = "full", derive(Insertable))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = local_user_vote_display_mode))]
|
||||||
|
pub struct LocalUserVoteDisplayModeInsertForm {
|
||||||
|
#[builder(!default)]
|
||||||
|
pub local_user_id: LocalUserId,
|
||||||
|
pub score: Option<bool>,
|
||||||
|
pub upvotes: Option<bool>,
|
||||||
|
pub downvotes: Option<bool>,
|
||||||
|
pub upvote_percentage: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Default)]
|
||||||
|
#[cfg_attr(feature = "full", derive(AsChangeset))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = local_user_vote_display_mode))]
|
||||||
|
pub struct LocalUserVoteDisplayModeUpdateForm {
|
||||||
|
pub score: Option<bool>,
|
||||||
|
pub upvotes: Option<bool>,
|
||||||
|
pub downvotes: Option<bool>,
|
||||||
|
pub upvote_percentage: Option<bool>,
|
||||||
|
}
|
|
@ -22,7 +22,9 @@ pub mod instance_block;
|
||||||
pub mod language;
|
pub mod language;
|
||||||
pub mod local_site;
|
pub mod local_site;
|
||||||
pub mod local_site_rate_limit;
|
pub mod local_site_rate_limit;
|
||||||
|
pub mod local_site_url_blocklist;
|
||||||
pub mod local_user;
|
pub mod local_user;
|
||||||
|
pub mod local_user_vote_display_mode;
|
||||||
pub mod login_token;
|
pub mod login_token;
|
||||||
pub mod moderator;
|
pub mod moderator;
|
||||||
pub mod password_reset_request;
|
pub mod password_reset_request;
|
||||||
|
@ -44,6 +46,6 @@ pub mod tagline;
|
||||||
/// value is not sent by Lemmy. Necessary for crates which rely on Rust API such as lemmy-stats-crawler.
|
/// value is not sent by Lemmy. Necessary for crates which rely on Rust API such as lemmy-stats-crawler.
|
||||||
fn placeholder_apub_url() -> DbUrl {
|
fn placeholder_apub_url() -> DbUrl {
|
||||||
DbUrl(Box::new(
|
DbUrl(Box::new(
|
||||||
Url::parse("http://example.com").expect("parse placeholer url"),
|
Url::parse("http://example.com").expect("parse placeholder url"),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,9 @@ pub struct Site {
|
||||||
pub last_refreshed_at: DateTime<Utc>,
|
pub last_refreshed_at: DateTime<Utc>,
|
||||||
/// The site inbox
|
/// The site inbox
|
||||||
pub inbox_url: DbUrl,
|
pub inbox_url: DbUrl,
|
||||||
|
#[serde(skip)]
|
||||||
pub private_key: Option<String>,
|
pub private_key: Option<String>,
|
||||||
|
#[serde(skip)]
|
||||||
pub public_key: String,
|
pub public_key: String,
|
||||||
pub instance_id: InstanceId,
|
pub instance_id: InstanceId,
|
||||||
/// If present, nsfw content is visible by default. Should be displayed by frontends/clients
|
/// If present, nsfw content is visible by default. Should be displayed by frontends/clients
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::{
|
||||||
SortType,
|
SortType,
|
||||||
};
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, TimeDelta, Utc};
|
||||||
use deadpool::Runtime;
|
use deadpool::Runtime;
|
||||||
use diesel::{
|
use diesel::{
|
||||||
helper_types::AsExprOf,
|
helper_types::AsExprOf,
|
||||||
|
@ -51,7 +51,7 @@ use url::Url;
|
||||||
const FETCH_LIMIT_DEFAULT: i64 = 10;
|
const FETCH_LIMIT_DEFAULT: i64 = 10;
|
||||||
pub const FETCH_LIMIT_MAX: i64 = 50;
|
pub const FETCH_LIMIT_MAX: i64 = 50;
|
||||||
pub const SITEMAP_LIMIT: i64 = 50000;
|
pub const SITEMAP_LIMIT: i64 = 50000;
|
||||||
pub const SITEMAP_DAYS: i64 = 31;
|
pub const SITEMAP_DAYS: Option<TimeDelta> = TimeDelta::try_days(31);
|
||||||
pub const RANK_DEFAULT: f64 = 0.0001;
|
pub const RANK_DEFAULT: f64 = 0.0001;
|
||||||
|
|
||||||
pub type ActualDbPool = Pool<AsyncPgConnection>;
|
pub type ActualDbPool = Pool<AsyncPgConnection>;
|
||||||
|
@ -536,9 +536,9 @@ impl<RF, LF> Queries<RF, LF> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
|
@ -18,10 +18,14 @@ use lemmy_db_schema::{
|
||||||
comment_aggregates,
|
comment_aggregates,
|
||||||
comment_like,
|
comment_like,
|
||||||
comment_report,
|
comment_report,
|
||||||
|
comment_saved,
|
||||||
community,
|
community,
|
||||||
|
community_follower,
|
||||||
community_moderator,
|
community_moderator,
|
||||||
community_person_ban,
|
community_person_ban,
|
||||||
|
local_user,
|
||||||
person,
|
person,
|
||||||
|
person_block,
|
||||||
post,
|
post,
|
||||||
},
|
},
|
||||||
utils::{get_conn, limit_and_offset, DbConn, DbPool, ListFn, Queries, ReadFn},
|
utils::{get_conn, limit_and_offset, DbConn, DbPool, ListFn, Queries, ReadFn},
|
||||||
|
@ -64,6 +68,45 @@ fn queries<'a>() -> Queries<
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.left_join(
|
||||||
|
aliases::community_moderator1.on(
|
||||||
|
community::id
|
||||||
|
.eq(aliases::community_moderator1.field(community_moderator::community_id))
|
||||||
|
.and(
|
||||||
|
aliases::community_moderator1
|
||||||
|
.field(community_moderator::person_id)
|
||||||
|
.eq(comment::creator_id),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.left_join(
|
||||||
|
local_user::table.on(
|
||||||
|
comment::creator_id
|
||||||
|
.eq(local_user::person_id)
|
||||||
|
.and(local_user::admin.eq(true)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.left_join(
|
||||||
|
person_block::table.on(
|
||||||
|
comment::creator_id
|
||||||
|
.eq(person_block::target_id)
|
||||||
|
.and(person_block::person_id.eq(my_person_id)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.left_join(
|
||||||
|
community_follower::table.on(
|
||||||
|
post::community_id
|
||||||
|
.eq(community_follower::community_id)
|
||||||
|
.and(community_follower::person_id.eq(my_person_id)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.left_join(
|
||||||
|
comment_saved::table.on(
|
||||||
|
comment::id
|
||||||
|
.eq(comment_saved::comment_id)
|
||||||
|
.and(comment_saved::person_id.eq(my_person_id)),
|
||||||
|
),
|
||||||
|
)
|
||||||
.select((
|
.select((
|
||||||
comment_report::all_columns,
|
comment_report::all_columns,
|
||||||
comment::all_columns,
|
comment::all_columns,
|
||||||
|
@ -73,6 +116,14 @@ fn queries<'a>() -> Queries<
|
||||||
aliases::person1.fields(person::all_columns),
|
aliases::person1.fields(person::all_columns),
|
||||||
comment_aggregates::all_columns,
|
comment_aggregates::all_columns,
|
||||||
community_person_ban::community_id.nullable().is_not_null(),
|
community_person_ban::community_id.nullable().is_not_null(),
|
||||||
|
aliases::community_moderator1
|
||||||
|
.field(community_moderator::community_id)
|
||||||
|
.nullable()
|
||||||
|
.is_not_null(),
|
||||||
|
local_user::admin.nullable().is_not_null(),
|
||||||
|
person_block::target_id.nullable().is_not_null(),
|
||||||
|
community_follower::pending.nullable(),
|
||||||
|
comment_saved::published.nullable().is_not_null(),
|
||||||
comment_like::score.nullable(),
|
comment_like::score.nullable(),
|
||||||
aliases::person2.fields(person::all_columns).nullable(),
|
aliases::person2.fields(person::all_columns).nullable(),
|
||||||
))
|
))
|
||||||
|
@ -207,9 +258,9 @@ impl CommentReportQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
comment_report_view::{CommentReportQuery, CommentReportView},
|
comment_report_view::{CommentReportQuery, CommentReportView},
|
||||||
|
@ -223,12 +274,14 @@ mod tests {
|
||||||
community::{Community, CommunityInsertForm, CommunityModerator, CommunityModeratorForm},
|
community::{Community, CommunityInsertForm, CommunityModerator, CommunityModeratorForm},
|
||||||
instance::Instance,
|
instance::Instance,
|
||||||
local_user::{LocalUser, LocalUserInsertForm},
|
local_user::{LocalUser, LocalUserInsertForm},
|
||||||
|
local_user_vote_display_mode::LocalUserVoteDisplayMode,
|
||||||
person::{Person, PersonInsertForm},
|
person::{Person, PersonInsertForm},
|
||||||
post::{Post, PostInsertForm},
|
post::{Post, PostInsertForm},
|
||||||
},
|
},
|
||||||
traits::{Crud, Joinable, Reportable},
|
traits::{Crud, Joinable, Reportable},
|
||||||
utils::{build_db_pool_for_tests, RANK_DEFAULT},
|
utils::{build_db_pool_for_tests, RANK_DEFAULT},
|
||||||
CommunityVisibility,
|
CommunityVisibility,
|
||||||
|
SubscribedType,
|
||||||
};
|
};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
@ -255,9 +308,12 @@ mod tests {
|
||||||
.person_id(inserted_timmy.id)
|
.person_id(inserted_timmy.id)
|
||||||
.password_encrypted("123".to_string())
|
.password_encrypted("123".to_string())
|
||||||
.build();
|
.build();
|
||||||
let timmy_local_user = LocalUser::create(pool, &new_local_user).await.unwrap();
|
let timmy_local_user = LocalUser::create(pool, &new_local_user, vec![])
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
let timmy_view = LocalUserView {
|
let timmy_view = LocalUserView {
|
||||||
local_user: timmy_local_user,
|
local_user: timmy_local_user,
|
||||||
|
local_user_vote_display_mode: LocalUserVoteDisplayMode::default(),
|
||||||
person: inserted_timmy.clone(),
|
person: inserted_timmy.clone(),
|
||||||
counts: Default::default(),
|
counts: Default::default(),
|
||||||
};
|
};
|
||||||
|
@ -350,6 +406,11 @@ mod tests {
|
||||||
comment_report: inserted_jessica_report.clone(),
|
comment_report: inserted_jessica_report.clone(),
|
||||||
comment: inserted_comment.clone(),
|
comment: inserted_comment.clone(),
|
||||||
post: inserted_post,
|
post: inserted_post,
|
||||||
|
creator_is_moderator: true,
|
||||||
|
creator_is_admin: false,
|
||||||
|
creator_blocked: false,
|
||||||
|
subscribed: SubscribedType::NotSubscribed,
|
||||||
|
saved: false,
|
||||||
community: Community {
|
community: Community {
|
||||||
id: inserted_community.id,
|
id: inserted_community.id,
|
||||||
name: inserted_community.name,
|
name: inserted_community.name,
|
||||||
|
|
|
@ -53,6 +53,16 @@ fn queries<'a>() -> Queries<
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let is_local_user_banned_from_community = |person_id| {
|
||||||
|
exists(
|
||||||
|
community_person_ban::table.filter(
|
||||||
|
community::id
|
||||||
|
.eq(community_person_ban::community_id)
|
||||||
|
.and(community_person_ban::person_id.eq(person_id)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
let is_saved = |person_id| {
|
let is_saved = |person_id| {
|
||||||
comment_saved::table
|
comment_saved::table
|
||||||
.filter(
|
.filter(
|
||||||
|
@ -113,6 +123,14 @@ fn queries<'a>() -> Queries<
|
||||||
);
|
);
|
||||||
|
|
||||||
let all_joins = move |query: comment::BoxedQuery<'a, Pg>, my_person_id: Option<PersonId>| {
|
let all_joins = move |query: comment::BoxedQuery<'a, Pg>, my_person_id: Option<PersonId>| {
|
||||||
|
let is_local_user_banned_from_community_selection: Box<
|
||||||
|
dyn BoxableExpression<_, Pg, SqlType = sql_types::Bool>,
|
||||||
|
> = if let Some(person_id) = my_person_id {
|
||||||
|
Box::new(is_local_user_banned_from_community(person_id))
|
||||||
|
} else {
|
||||||
|
Box::new(false.into_sql::<sql_types::Bool>())
|
||||||
|
};
|
||||||
|
|
||||||
let score_selection: Box<
|
let score_selection: Box<
|
||||||
dyn BoxableExpression<_, Pg, SqlType = sql_types::Nullable<sql_types::SmallInt>>,
|
dyn BoxableExpression<_, Pg, SqlType = sql_types::Nullable<sql_types::SmallInt>>,
|
||||||
> = if let Some(person_id) = my_person_id {
|
> = if let Some(person_id) = my_person_id {
|
||||||
|
@ -156,6 +174,7 @@ fn queries<'a>() -> Queries<
|
||||||
community::all_columns,
|
community::all_columns,
|
||||||
comment_aggregates::all_columns,
|
comment_aggregates::all_columns,
|
||||||
is_creator_banned_from_community,
|
is_creator_banned_from_community,
|
||||||
|
is_local_user_banned_from_community_selection,
|
||||||
creator_is_moderator,
|
creator_is_moderator,
|
||||||
creator_is_admin,
|
creator_is_admin,
|
||||||
subscribed_type_selection,
|
subscribed_type_selection,
|
||||||
|
@ -407,9 +426,9 @@ impl<'a> CommentQuery<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
comment_view::{CommentQuery, CommentSortType, CommentView, DbPool},
|
comment_view::{CommentQuery, CommentSortType, CommentView, DbPool},
|
||||||
|
@ -436,20 +455,24 @@ mod tests {
|
||||||
CommunityInsertForm,
|
CommunityInsertForm,
|
||||||
CommunityModerator,
|
CommunityModerator,
|
||||||
CommunityModeratorForm,
|
CommunityModeratorForm,
|
||||||
|
CommunityPersonBan,
|
||||||
|
CommunityPersonBanForm,
|
||||||
CommunityUpdateForm,
|
CommunityUpdateForm,
|
||||||
},
|
},
|
||||||
instance::Instance,
|
instance::Instance,
|
||||||
language::Language,
|
language::Language,
|
||||||
local_user::{LocalUser, LocalUserInsertForm},
|
local_user::{LocalUser, LocalUserInsertForm},
|
||||||
|
local_user_vote_display_mode::LocalUserVoteDisplayMode,
|
||||||
person::{Person, PersonInsertForm},
|
person::{Person, PersonInsertForm},
|
||||||
person_block::{PersonBlock, PersonBlockForm},
|
person_block::{PersonBlock, PersonBlockForm},
|
||||||
post::{Post, PostInsertForm},
|
post::{Post, PostInsertForm},
|
||||||
},
|
},
|
||||||
traits::{Blockable, Crud, Joinable, Likeable, Saveable},
|
traits::{Bannable, Blockable, Crud, Joinable, Likeable, Saveable},
|
||||||
utils::{build_db_pool_for_tests, RANK_DEFAULT},
|
utils::{build_db_pool_for_tests, RANK_DEFAULT},
|
||||||
CommunityVisibility,
|
CommunityVisibility,
|
||||||
SubscribedType,
|
SubscribedType,
|
||||||
};
|
};
|
||||||
|
use lemmy_utils::error::LemmyResult;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
|
@ -480,7 +503,7 @@ mod tests {
|
||||||
.admin(Some(true))
|
.admin(Some(true))
|
||||||
.password_encrypted(String::new())
|
.password_encrypted(String::new())
|
||||||
.build();
|
.build();
|
||||||
let inserted_timmy_local_user = LocalUser::create(pool, &timmy_local_user_form)
|
let inserted_timmy_local_user = LocalUser::create(pool, &timmy_local_user_form, vec![])
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -614,6 +637,7 @@ mod tests {
|
||||||
|
|
||||||
let timmy_local_user_view = LocalUserView {
|
let timmy_local_user_view = LocalUserView {
|
||||||
local_user: inserted_timmy_local_user.clone(),
|
local_user: inserted_timmy_local_user.clone(),
|
||||||
|
local_user_vote_display_mode: LocalUserVoteDisplayMode::default(),
|
||||||
person: inserted_timmy_person.clone(),
|
person: inserted_timmy_person.clone(),
|
||||||
counts: Default::default(),
|
counts: Default::default(),
|
||||||
};
|
};
|
||||||
|
@ -631,12 +655,12 @@ mod tests {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn test_crud() {
|
async fn test_crud() -> LemmyResult<()> {
|
||||||
let pool = &build_db_pool_for_tests().await;
|
let pool = &build_db_pool_for_tests().await;
|
||||||
let pool = &mut pool.into();
|
let pool = &mut pool.into();
|
||||||
let data = init_data(pool).await;
|
let data = init_data(pool).await;
|
||||||
|
|
||||||
let expected_comment_view_no_person = expected_comment_view(&data, pool).await;
|
let expected_comment_view_no_person = expected_comment_view(&data, pool).await?;
|
||||||
|
|
||||||
let mut expected_comment_view_with_person = expected_comment_view_no_person.clone();
|
let mut expected_comment_view_with_person = expected_comment_view_no_person.clone();
|
||||||
expected_comment_view_with_person.my_vote = Some(1);
|
expected_comment_view_with_person.my_vote = Some(1);
|
||||||
|
@ -647,8 +671,7 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected_comment_view_no_person,
|
expected_comment_view_no_person,
|
||||||
|
@ -662,8 +685,7 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected_comment_view_with_person,
|
expected_comment_view_with_person,
|
||||||
|
@ -678,8 +700,7 @@ mod tests {
|
||||||
data.inserted_comment_1.id,
|
data.inserted_comment_1.id,
|
||||||
Some(data.timmy_local_user_view.person.id),
|
Some(data.timmy_local_user_view.person.id),
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Make sure block set the creator blocked
|
// Make sure block set the creator blocked
|
||||||
assert!(read_comment_from_blocked_person.creator_blocked);
|
assert!(read_comment_from_blocked_person.creator_blocked);
|
||||||
|
@ -690,8 +711,7 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected_comment_view_with_person,
|
expected_comment_view_with_person,
|
||||||
|
@ -706,17 +726,16 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert!(read_disliked_comment_views.is_empty());
|
assert!(read_disliked_comment_views.is_empty());
|
||||||
|
|
||||||
cleanup(data, pool).await;
|
cleanup(data, pool).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn test_comment_tree() {
|
async fn test_comment_tree() -> LemmyResult<()> {
|
||||||
let pool = &build_db_pool_for_tests().await;
|
let pool = &build_db_pool_for_tests().await;
|
||||||
let pool = &mut pool.into();
|
let pool = &mut pool.into();
|
||||||
let data = init_data(pool).await;
|
let data = init_data(pool).await;
|
||||||
|
@ -728,8 +747,7 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let child_path = data.inserted_comment_1.path.clone();
|
let child_path = data.inserted_comment_1.path.clone();
|
||||||
let read_comment_views_child_path = CommentQuery {
|
let read_comment_views_child_path = CommentQuery {
|
||||||
|
@ -738,8 +756,7 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Make sure the comment parent-limited fetch is correct
|
// Make sure the comment parent-limited fetch is correct
|
||||||
assert_length!(6, read_comment_views_top_path);
|
assert_length!(6, read_comment_views_top_path);
|
||||||
|
@ -759,12 +776,11 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Make sure a depth limited one only has the top comment
|
// Make sure a depth limited one only has the top comment
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected_comment_view(&data, pool).await,
|
expected_comment_view(&data, pool).await?,
|
||||||
read_comment_views_top_max_depth[0]
|
read_comment_views_top_max_depth[0]
|
||||||
);
|
);
|
||||||
assert_length!(1, read_comment_views_top_max_depth);
|
assert_length!(1, read_comment_views_top_max_depth);
|
||||||
|
@ -778,8 +794,7 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Make sure a depth limited one, and given child comment 1, has 3
|
// Make sure a depth limited one, and given child comment 1, has 3
|
||||||
assert!(read_comment_views_parent_max_depth[2]
|
assert!(read_comment_views_parent_max_depth[2]
|
||||||
|
@ -788,12 +803,12 @@ mod tests {
|
||||||
.eq("Comment 3"));
|
.eq("Comment 3"));
|
||||||
assert_length!(3, read_comment_views_parent_max_depth);
|
assert_length!(3, read_comment_views_parent_max_depth);
|
||||||
|
|
||||||
cleanup(data, pool).await;
|
cleanup(data, pool).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn test_languages() {
|
async fn test_languages() -> LemmyResult<()> {
|
||||||
let pool = &build_db_pool_for_tests().await;
|
let pool = &build_db_pool_for_tests().await;
|
||||||
let pool = &mut pool.into();
|
let pool = &mut pool.into();
|
||||||
let data = init_data(pool).await;
|
let data = init_data(pool).await;
|
||||||
|
@ -805,29 +820,25 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
assert_length!(5, all_languages);
|
assert_length!(5, all_languages);
|
||||||
|
|
||||||
// change user lang to finnish, should only show one post in finnish and one undetermined
|
// change user lang to finnish, should only show one post in finnish and one undetermined
|
||||||
let finnish_id = Language::read_id_from_code(pool, Some("fi"))
|
let finnish_id = Language::read_id_from_code(pool, Some("fi"))
|
||||||
.await
|
.await?
|
||||||
.unwrap()
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
LocalUserLanguage::update(
|
LocalUserLanguage::update(
|
||||||
pool,
|
pool,
|
||||||
vec![finnish_id],
|
vec![finnish_id],
|
||||||
data.timmy_local_user_view.local_user.id,
|
data.timmy_local_user_view.local_user.id,
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
let finnish_comments = CommentQuery {
|
let finnish_comments = CommentQuery {
|
||||||
local_user: (Some(&data.timmy_local_user_view)),
|
local_user: (Some(&data.timmy_local_user_view)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
assert_length!(2, finnish_comments);
|
assert_length!(2, finnish_comments);
|
||||||
let finnish_comment = finnish_comments
|
let finnish_comment = finnish_comments
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -844,23 +855,21 @@ mod tests {
|
||||||
vec![UNDETERMINED_ID],
|
vec![UNDETERMINED_ID],
|
||||||
data.timmy_local_user_view.local_user.id,
|
data.timmy_local_user_view.local_user.id,
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
let undetermined_comment = CommentQuery {
|
let undetermined_comment = CommentQuery {
|
||||||
local_user: (Some(&data.timmy_local_user_view)),
|
local_user: (Some(&data.timmy_local_user_view)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
assert_length!(1, undetermined_comment);
|
assert_length!(1, undetermined_comment);
|
||||||
|
|
||||||
cleanup(data, pool).await;
|
cleanup(data, pool).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn test_distinguished_first() {
|
async fn test_distinguished_first() -> LemmyResult<()> {
|
||||||
let pool = &build_db_pool_for_tests().await;
|
let pool = &build_db_pool_for_tests().await;
|
||||||
let pool = &mut pool.into();
|
let pool = &mut pool.into();
|
||||||
let data = init_data(pool).await;
|
let data = init_data(pool).await;
|
||||||
|
@ -869,26 +878,23 @@ mod tests {
|
||||||
distinguished: Some(true),
|
distinguished: Some(true),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
Comment::update(pool, data.inserted_comment_2.id, &form)
|
Comment::update(pool, data.inserted_comment_2.id, &form).await?;
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let comments = CommentQuery {
|
let comments = CommentQuery {
|
||||||
post_id: Some(data.inserted_comment_2.post_id),
|
post_id: Some(data.inserted_comment_2.post_id),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
assert_eq!(comments[0].comment.id, data.inserted_comment_2.id);
|
assert_eq!(comments[0].comment.id, data.inserted_comment_2.id);
|
||||||
assert!(comments[0].comment.distinguished);
|
assert!(comments[0].comment.distinguished);
|
||||||
|
|
||||||
cleanup(data, pool).await;
|
cleanup(data, pool).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn test_creator_is_moderator() {
|
async fn test_creator_is_moderator() -> LemmyResult<()> {
|
||||||
let pool = &build_db_pool_for_tests().await;
|
let pool = &build_db_pool_for_tests().await;
|
||||||
let pool = &mut pool.into();
|
let pool = &mut pool.into();
|
||||||
let data = init_data(pool).await;
|
let data = init_data(pool).await;
|
||||||
|
@ -900,7 +906,7 @@ mod tests {
|
||||||
community_id,
|
community_id,
|
||||||
person_id,
|
person_id,
|
||||||
};
|
};
|
||||||
CommunityModerator::join(pool, &form).await.unwrap();
|
CommunityModerator::join(pool, &form).await?;
|
||||||
|
|
||||||
// Make sure that they come back as a mod in the list
|
// Make sure that they come back as a mod in the list
|
||||||
let comments = CommentQuery {
|
let comments = CommentQuery {
|
||||||
|
@ -908,19 +914,18 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(comments[1].creator.name, "sara");
|
assert_eq!(comments[1].creator.name, "sara");
|
||||||
assert!(comments[1].creator_is_moderator);
|
assert!(comments[1].creator_is_moderator);
|
||||||
assert!(!comments[0].creator_is_moderator);
|
assert!(!comments[0].creator_is_moderator);
|
||||||
|
|
||||||
cleanup(data, pool).await;
|
cleanup(data, pool).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn test_creator_is_admin() {
|
async fn test_creator_is_admin() -> LemmyResult<()> {
|
||||||
let pool = &build_db_pool_for_tests().await;
|
let pool = &build_db_pool_for_tests().await;
|
||||||
let pool = &mut pool.into();
|
let pool = &mut pool.into();
|
||||||
let data = init_data(pool).await;
|
let data = init_data(pool).await;
|
||||||
|
@ -930,8 +935,7 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Timmy is an admin, and make sure that field is true
|
// Timmy is an admin, and make sure that field is true
|
||||||
assert_eq!(comments[0].creator.name, "timmy");
|
assert_eq!(comments[0].creator.name, "timmy");
|
||||||
|
@ -941,12 +945,12 @@ mod tests {
|
||||||
assert_eq!(comments[1].creator.name, "sara");
|
assert_eq!(comments[1].creator.name, "sara");
|
||||||
assert!(!comments[1].creator_is_admin);
|
assert!(!comments[1].creator_is_admin);
|
||||||
|
|
||||||
cleanup(data, pool).await;
|
cleanup(data, pool).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn test_saved_order() {
|
async fn test_saved_order() -> LemmyResult<()> {
|
||||||
let pool = &build_db_pool_for_tests().await;
|
let pool = &build_db_pool_for_tests().await;
|
||||||
let pool = &mut pool.into();
|
let pool = &mut pool.into();
|
||||||
let data = init_data(pool).await;
|
let data = init_data(pool).await;
|
||||||
|
@ -956,17 +960,13 @@ mod tests {
|
||||||
person_id: data.timmy_local_user_view.person.id,
|
person_id: data.timmy_local_user_view.person.id,
|
||||||
comment_id: data.inserted_comment_0.id,
|
comment_id: data.inserted_comment_0.id,
|
||||||
};
|
};
|
||||||
CommentSaved::save(pool, &save_comment_0_form)
|
CommentSaved::save(pool, &save_comment_0_form).await?;
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let save_comment_2_form = CommentSavedForm {
|
let save_comment_2_form = CommentSavedForm {
|
||||||
person_id: data.timmy_local_user_view.person.id,
|
person_id: data.timmy_local_user_view.person.id,
|
||||||
comment_id: data.inserted_comment_2.id,
|
comment_id: data.inserted_comment_2.id,
|
||||||
};
|
};
|
||||||
CommentSaved::save(pool, &save_comment_2_form)
|
CommentSaved::save(pool, &save_comment_2_form).await?;
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Fetch the saved comments
|
// Fetch the saved comments
|
||||||
let comments = CommentQuery {
|
let comments = CommentQuery {
|
||||||
|
@ -975,8 +975,7 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// There should only be two comments
|
// There should only be two comments
|
||||||
assert_eq!(2, comments.len());
|
assert_eq!(2, comments.len());
|
||||||
|
@ -987,47 +986,33 @@ mod tests {
|
||||||
// The second comment, should be the first one saved
|
// The second comment, should be the first one saved
|
||||||
assert_eq!(comments[1].comment.id, data.inserted_comment_0.id);
|
assert_eq!(comments[1].comment.id, data.inserted_comment_0.id);
|
||||||
|
|
||||||
cleanup(data, pool).await;
|
cleanup(data, pool).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn cleanup(data: Data, pool: &mut DbPool<'_>) {
|
async fn cleanup(data: Data, pool: &mut DbPool<'_>) -> LemmyResult<()> {
|
||||||
CommentLike::remove(
|
CommentLike::remove(
|
||||||
pool,
|
pool,
|
||||||
data.timmy_local_user_view.person.id,
|
data.timmy_local_user_view.person.id,
|
||||||
data.inserted_comment_0.id,
|
data.inserted_comment_0.id,
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
Comment::delete(pool, data.inserted_comment_0.id).await?;
|
||||||
Comment::delete(pool, data.inserted_comment_0.id)
|
Comment::delete(pool, data.inserted_comment_1.id).await?;
|
||||||
.await
|
Post::delete(pool, data.inserted_post.id).await?;
|
||||||
.unwrap();
|
Community::delete(pool, data.inserted_community.id).await?;
|
||||||
Comment::delete(pool, data.inserted_comment_1.id)
|
Person::delete(pool, data.timmy_local_user_view.person.id).await?;
|
||||||
.await
|
LocalUser::delete(pool, data.timmy_local_user_view.local_user.id).await?;
|
||||||
.unwrap();
|
Person::delete(pool, data.inserted_sara_person.id).await?;
|
||||||
Post::delete(pool, data.inserted_post.id).await.unwrap();
|
Instance::delete(pool, data.inserted_instance.id).await?;
|
||||||
Community::delete(pool, data.inserted_community.id)
|
|
||||||
.await
|
Ok(())
|
||||||
.unwrap();
|
|
||||||
Person::delete(pool, data.timmy_local_user_view.person.id)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
LocalUser::delete(pool, data.timmy_local_user_view.local_user.id)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
Person::delete(pool, data.inserted_sara_person.id)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
Instance::delete(pool, data.inserted_instance.id)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn expected_comment_view(data: &Data, pool: &mut DbPool<'_>) -> CommentView {
|
async fn expected_comment_view(data: &Data, pool: &mut DbPool<'_>) -> LemmyResult<CommentView> {
|
||||||
let agg = CommentAggregates::read(pool, data.inserted_comment_0.id)
|
let agg = CommentAggregates::read(pool, data.inserted_comment_0.id).await?;
|
||||||
.await
|
Ok(CommentView {
|
||||||
.unwrap();
|
|
||||||
CommentView {
|
|
||||||
creator_banned_from_community: false,
|
creator_banned_from_community: false,
|
||||||
|
banned_from_community: false,
|
||||||
creator_is_moderator: false,
|
creator_is_moderator: false,
|
||||||
creator_is_admin: true,
|
creator_is_admin: true,
|
||||||
my_vote: None,
|
my_vote: None,
|
||||||
|
@ -1134,12 +1119,12 @@ mod tests {
|
||||||
hot_rank: RANK_DEFAULT,
|
hot_rank: RANK_DEFAULT,
|
||||||
controversy_rank: 0.0,
|
controversy_rank: 0.0,
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn local_only_instance() {
|
async fn local_only_instance() -> LemmyResult<()> {
|
||||||
let pool = &build_db_pool_for_tests().await;
|
let pool = &build_db_pool_for_tests().await;
|
||||||
let pool = &mut pool.into();
|
let pool = &mut pool.into();
|
||||||
let data = init_data(pool).await;
|
let data = init_data(pool).await;
|
||||||
|
@ -1152,15 +1137,13 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let unauthenticated_query = CommentQuery {
|
let unauthenticated_query = CommentQuery {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
assert_eq!(0, unauthenticated_query.len());
|
assert_eq!(0, unauthenticated_query.len());
|
||||||
|
|
||||||
let authenticated_query = CommentQuery {
|
let authenticated_query = CommentQuery {
|
||||||
|
@ -1168,8 +1151,7 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
assert_eq!(5, authenticated_query.len());
|
assert_eq!(5, authenticated_query.len());
|
||||||
|
|
||||||
let unauthenticated_comment = CommentView::read(pool, data.inserted_comment_0.id, None).await;
|
let unauthenticated_comment = CommentView::read(pool, data.inserted_comment_0.id, None).await;
|
||||||
|
@ -1183,6 +1165,67 @@ mod tests {
|
||||||
.await;
|
.await;
|
||||||
assert!(authenticated_comment.is_ok());
|
assert!(authenticated_comment.is_ok());
|
||||||
|
|
||||||
cleanup(data, pool).await;
|
cleanup(data, pool).await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
#[serial]
|
||||||
|
async fn comment_listing_local_user_banned_from_community() -> LemmyResult<()> {
|
||||||
|
let pool = &build_db_pool_for_tests().await;
|
||||||
|
let pool = &mut pool.into();
|
||||||
|
let data = init_data(pool).await;
|
||||||
|
|
||||||
|
// Test that comment view shows if local user is blocked from community
|
||||||
|
let banned_from_comm_person = PersonInsertForm::test_form(data.inserted_instance.id, "jill");
|
||||||
|
|
||||||
|
let inserted_banned_from_comm_person = Person::create(pool, &banned_from_comm_person).await?;
|
||||||
|
|
||||||
|
let inserted_banned_from_comm_local_user = LocalUser::create(
|
||||||
|
pool,
|
||||||
|
&LocalUserInsertForm::test_form(inserted_banned_from_comm_person.id),
|
||||||
|
vec![],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
CommunityPersonBan::ban(
|
||||||
|
pool,
|
||||||
|
&CommunityPersonBanForm {
|
||||||
|
community_id: data.inserted_community.id,
|
||||||
|
person_id: inserted_banned_from_comm_person.id,
|
||||||
|
expires: None,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let comment_view = CommentView::read(
|
||||||
|
pool,
|
||||||
|
data.inserted_comment_0.id,
|
||||||
|
Some(inserted_banned_from_comm_local_user.person_id),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
assert!(comment_view.banned_from_community);
|
||||||
|
|
||||||
|
Person::delete(pool, inserted_banned_from_comm_person.id).await?;
|
||||||
|
cleanup(data, pool).await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
#[serial]
|
||||||
|
async fn comment_listing_local_user_not_banned_from_community() -> LemmyResult<()> {
|
||||||
|
let pool = &build_db_pool_for_tests().await;
|
||||||
|
let pool = &mut pool.into();
|
||||||
|
let data = init_data(pool).await;
|
||||||
|
|
||||||
|
let comment_view = CommentView::read(
|
||||||
|
pool,
|
||||||
|
data.inserted_comment_0.id,
|
||||||
|
Some(data.timmy_local_user_view.person.id),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
assert!(!comment_view.banned_from_community);
|
||||||
|
|
||||||
|
cleanup(data, pool).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ impl CustomEmojiView {
|
||||||
}
|
}
|
||||||
for emoji in &mut result {
|
for emoji in &mut result {
|
||||||
if let Some(keywords) = hash.get_mut(&emoji.custom_emoji.id) {
|
if let Some(keywords) = hash.get_mut(&emoji.custom_emoji.id) {
|
||||||
emoji.keywords = keywords.clone();
|
emoji.keywords.clone_from(keywords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
|
|
|
@ -4,7 +4,7 @@ use diesel::{result::Error, BoolExpressionMethods, ExpressionMethods, JoinOnDsl,
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
newtypes::{LocalUserId, PersonId},
|
newtypes::{LocalUserId, PersonId},
|
||||||
schema::{local_user, person, person_aggregates},
|
schema::{local_user, local_user_vote_display_mode, person, person_aggregates},
|
||||||
utils::{
|
utils::{
|
||||||
functions::{coalesce, lower},
|
functions::{coalesce, lower},
|
||||||
DbConn,
|
DbConn,
|
||||||
|
@ -33,6 +33,7 @@ fn queries<'a>(
|
||||||
) -> Queries<impl ReadFn<'a, LocalUserView, ReadBy<'a>>, impl ListFn<'a, LocalUserView, ListMode>> {
|
) -> Queries<impl ReadFn<'a, LocalUserView, ReadBy<'a>>, impl ListFn<'a, LocalUserView, ListMode>> {
|
||||||
let selection = (
|
let selection = (
|
||||||
local_user::all_columns,
|
local_user::all_columns,
|
||||||
|
local_user_vote_display_mode::all_columns,
|
||||||
person::all_columns,
|
person::all_columns,
|
||||||
person_aggregates::all_columns,
|
person_aggregates::all_columns,
|
||||||
);
|
);
|
||||||
|
@ -58,6 +59,7 @@ fn queries<'a>(
|
||||||
_ => query,
|
_ => query,
|
||||||
};
|
};
|
||||||
query
|
query
|
||||||
|
.inner_join(local_user_vote_display_mode::table)
|
||||||
.inner_join(person_aggregates::table.on(person::id.eq(person_aggregates::person_id)))
|
.inner_join(person_aggregates::table.on(person::id.eq(person_aggregates::person_id)))
|
||||||
.select(selection)
|
.select(selection)
|
||||||
.first::<LocalUserView>(&mut conn)
|
.first::<LocalUserView>(&mut conn)
|
||||||
|
@ -68,10 +70,11 @@ fn queries<'a>(
|
||||||
match mode {
|
match mode {
|
||||||
ListMode::AdminsWithEmails => {
|
ListMode::AdminsWithEmails => {
|
||||||
local_user::table
|
local_user::table
|
||||||
.filter(local_user::email.is_not_null())
|
.inner_join(local_user_vote_display_mode::table)
|
||||||
.filter(local_user::admin.eq(true))
|
|
||||||
.inner_join(person::table)
|
.inner_join(person::table)
|
||||||
.inner_join(person_aggregates::table.on(person::id.eq(person_aggregates::person_id)))
|
.inner_join(person_aggregates::table.on(person::id.eq(person_aggregates::person_id)))
|
||||||
|
.filter(local_user::email.is_not_null())
|
||||||
|
.filter(local_user::admin.eq(true))
|
||||||
.select(selection)
|
.select(selection)
|
||||||
.load::<LocalUserView>(&mut conn)
|
.load::<LocalUserView>(&mut conn)
|
||||||
.await
|
.await
|
||||||
|
|
|
@ -14,15 +14,31 @@ use lemmy_db_schema::{
|
||||||
newtypes::{CommunityId, PersonId, PostId, PostReportId},
|
newtypes::{CommunityId, PersonId, PostId, PostReportId},
|
||||||
schema::{
|
schema::{
|
||||||
community,
|
community,
|
||||||
|
community_follower,
|
||||||
community_moderator,
|
community_moderator,
|
||||||
community_person_ban,
|
community_person_ban,
|
||||||
|
local_user,
|
||||||
person,
|
person,
|
||||||
|
person_block,
|
||||||
|
person_post_aggregates,
|
||||||
post,
|
post,
|
||||||
post_aggregates,
|
post_aggregates,
|
||||||
|
post_hide,
|
||||||
post_like,
|
post_like,
|
||||||
|
post_read,
|
||||||
post_report,
|
post_report,
|
||||||
|
post_saved,
|
||||||
|
},
|
||||||
|
utils::{
|
||||||
|
functions::coalesce,
|
||||||
|
get_conn,
|
||||||
|
limit_and_offset,
|
||||||
|
DbConn,
|
||||||
|
DbPool,
|
||||||
|
ListFn,
|
||||||
|
Queries,
|
||||||
|
ReadFn,
|
||||||
},
|
},
|
||||||
utils::{get_conn, limit_and_offset, DbConn, DbPool, ListFn, Queries, ReadFn},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fn queries<'a>() -> Queries<
|
fn queries<'a>() -> Queries<
|
||||||
|
@ -42,6 +58,67 @@ fn queries<'a>() -> Queries<
|
||||||
.and(community_person_ban::person_id.eq(post::creator_id)),
|
.and(community_person_ban::person_id.eq(post::creator_id)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.left_join(
|
||||||
|
aliases::community_moderator1.on(
|
||||||
|
aliases::community_moderator1
|
||||||
|
.field(community_moderator::community_id)
|
||||||
|
.eq(post::community_id)
|
||||||
|
.and(
|
||||||
|
aliases::community_moderator1
|
||||||
|
.field(community_moderator::person_id)
|
||||||
|
.eq(my_person_id),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.left_join(
|
||||||
|
local_user::table.on(
|
||||||
|
post::creator_id
|
||||||
|
.eq(local_user::person_id)
|
||||||
|
.and(local_user::admin.eq(true)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.left_join(
|
||||||
|
post_saved::table.on(
|
||||||
|
post::id
|
||||||
|
.eq(post_saved::post_id)
|
||||||
|
.and(post_saved::person_id.eq(my_person_id)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.left_join(
|
||||||
|
post_read::table.on(
|
||||||
|
post::id
|
||||||
|
.eq(post_read::post_id)
|
||||||
|
.and(post_read::person_id.eq(my_person_id)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.left_join(
|
||||||
|
post_hide::table.on(
|
||||||
|
post::id
|
||||||
|
.eq(post_hide::post_id)
|
||||||
|
.and(post_hide::person_id.eq(my_person_id)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.left_join(
|
||||||
|
person_block::table.on(
|
||||||
|
post::creator_id
|
||||||
|
.eq(person_block::target_id)
|
||||||
|
.and(person_block::person_id.eq(my_person_id)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.left_join(
|
||||||
|
person_post_aggregates::table.on(
|
||||||
|
post::id
|
||||||
|
.eq(person_post_aggregates::post_id)
|
||||||
|
.and(person_post_aggregates::person_id.eq(my_person_id)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.left_join(
|
||||||
|
community_follower::table.on(
|
||||||
|
post::community_id
|
||||||
|
.eq(community_follower::community_id)
|
||||||
|
.and(community_follower::person_id.eq(my_person_id)),
|
||||||
|
),
|
||||||
|
)
|
||||||
.left_join(
|
.left_join(
|
||||||
post_like::table.on(
|
post_like::table.on(
|
||||||
post::id
|
post::id
|
||||||
|
@ -61,7 +138,21 @@ fn queries<'a>() -> Queries<
|
||||||
person::all_columns,
|
person::all_columns,
|
||||||
aliases::person1.fields(person::all_columns),
|
aliases::person1.fields(person::all_columns),
|
||||||
community_person_ban::community_id.nullable().is_not_null(),
|
community_person_ban::community_id.nullable().is_not_null(),
|
||||||
|
aliases::community_moderator1
|
||||||
|
.field(community_moderator::community_id)
|
||||||
|
.nullable()
|
||||||
|
.is_not_null(),
|
||||||
|
local_user::admin.nullable().is_not_null(),
|
||||||
|
community_follower::pending.nullable(),
|
||||||
|
post_saved::post_id.nullable().is_not_null(),
|
||||||
|
post_read::post_id.nullable().is_not_null(),
|
||||||
|
post_hide::post_id.nullable().is_not_null(),
|
||||||
|
person_block::target_id.nullable().is_not_null(),
|
||||||
post_like::score.nullable(),
|
post_like::score.nullable(),
|
||||||
|
coalesce(
|
||||||
|
post_aggregates::comments.nullable() - person_post_aggregates::read_comments.nullable(),
|
||||||
|
post_aggregates::comments,
|
||||||
|
),
|
||||||
post_aggregates::all_columns,
|
post_aggregates::all_columns,
|
||||||
aliases::person2.fields(person::all_columns.nullable()),
|
aliases::person2.fields(person::all_columns.nullable()),
|
||||||
))
|
))
|
||||||
|
@ -192,9 +283,9 @@ impl PostReportQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
#![allow(clippy::indexing_slicing)]
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
post_report_view::{PostReportQuery, PostReportView},
|
post_report_view::{PostReportQuery, PostReportView},
|
||||||
|
@ -206,6 +297,7 @@ mod tests {
|
||||||
community::{Community, CommunityInsertForm, CommunityModerator, CommunityModeratorForm},
|
community::{Community, CommunityInsertForm, CommunityModerator, CommunityModeratorForm},
|
||||||
instance::Instance,
|
instance::Instance,
|
||||||
local_user::{LocalUser, LocalUserInsertForm},
|
local_user::{LocalUser, LocalUserInsertForm},
|
||||||
|
local_user_vote_display_mode::LocalUserVoteDisplayMode,
|
||||||
person::{Person, PersonInsertForm},
|
person::{Person, PersonInsertForm},
|
||||||
post::{Post, PostInsertForm},
|
post::{Post, PostInsertForm},
|
||||||
post_report::{PostReport, PostReportForm},
|
post_report::{PostReport, PostReportForm},
|
||||||
|
@ -238,9 +330,12 @@ mod tests {
|
||||||
.person_id(inserted_timmy.id)
|
.person_id(inserted_timmy.id)
|
||||||
.password_encrypted("123".to_string())
|
.password_encrypted("123".to_string())
|
||||||
.build();
|
.build();
|
||||||
let timmy_local_user = LocalUser::create(pool, &new_local_user).await.unwrap();
|
let timmy_local_user = LocalUser::create(pool, &new_local_user, vec![])
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
let timmy_view = LocalUserView {
|
let timmy_view = LocalUserView {
|
||||||
local_user: timmy_local_user,
|
local_user: timmy_local_user,
|
||||||
|
local_user_vote_display_mode: LocalUserVoteDisplayMode::default(),
|
||||||
person: inserted_timmy.clone(),
|
person: inserted_timmy.clone(),
|
||||||
counts: Default::default(),
|
counts: Default::default(),
|
||||||
};
|
};
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue