mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 13:51:19 +00:00
Merge branch 'main' into no-overwrite-local
This commit is contained in:
commit
f53327cde7
205 changed files with 1111 additions and 891 deletions
26
Cargo.lock
generated
26
Cargo.lock
generated
|
@ -2612,7 +2612,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||
|
||||
[[package]]
|
||||
name = "lemmy_api"
|
||||
version = "0.19.4-beta.2"
|
||||
version = "0.19.4-beta.3"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"actix-web",
|
||||
|
@ -2641,7 +2641,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lemmy_api_common"
|
||||
version = "0.19.4-beta.2"
|
||||
version = "0.19.4-beta.3"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"actix-web",
|
||||
|
@ -2679,7 +2679,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lemmy_api_crud"
|
||||
version = "0.19.4-beta.2"
|
||||
version = "0.19.4-beta.3"
|
||||
dependencies = [
|
||||
"accept-language",
|
||||
"activitypub_federation",
|
||||
|
@ -2702,7 +2702,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lemmy_apub"
|
||||
version = "0.19.4-beta.2"
|
||||
version = "0.19.4-beta.3"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"actix-web",
|
||||
|
@ -2740,7 +2740,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lemmy_db_perf"
|
||||
version = "0.19.4-beta.2"
|
||||
version = "0.19.4-beta.3"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
@ -2755,7 +2755,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lemmy_db_schema"
|
||||
version = "0.19.4-beta.2"
|
||||
version = "0.19.4-beta.3"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"anyhow",
|
||||
|
@ -2795,7 +2795,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lemmy_db_views"
|
||||
version = "0.19.4-beta.2"
|
||||
version = "0.19.4-beta.3"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"chrono",
|
||||
|
@ -2817,7 +2817,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lemmy_db_views_actor"
|
||||
version = "0.19.4-beta.2"
|
||||
version = "0.19.4-beta.3"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"diesel",
|
||||
|
@ -2837,7 +2837,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lemmy_db_views_moderator"
|
||||
version = "0.19.4-beta.2"
|
||||
version = "0.19.4-beta.3"
|
||||
dependencies = [
|
||||
"diesel",
|
||||
"diesel-async",
|
||||
|
@ -2849,7 +2849,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lemmy_federate"
|
||||
version = "0.19.4-beta.2"
|
||||
version = "0.19.4-beta.3"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"anyhow",
|
||||
|
@ -2872,7 +2872,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lemmy_routes"
|
||||
version = "0.19.4-beta.2"
|
||||
version = "0.19.4-beta.3"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"actix-web",
|
||||
|
@ -2897,7 +2897,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lemmy_server"
|
||||
version = "0.19.4-beta.2"
|
||||
version = "0.19.4-beta.3"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"actix-cors",
|
||||
|
@ -2940,7 +2940,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lemmy_utils"
|
||||
version = "0.19.4-beta.2"
|
||||
version = "0.19.4-beta.3"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"anyhow",
|
||||
|
|
24
Cargo.toml
24
Cargo.toml
|
@ -1,5 +1,5 @@
|
|||
[workspace.package]
|
||||
version = "0.19.4-beta.2"
|
||||
version = "0.19.4-beta.3"
|
||||
edition = "2021"
|
||||
description = "A link aggregator for the fediverse"
|
||||
license = "AGPL-3.0"
|
||||
|
@ -88,17 +88,17 @@ unused_self = "deny"
|
|||
unwrap_used = "deny"
|
||||
|
||||
[workspace.dependencies]
|
||||
lemmy_api = { version = "=0.19.4-beta.2", path = "./crates/api" }
|
||||
lemmy_api_crud = { version = "=0.19.4-beta.2", path = "./crates/api_crud" }
|
||||
lemmy_apub = { version = "=0.19.4-beta.2", path = "./crates/apub" }
|
||||
lemmy_utils = { version = "=0.19.4-beta.2", path = "./crates/utils", default-features = false }
|
||||
lemmy_db_schema = { version = "=0.19.4-beta.2", path = "./crates/db_schema" }
|
||||
lemmy_api_common = { version = "=0.19.4-beta.2", path = "./crates/api_common" }
|
||||
lemmy_routes = { version = "=0.19.4-beta.2", path = "./crates/routes" }
|
||||
lemmy_db_views = { version = "=0.19.4-beta.2", path = "./crates/db_views" }
|
||||
lemmy_db_views_actor = { version = "=0.19.4-beta.2", path = "./crates/db_views_actor" }
|
||||
lemmy_db_views_moderator = { version = "=0.19.4-beta.2", path = "./crates/db_views_moderator" }
|
||||
lemmy_federate = { version = "=0.19.4-beta.2", path = "./crates/federate" }
|
||||
lemmy_api = { version = "=0.19.4-beta.3", path = "./crates/api" }
|
||||
lemmy_api_crud = { version = "=0.19.4-beta.3", path = "./crates/api_crud" }
|
||||
lemmy_apub = { version = "=0.19.4-beta.3", path = "./crates/apub" }
|
||||
lemmy_utils = { version = "=0.19.4-beta.3", path = "./crates/utils", default-features = false }
|
||||
lemmy_db_schema = { version = "=0.19.4-beta.3", path = "./crates/db_schema" }
|
||||
lemmy_api_common = { version = "=0.19.4-beta.3", path = "./crates/api_common" }
|
||||
lemmy_routes = { version = "=0.19.4-beta.3", path = "./crates/routes" }
|
||||
lemmy_db_views = { version = "=0.19.4-beta.3", path = "./crates/db_views" }
|
||||
lemmy_db_views_actor = { version = "=0.19.4-beta.3", path = "./crates/db_views_actor" }
|
||||
lemmy_db_views_moderator = { version = "=0.19.4-beta.3", path = "./crates/db_views_moderator" }
|
||||
lemmy_federate = { version = "=0.19.4-beta.3", path = "./crates/federate" }
|
||||
activitypub_federation = { version = "0.5.4", default-features = false, features = [
|
||||
"actix-web",
|
||||
] }
|
||||
|
|
|
@ -20,16 +20,16 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^20.11.27",
|
||||
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
||||
"@typescript-eslint/parser": "^7.2.0",
|
||||
"@types/node": "^20.12.4",
|
||||
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
||||
"@typescript-eslint/parser": "^7.5.0",
|
||||
"download-file-sync": "^1.0.4",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"jest": "^29.5.0",
|
||||
"lemmy-js-client": "0.19.4-alpha.13",
|
||||
"lemmy-js-client": "0.19.4-alpha.16",
|
||||
"prettier": "^3.2.5",
|
||||
"ts-jest": "^29.1.0",
|
||||
"typescript": "^5.4.2"
|
||||
"typescript": "^5.4.4"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,14 +9,14 @@ devDependencies:
|
|||
specifier: ^29.5.12
|
||||
version: 29.5.12
|
||||
'@types/node':
|
||||
specifier: ^20.11.27
|
||||
version: 20.11.27
|
||||
specifier: ^20.12.4
|
||||
version: 20.12.4
|
||||
'@typescript-eslint/eslint-plugin':
|
||||
specifier: ^7.2.0
|
||||
version: 7.2.0(@typescript-eslint/parser@7.2.0)(eslint@8.57.0)(typescript@5.4.2)
|
||||
specifier: ^7.5.0
|
||||
version: 7.5.0(@typescript-eslint/parser@7.5.0)(eslint@8.57.0)(typescript@5.4.4)
|
||||
'@typescript-eslint/parser':
|
||||
specifier: ^7.2.0
|
||||
version: 7.2.0(eslint@8.57.0)(typescript@5.4.2)
|
||||
specifier: ^7.5.0
|
||||
version: 7.5.0(eslint@8.57.0)(typescript@5.4.4)
|
||||
download-file-sync:
|
||||
specifier: ^1.0.4
|
||||
version: 1.0.4
|
||||
|
@ -28,19 +28,19 @@ devDependencies:
|
|||
version: 5.1.3(eslint@8.57.0)(prettier@3.2.5)
|
||||
jest:
|
||||
specifier: ^29.5.0
|
||||
version: 29.7.0(@types/node@20.11.27)
|
||||
version: 29.7.0(@types/node@20.12.4)
|
||||
lemmy-js-client:
|
||||
specifier: 0.19.4-alpha.13
|
||||
version: 0.19.4-alpha.13
|
||||
specifier: 0.19.4-alpha.16
|
||||
version: 0.19.4-alpha.16
|
||||
prettier:
|
||||
specifier: ^3.2.5
|
||||
version: 3.2.5
|
||||
ts-jest:
|
||||
specifier: ^29.1.0
|
||||
version: 29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.4.2)
|
||||
version: 29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.4.4)
|
||||
typescript:
|
||||
specifier: ^5.4.2
|
||||
version: 5.4.2
|
||||
specifier: ^5.4.4
|
||||
version: 5.4.4
|
||||
|
||||
packages:
|
||||
|
||||
|
@ -464,7 +464,7 @@ packages:
|
|||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
chalk: 4.1.2
|
||||
jest-message-util: 29.7.0
|
||||
jest-util: 29.7.0
|
||||
|
@ -485,14 +485,14 @@ packages:
|
|||
'@jest/test-result': 29.7.0
|
||||
'@jest/transform': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
ansi-escapes: 4.3.2
|
||||
chalk: 4.1.2
|
||||
ci-info: 3.9.0
|
||||
exit: 0.1.2
|
||||
graceful-fs: 4.2.11
|
||||
jest-changed-files: 29.7.0
|
||||
jest-config: 29.7.0(@types/node@20.11.27)
|
||||
jest-config: 29.7.0(@types/node@20.12.4)
|
||||
jest-haste-map: 29.7.0
|
||||
jest-message-util: 29.7.0
|
||||
jest-regex-util: 29.6.3
|
||||
|
@ -520,7 +520,7 @@ packages:
|
|||
dependencies:
|
||||
'@jest/fake-timers': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
jest-mock: 29.7.0
|
||||
dev: true
|
||||
|
||||
|
@ -547,7 +547,7 @@ packages:
|
|||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@sinonjs/fake-timers': 10.3.0
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
jest-message-util: 29.7.0
|
||||
jest-mock: 29.7.0
|
||||
jest-util: 29.7.0
|
||||
|
@ -580,7 +580,7 @@ packages:
|
|||
'@jest/transform': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@jridgewell/trace-mapping': 0.3.22
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
chalk: 4.1.2
|
||||
collect-v8-coverage: 1.0.2
|
||||
exit: 0.1.2
|
||||
|
@ -668,7 +668,7 @@ packages:
|
|||
'@jest/schemas': 29.6.3
|
||||
'@types/istanbul-lib-coverage': 2.0.6
|
||||
'@types/istanbul-reports': 3.0.4
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
'@types/yargs': 17.0.32
|
||||
chalk: 4.1.2
|
||||
dev: true
|
||||
|
@ -777,7 +777,7 @@ packages:
|
|||
/@types/graceful-fs@4.1.9:
|
||||
resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==}
|
||||
dependencies:
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
dev: true
|
||||
|
||||
/@types/istanbul-lib-coverage@2.0.6:
|
||||
|
@ -807,8 +807,8 @@ packages:
|
|||
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
|
||||
dev: true
|
||||
|
||||
/@types/node@20.11.27:
|
||||
resolution: {integrity: sha512-qyUZfMnCg1KEz57r7pzFtSGt49f6RPkPBis3Vo4PbS7roQEDn22hiHzl/Lo1q4i4hDEgBJmBF/NTNg2XR0HbFg==}
|
||||
/@types/node@20.12.4:
|
||||
resolution: {integrity: sha512-E+Fa9z3wSQpzgYQdYmme5X3OTuejnnTx88A6p6vkkJosR3KBz+HpE3kqNm98VE6cfLFcISx7zW7MsJkH6KwbTw==}
|
||||
dependencies:
|
||||
undici-types: 5.26.5
|
||||
dev: true
|
||||
|
@ -831,9 +831,9 @@ packages:
|
|||
'@types/yargs-parser': 21.0.3
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/eslint-plugin@7.2.0(@typescript-eslint/parser@7.2.0)(eslint@8.57.0)(typescript@5.4.2):
|
||||
resolution: {integrity: sha512-mdekAHOqS9UjlmyF/LSs6AIEvfceV749GFxoBAjwAv0nkevfKHWQFDMcBZWUiIC5ft6ePWivXoS36aKQ0Cy3sw==}
|
||||
engines: {node: ^16.0.0 || >=18.0.0}
|
||||
/@typescript-eslint/eslint-plugin@7.5.0(@typescript-eslint/parser@7.5.0)(eslint@8.57.0)(typescript@5.4.4):
|
||||
resolution: {integrity: sha512-HpqNTH8Du34nLxbKgVMGljZMG0rJd2O9ecvr2QLYp+7512ty1j42KnsFwspPXg1Vh8an9YImf6CokUBltisZFQ==}
|
||||
engines: {node: ^18.18.0 || >=20.0.0}
|
||||
peerDependencies:
|
||||
'@typescript-eslint/parser': ^7.0.0
|
||||
eslint: ^8.56.0
|
||||
|
@ -843,26 +843,26 @@ packages:
|
|||
optional: true
|
||||
dependencies:
|
||||
'@eslint-community/regexpp': 4.10.0
|
||||
'@typescript-eslint/parser': 7.2.0(eslint@8.57.0)(typescript@5.4.2)
|
||||
'@typescript-eslint/scope-manager': 7.2.0
|
||||
'@typescript-eslint/type-utils': 7.2.0(eslint@8.57.0)(typescript@5.4.2)
|
||||
'@typescript-eslint/utils': 7.2.0(eslint@8.57.0)(typescript@5.4.2)
|
||||
'@typescript-eslint/visitor-keys': 7.2.0
|
||||
'@typescript-eslint/parser': 7.5.0(eslint@8.57.0)(typescript@5.4.4)
|
||||
'@typescript-eslint/scope-manager': 7.5.0
|
||||
'@typescript-eslint/type-utils': 7.5.0(eslint@8.57.0)(typescript@5.4.4)
|
||||
'@typescript-eslint/utils': 7.5.0(eslint@8.57.0)(typescript@5.4.4)
|
||||
'@typescript-eslint/visitor-keys': 7.5.0
|
||||
debug: 4.3.4
|
||||
eslint: 8.57.0
|
||||
graphemer: 1.4.0
|
||||
ignore: 5.3.1
|
||||
natural-compare: 1.4.0
|
||||
semver: 7.6.0
|
||||
ts-api-utils: 1.3.0(typescript@5.4.2)
|
||||
typescript: 5.4.2
|
||||
ts-api-utils: 1.3.0(typescript@5.4.4)
|
||||
typescript: 5.4.4
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.4.2):
|
||||
resolution: {integrity: sha512-5FKsVcHTk6TafQKQbuIVkXq58Fnbkd2wDL4LB7AURN7RUOu1utVP+G8+6u3ZhEroW3DF6hyo3ZEXxgKgp4KeCg==}
|
||||
engines: {node: ^16.0.0 || >=18.0.0}
|
||||
/@typescript-eslint/parser@7.5.0(eslint@8.57.0)(typescript@5.4.4):
|
||||
resolution: {integrity: sha512-cj+XGhNujfD2/wzR1tabNsidnYRaFfEkcULdcIyVBYcXjBvBKOes+mpMBP7hMpOyk+gBcfXsrg4NBGAStQyxjQ==}
|
||||
engines: {node: ^18.18.0 || >=20.0.0}
|
||||
peerDependencies:
|
||||
eslint: ^8.56.0
|
||||
typescript: '*'
|
||||
|
@ -870,28 +870,28 @@ packages:
|
|||
typescript:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@typescript-eslint/scope-manager': 7.2.0
|
||||
'@typescript-eslint/types': 7.2.0
|
||||
'@typescript-eslint/typescript-estree': 7.2.0(typescript@5.4.2)
|
||||
'@typescript-eslint/visitor-keys': 7.2.0
|
||||
'@typescript-eslint/scope-manager': 7.5.0
|
||||
'@typescript-eslint/types': 7.5.0
|
||||
'@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.4)
|
||||
'@typescript-eslint/visitor-keys': 7.5.0
|
||||
debug: 4.3.4
|
||||
eslint: 8.57.0
|
||||
typescript: 5.4.2
|
||||
typescript: 5.4.4
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/scope-manager@7.2.0:
|
||||
resolution: {integrity: sha512-Qh976RbQM/fYtjx9hs4XkayYujB/aPwglw2choHmf3zBjB4qOywWSdt9+KLRdHubGcoSwBnXUH2sR3hkyaERRg==}
|
||||
engines: {node: ^16.0.0 || >=18.0.0}
|
||||
/@typescript-eslint/scope-manager@7.5.0:
|
||||
resolution: {integrity: sha512-Z1r7uJY0MDeUlql9XJ6kRVgk/sP11sr3HKXn268HZyqL7i4cEfrdFuSSY/0tUqT37l5zT0tJOsuDP16kio85iA==}
|
||||
engines: {node: ^18.18.0 || >=20.0.0}
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 7.2.0
|
||||
'@typescript-eslint/visitor-keys': 7.2.0
|
||||
'@typescript-eslint/types': 7.5.0
|
||||
'@typescript-eslint/visitor-keys': 7.5.0
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/type-utils@7.2.0(eslint@8.57.0)(typescript@5.4.2):
|
||||
resolution: {integrity: sha512-xHi51adBHo9O9330J8GQYQwrKBqbIPJGZZVQTHHmy200hvkLZFWJIFtAG/7IYTWUyun6DE6w5InDReePJYJlJA==}
|
||||
engines: {node: ^16.0.0 || >=18.0.0}
|
||||
/@typescript-eslint/type-utils@7.5.0(eslint@8.57.0)(typescript@5.4.4):
|
||||
resolution: {integrity: sha512-A021Rj33+G8mx2Dqh0nMO9GyjjIBK3MqgVgZ2qlKf6CJy51wY/lkkFqq3TqqnH34XyAHUkq27IjlUkWlQRpLHw==}
|
||||
engines: {node: ^18.18.0 || >=20.0.0}
|
||||
peerDependencies:
|
||||
eslint: ^8.56.0
|
||||
typescript: '*'
|
||||
|
@ -899,55 +899,55 @@ packages:
|
|||
typescript:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@typescript-eslint/typescript-estree': 7.2.0(typescript@5.4.2)
|
||||
'@typescript-eslint/utils': 7.2.0(eslint@8.57.0)(typescript@5.4.2)
|
||||
'@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.4)
|
||||
'@typescript-eslint/utils': 7.5.0(eslint@8.57.0)(typescript@5.4.4)
|
||||
debug: 4.3.4
|
||||
eslint: 8.57.0
|
||||
ts-api-utils: 1.3.0(typescript@5.4.2)
|
||||
typescript: 5.4.2
|
||||
ts-api-utils: 1.3.0(typescript@5.4.4)
|
||||
typescript: 5.4.4
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/types@7.2.0:
|
||||
resolution: {integrity: sha512-XFtUHPI/abFhm4cbCDc5Ykc8npOKBSJePY3a3s+lwumt7XWJuzP5cZcfZ610MIPHjQjNsOLlYK8ASPaNG8UiyA==}
|
||||
engines: {node: ^16.0.0 || >=18.0.0}
|
||||
/@typescript-eslint/types@7.5.0:
|
||||
resolution: {integrity: sha512-tv5B4IHeAdhR7uS4+bf8Ov3k793VEVHd45viRRkehIUZxm0WF82VPiLgHzA/Xl4TGPg1ZD49vfxBKFPecD5/mg==}
|
||||
engines: {node: ^18.18.0 || >=20.0.0}
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/typescript-estree@7.2.0(typescript@5.4.2):
|
||||
resolution: {integrity: sha512-cyxS5WQQCoBwSakpMrvMXuMDEbhOo9bNHHrNcEWis6XHx6KF518tkF1wBvKIn/tpq5ZpUYK7Bdklu8qY0MsFIA==}
|
||||
engines: {node: ^16.0.0 || >=18.0.0}
|
||||
/@typescript-eslint/typescript-estree@7.5.0(typescript@5.4.4):
|
||||
resolution: {integrity: sha512-YklQQfe0Rv2PZEueLTUffiQGKQneiIEKKnfIqPIOxgM9lKSZFCjT5Ad4VqRKj/U4+kQE3fa8YQpskViL7WjdPQ==}
|
||||
engines: {node: ^18.18.0 || >=20.0.0}
|
||||
peerDependencies:
|
||||
typescript: '*'
|
||||
peerDependenciesMeta:
|
||||
typescript:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 7.2.0
|
||||
'@typescript-eslint/visitor-keys': 7.2.0
|
||||
'@typescript-eslint/types': 7.5.0
|
||||
'@typescript-eslint/visitor-keys': 7.5.0
|
||||
debug: 4.3.4
|
||||
globby: 11.1.0
|
||||
is-glob: 4.0.3
|
||||
minimatch: 9.0.3
|
||||
semver: 7.6.0
|
||||
ts-api-utils: 1.3.0(typescript@5.4.2)
|
||||
typescript: 5.4.2
|
||||
ts-api-utils: 1.3.0(typescript@5.4.4)
|
||||
typescript: 5.4.4
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/utils@7.2.0(eslint@8.57.0)(typescript@5.4.2):
|
||||
resolution: {integrity: sha512-YfHpnMAGb1Eekpm3XRK8hcMwGLGsnT6L+7b2XyRv6ouDuJU1tZir1GS2i0+VXRatMwSI1/UfcyPe53ADkU+IuA==}
|
||||
engines: {node: ^16.0.0 || >=18.0.0}
|
||||
/@typescript-eslint/utils@7.5.0(eslint@8.57.0)(typescript@5.4.4):
|
||||
resolution: {integrity: sha512-3vZl9u0R+/FLQcpy2EHyRGNqAS/ofJ3Ji8aebilfJe+fobK8+LbIFmrHciLVDxjDoONmufDcnVSF38KwMEOjzw==}
|
||||
engines: {node: ^18.18.0 || >=20.0.0}
|
||||
peerDependencies:
|
||||
eslint: ^8.56.0
|
||||
dependencies:
|
||||
'@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0)
|
||||
'@types/json-schema': 7.0.15
|
||||
'@types/semver': 7.5.8
|
||||
'@typescript-eslint/scope-manager': 7.2.0
|
||||
'@typescript-eslint/types': 7.2.0
|
||||
'@typescript-eslint/typescript-estree': 7.2.0(typescript@5.4.2)
|
||||
'@typescript-eslint/scope-manager': 7.5.0
|
||||
'@typescript-eslint/types': 7.5.0
|
||||
'@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.4)
|
||||
eslint: 8.57.0
|
||||
semver: 7.6.0
|
||||
transitivePeerDependencies:
|
||||
|
@ -955,11 +955,11 @@ packages:
|
|||
- typescript
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/visitor-keys@7.2.0:
|
||||
resolution: {integrity: sha512-c6EIQRHhcpl6+tO8EMR+kjkkV+ugUNXOmeASA1rlzkd8EPIriavpWoiEz1HR/VLhbVIdhqnV6E7JZm00cBDx2A==}
|
||||
engines: {node: ^16.0.0 || >=18.0.0}
|
||||
/@typescript-eslint/visitor-keys@7.5.0:
|
||||
resolution: {integrity: sha512-mcuHM/QircmA6O7fy6nn2w/3ditQkj+SgtOc8DW3uQ10Yfj42amm2i+6F2K4YAOPNNTmE6iM1ynM6lrSwdendA==}
|
||||
engines: {node: ^18.18.0 || >=20.0.0}
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 7.2.0
|
||||
'@typescript-eslint/types': 7.5.0
|
||||
eslint-visitor-keys: 3.4.3
|
||||
dev: true
|
||||
|
||||
|
@ -1265,7 +1265,7 @@ packages:
|
|||
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
|
||||
dev: true
|
||||
|
||||
/create-jest@29.7.0(@types/node@20.11.27):
|
||||
/create-jest@29.7.0(@types/node@20.12.4):
|
||||
resolution: {integrity: sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
hasBin: true
|
||||
|
@ -1274,7 +1274,7 @@ packages:
|
|||
chalk: 4.1.2
|
||||
exit: 0.1.2
|
||||
graceful-fs: 4.2.11
|
||||
jest-config: 29.7.0(@types/node@20.11.27)
|
||||
jest-config: 29.7.0(@types/node@20.12.4)
|
||||
jest-util: 29.7.0
|
||||
prompts: 2.4.2
|
||||
transitivePeerDependencies:
|
||||
|
@ -1906,7 +1906,7 @@ packages:
|
|||
'@jest/expect': 29.7.0
|
||||
'@jest/test-result': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
chalk: 4.1.2
|
||||
co: 4.6.0
|
||||
dedent: 1.5.1
|
||||
|
@ -1927,7 +1927,7 @@ packages:
|
|||
- supports-color
|
||||
dev: true
|
||||
|
||||
/jest-cli@29.7.0(@types/node@20.11.27):
|
||||
/jest-cli@29.7.0(@types/node@20.12.4):
|
||||
resolution: {integrity: sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
hasBin: true
|
||||
|
@ -1941,10 +1941,10 @@ packages:
|
|||
'@jest/test-result': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
chalk: 4.1.2
|
||||
create-jest: 29.7.0(@types/node@20.11.27)
|
||||
create-jest: 29.7.0(@types/node@20.12.4)
|
||||
exit: 0.1.2
|
||||
import-local: 3.1.0
|
||||
jest-config: 29.7.0(@types/node@20.11.27)
|
||||
jest-config: 29.7.0(@types/node@20.12.4)
|
||||
jest-util: 29.7.0
|
||||
jest-validate: 29.7.0
|
||||
yargs: 17.7.2
|
||||
|
@ -1955,7 +1955,7 @@ packages:
|
|||
- ts-node
|
||||
dev: true
|
||||
|
||||
/jest-config@29.7.0(@types/node@20.11.27):
|
||||
/jest-config@29.7.0(@types/node@20.12.4):
|
||||
resolution: {integrity: sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
peerDependencies:
|
||||
|
@ -1970,7 +1970,7 @@ packages:
|
|||
'@babel/core': 7.23.9
|
||||
'@jest/test-sequencer': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
babel-jest: 29.7.0(@babel/core@7.23.9)
|
||||
chalk: 4.1.2
|
||||
ci-info: 3.9.0
|
||||
|
@ -2030,7 +2030,7 @@ packages:
|
|||
'@jest/environment': 29.7.0
|
||||
'@jest/fake-timers': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
jest-mock: 29.7.0
|
||||
jest-util: 29.7.0
|
||||
dev: true
|
||||
|
@ -2046,7 +2046,7 @@ packages:
|
|||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@types/graceful-fs': 4.1.9
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
anymatch: 3.1.3
|
||||
fb-watchman: 2.0.2
|
||||
graceful-fs: 4.2.11
|
||||
|
@ -2097,7 +2097,7 @@ packages:
|
|||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
jest-util: 29.7.0
|
||||
dev: true
|
||||
|
||||
|
@ -2152,7 +2152,7 @@ packages:
|
|||
'@jest/test-result': 29.7.0
|
||||
'@jest/transform': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
chalk: 4.1.2
|
||||
emittery: 0.13.1
|
||||
graceful-fs: 4.2.11
|
||||
|
@ -2183,7 +2183,7 @@ packages:
|
|||
'@jest/test-result': 29.7.0
|
||||
'@jest/transform': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
chalk: 4.1.2
|
||||
cjs-module-lexer: 1.2.3
|
||||
collect-v8-coverage: 1.0.2
|
||||
|
@ -2235,7 +2235,7 @@ packages:
|
|||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
chalk: 4.1.2
|
||||
ci-info: 3.9.0
|
||||
graceful-fs: 4.2.11
|
||||
|
@ -2260,7 +2260,7 @@ packages:
|
|||
dependencies:
|
||||
'@jest/test-result': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
ansi-escapes: 4.3.2
|
||||
chalk: 4.1.2
|
||||
emittery: 0.13.1
|
||||
|
@ -2272,13 +2272,13 @@ packages:
|
|||
resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
dependencies:
|
||||
'@types/node': 20.11.27
|
||||
'@types/node': 20.12.4
|
||||
jest-util: 29.7.0
|
||||
merge-stream: 2.0.0
|
||||
supports-color: 8.1.1
|
||||
dev: true
|
||||
|
||||
/jest@29.7.0(@types/node@20.11.27):
|
||||
/jest@29.7.0(@types/node@20.12.4):
|
||||
resolution: {integrity: sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
hasBin: true
|
||||
|
@ -2291,7 +2291,7 @@ packages:
|
|||
'@jest/core': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
import-local: 3.1.0
|
||||
jest-cli: 29.7.0(@types/node@20.11.27)
|
||||
jest-cli: 29.7.0(@types/node@20.12.4)
|
||||
transitivePeerDependencies:
|
||||
- '@types/node'
|
||||
- babel-plugin-macros
|
||||
|
@ -2357,8 +2357,8 @@ packages:
|
|||
engines: {node: '>=6'}
|
||||
dev: true
|
||||
|
||||
/lemmy-js-client@0.19.4-alpha.13:
|
||||
resolution: {integrity: sha512-ru1dCqPSfOJdsGq7am5J7P7f+/hpyHGhNbCEV/JAZP2U1lGHul32gLpBkilDnStDNdeq52scjKx+3WskRJFGFA==}
|
||||
/lemmy-js-client@0.19.4-alpha.16:
|
||||
resolution: {integrity: sha512-9BKCpZeH5+dDkSuYLVPvJnRGOSa3/jBUqYlQH3r1p8TyCCBrxstIC2I+h9dZZtOg4RmK7ShcuZdk9LSMe1ZMyw==}
|
||||
dev: true
|
||||
|
||||
/leven@3.1.0:
|
||||
|
@ -2890,16 +2890,16 @@ packages:
|
|||
is-number: 7.0.0
|
||||
dev: true
|
||||
|
||||
/ts-api-utils@1.3.0(typescript@5.4.2):
|
||||
/ts-api-utils@1.3.0(typescript@5.4.4):
|
||||
resolution: {integrity: sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==}
|
||||
engines: {node: '>=16'}
|
||||
peerDependencies:
|
||||
typescript: '>=4.2.0'
|
||||
dependencies:
|
||||
typescript: 5.4.2
|
||||
typescript: 5.4.4
|
||||
dev: true
|
||||
|
||||
/ts-jest@29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.4.2):
|
||||
/ts-jest@29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.4.4):
|
||||
resolution: {integrity: sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==}
|
||||
engines: {node: ^16.10.0 || ^18.0.0 || >=20.0.0}
|
||||
hasBin: true
|
||||
|
@ -2923,13 +2923,13 @@ packages:
|
|||
'@babel/core': 7.23.9
|
||||
bs-logger: 0.2.6
|
||||
fast-json-stable-stringify: 2.1.0
|
||||
jest: 29.7.0(@types/node@20.11.27)
|
||||
jest: 29.7.0(@types/node@20.12.4)
|
||||
jest-util: 29.7.0
|
||||
json5: 2.2.3
|
||||
lodash.memoize: 4.1.2
|
||||
make-error: 1.3.6
|
||||
semver: 7.5.4
|
||||
typescript: 5.4.2
|
||||
typescript: 5.4.4
|
||||
yargs-parser: 21.1.1
|
||||
dev: true
|
||||
|
||||
|
@ -2959,8 +2959,8 @@ packages:
|
|||
engines: {node: '>=10'}
|
||||
dev: true
|
||||
|
||||
/typescript@5.4.2:
|
||||
resolution: {integrity: sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==}
|
||||
/typescript@5.4.4:
|
||||
resolution: {integrity: sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==}
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
|
|
@ -53,9 +53,7 @@ beforeAll(async () => {
|
|||
}
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
unfollows();
|
||||
});
|
||||
afterAll(unfollows);
|
||||
|
||||
function assertCommentFederation(
|
||||
commentOne?: CommentView,
|
||||
|
|
|
@ -31,10 +31,12 @@ import {
|
|||
searchPostLocal,
|
||||
longDelay,
|
||||
editCommunity,
|
||||
unfollows,
|
||||
} from "./shared";
|
||||
import { EditCommunity, EditSite } from "lemmy-js-client";
|
||||
|
||||
beforeAll(setupLogins);
|
||||
afterAll(unfollows);
|
||||
|
||||
function assertCommunityFederation(
|
||||
communityOne?: CommunityView,
|
||||
|
|
|
@ -15,9 +15,7 @@ import {
|
|||
|
||||
beforeAll(setupLogins);
|
||||
|
||||
afterAll(() => {
|
||||
unfollows();
|
||||
});
|
||||
afterAll(unfollows);
|
||||
|
||||
test("Follow local community", async () => {
|
||||
let user = await registerUser(beta, betaUrl);
|
||||
|
|
|
@ -15,7 +15,6 @@ import {
|
|||
createCommunity,
|
||||
createPost,
|
||||
deleteAllImages,
|
||||
delta,
|
||||
epsilon,
|
||||
followCommunity,
|
||||
gamma,
|
||||
|
@ -28,14 +27,15 @@ import {
|
|||
setupLogins,
|
||||
waitForPost,
|
||||
unfollows,
|
||||
editPostThumbnail,
|
||||
getPost,
|
||||
waitUntil,
|
||||
} from "./shared";
|
||||
const downloadFileSync = require("download-file-sync");
|
||||
|
||||
beforeAll(setupLogins);
|
||||
|
||||
afterAll(() => {
|
||||
unfollows();
|
||||
});
|
||||
afterAll(unfollows);
|
||||
|
||||
test("Upload image and delete it", async () => {
|
||||
// Before running this test, you need to delete all previous images in the DB
|
||||
|
@ -252,3 +252,74 @@ test("No image proxying if setting is disabled", async () => {
|
|||
// Make sure the alt text got federated
|
||||
expect(post.post_view.post.alt_text).toBe(betaPost.post.alt_text);
|
||||
});
|
||||
|
||||
test("Make regular post, and give it a custom thumbnail", async () => {
|
||||
const uploadForm1: UploadImage = {
|
||||
image: Buffer.from("testRegular1"),
|
||||
};
|
||||
const upload1 = await alphaImage.uploadImage(uploadForm1);
|
||||
|
||||
const community = await createCommunity(alphaImage);
|
||||
|
||||
// Use wikipedia since it has an opengraph image
|
||||
const wikipediaUrl = "https://wikipedia.org/";
|
||||
|
||||
let post = await createPost(
|
||||
alphaImage,
|
||||
community.community_view.community.id,
|
||||
wikipediaUrl,
|
||||
);
|
||||
|
||||
// Wait for the metadata to get fetched, since this is backgrounded now
|
||||
post = await waitUntil(
|
||||
() => getPost(alphaImage, post.post_view.post.id),
|
||||
p => p.post_view.post.thumbnail_url != undefined,
|
||||
);
|
||||
expect(post.post_view.post.url).toBe(wikipediaUrl);
|
||||
expect(post.post_view.post.thumbnail_url).toBeDefined();
|
||||
|
||||
// Edit the thumbnail
|
||||
await editPostThumbnail(alphaImage, post.post_view.post, upload1.url!);
|
||||
|
||||
post = await waitUntil(
|
||||
() => getPost(alphaImage, post.post_view.post.id),
|
||||
p => p.post_view.post.thumbnail_url == upload1.url,
|
||||
);
|
||||
|
||||
// Make sure the thumbnail got edited.
|
||||
expect(post.post_view.post.thumbnail_url).toBe(upload1.url);
|
||||
});
|
||||
|
||||
test("Create an image post, and make sure a custom thumbnail doesnt overwrite it", async () => {
|
||||
const uploadForm1: UploadImage = {
|
||||
image: Buffer.from("test1"),
|
||||
};
|
||||
const upload1 = await alphaImage.uploadImage(uploadForm1);
|
||||
|
||||
const uploadForm2: UploadImage = {
|
||||
image: Buffer.from("test2"),
|
||||
};
|
||||
const upload2 = await alphaImage.uploadImage(uploadForm2);
|
||||
|
||||
const community = await createCommunity(alphaImage);
|
||||
|
||||
let post = await createPost(
|
||||
alphaImage,
|
||||
community.community_view.community.id,
|
||||
upload1.url,
|
||||
);
|
||||
expect(post.post_view.post.url).toBe(upload1.url);
|
||||
|
||||
// Edit the post
|
||||
await editPostThumbnail(alphaImage, post.post_view.post, upload2.url!);
|
||||
|
||||
// Wait for the metadata to get fetched
|
||||
post = await waitUntil(
|
||||
() => getPost(alphaImage, post.post_view.post.id),
|
||||
p => p.post_view.post.thumbnail_url == upload1.url,
|
||||
);
|
||||
|
||||
// Make sure the new custom thumbnail is ignored, and doesn't overwrite the image post
|
||||
expect(post.post_view.post.url).toBe(upload1.url);
|
||||
expect(post.post_view.post.thumbnail_url).toBe(upload1.url);
|
||||
});
|
||||
|
|
|
@ -51,9 +51,7 @@ beforeAll(async () => {
|
|||
await unfollows();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
unfollows();
|
||||
});
|
||||
afterAll(unfollows);
|
||||
|
||||
async function assertPostFederation(postOne: PostView, postTwo: PostView) {
|
||||
// Link metadata is generated in background task and may not be ready yet at this time,
|
||||
|
@ -745,3 +743,23 @@ test("Block post that contains banned URL", async () => {
|
|||
editSiteForm.blocked_urls = [];
|
||||
await epsilon.editSite(editSiteForm);
|
||||
});
|
||||
|
||||
test("Fetch post with redirect", async () => {
|
||||
let alphaPost = await createPost(alpha, betaCommunity!.community.id);
|
||||
expect(alphaPost.post_view.post).toBeDefined();
|
||||
|
||||
// beta fetches from alpha as usual
|
||||
let betaPost = await resolvePost(beta, alphaPost.post_view.post);
|
||||
expect(betaPost.post).toBeDefined();
|
||||
|
||||
// gamma fetches from beta, and gets redirected to alpha
|
||||
let gammaPost = await resolvePost(gamma, betaPost.post!.post);
|
||||
expect(gammaPost.post).toBeDefined();
|
||||
|
||||
// fetch remote object from local url, which redirects to the original url
|
||||
let form: ResolveObject = {
|
||||
q: `http://lemmy-gamma:8561/post/${gammaPost.post!.post.id}`,
|
||||
};
|
||||
let gammaPost2 = await gamma.resolveObject(form);
|
||||
expect(gammaPost2.post).toBeDefined();
|
||||
});
|
||||
|
|
|
@ -21,9 +21,7 @@ beforeAll(async () => {
|
|||
recipient_id = 3;
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
unfollows();
|
||||
});
|
||||
afterAll(unfollows);
|
||||
|
||||
test("Create a private message", async () => {
|
||||
let pmRes = await createPrivateMessage(alpha, recipient_id);
|
||||
|
|
|
@ -226,6 +226,18 @@ export async function editPost(
|
|||
return api.editPost(form);
|
||||
}
|
||||
|
||||
export async function editPostThumbnail(
|
||||
api: LemmyHttp,
|
||||
post: Post,
|
||||
customThumbnail: string,
|
||||
): Promise<PostResponse> {
|
||||
let form: EditPost = {
|
||||
post_id: post.id,
|
||||
custom_thumbnail: customThumbnail,
|
||||
};
|
||||
return api.editPost(form);
|
||||
}
|
||||
|
||||
export async function deletePost(
|
||||
api: LemmyHttp,
|
||||
deleted: boolean,
|
||||
|
|
|
@ -20,11 +20,13 @@ import {
|
|||
getComments,
|
||||
fetchFunction,
|
||||
alphaImage,
|
||||
unfollows,
|
||||
} from "./shared";
|
||||
import { LemmyHttp, SaveUserSettings, UploadImage } from "lemmy-js-client";
|
||||
import { GetPosts } from "lemmy-js-client/dist/types/GetPosts";
|
||||
|
||||
beforeAll(setupLogins);
|
||||
afterAll(unfollows);
|
||||
|
||||
let apShortname: string;
|
||||
|
||||
|
|
|
@ -9,14 +9,14 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views::structs::{CommentView, LocalUserView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn distinguish_comment(
|
||||
data: Json<DistinguishComment>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommentResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommentResponse>> {
|
||||
let orig_comment = CommentView::read(&mut context.pool(), data.comment_id, None).await?;
|
||||
|
||||
check_community_user_action(
|
||||
|
|
|
@ -17,7 +17,7 @@ use lemmy_db_schema::{
|
|||
traits::Likeable,
|
||||
};
|
||||
use lemmy_db_views::structs::{CommentView, LocalUserView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
use std::ops::Deref;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
|
@ -25,7 +25,7 @@ pub async fn like_comment(
|
|||
data: Json<CreateCommentLike>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommentResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommentResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
let mut recipient_ids = Vec::<LocalUserId>::new();
|
||||
|
|
|
@ -5,7 +5,7 @@ use lemmy_api_common::{
|
|||
utils::is_mod_or_admin,
|
||||
};
|
||||
use lemmy_db_views::structs::{CommentView, LocalUserView, VoteView};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
/// Lists likes for a comment
|
||||
#[tracing::instrument(skip(context))]
|
||||
|
@ -13,7 +13,7 @@ pub async fn list_comment_likes(
|
|||
data: Query<ListCommentLikes>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<ListCommentLikesResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<ListCommentLikesResponse>> {
|
||||
let comment_view = CommentView::read(
|
||||
&mut context.pool(),
|
||||
data.comment_id,
|
||||
|
|
|
@ -8,14 +8,14 @@ use lemmy_db_schema::{
|
|||
traits::Saveable,
|
||||
};
|
||||
use lemmy_db_views::structs::{CommentView, LocalUserView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn save_comment(
|
||||
data: Json<SaveComment>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommentResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommentResponse>> {
|
||||
let comment_saved_form = CommentSavedForm {
|
||||
comment_id: data.comment_id,
|
||||
person_id: local_user_view.person.id,
|
||||
|
|
|
@ -19,7 +19,7 @@ use lemmy_db_schema::{
|
|||
traits::Reportable,
|
||||
};
|
||||
use lemmy_db_views::structs::{CommentReportView, CommentView, LocalUserView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
/// Creates a comment report and notifies the moderators of the community
|
||||
#[tracing::instrument(skip(context))]
|
||||
|
@ -27,7 +27,7 @@ pub async fn create_comment_report(
|
|||
data: Json<CreateCommentReport>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommentReportResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommentReportResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
let reason = data.reason.trim().to_string();
|
||||
|
|
|
@ -5,7 +5,7 @@ use lemmy_api_common::{
|
|||
utils::check_community_mod_of_any_or_admin_action,
|
||||
};
|
||||
use lemmy_db_views::{comment_report_view::CommentReportQuery, structs::LocalUserView};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
/// Lists comment reports for a community if an id is supplied
|
||||
/// or returns all comment reports for communities a user moderates
|
||||
|
@ -14,7 +14,7 @@ pub async fn list_comment_reports(
|
|||
data: Query<ListCommentReports>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<ListCommentReportsResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<ListCommentReportsResponse>> {
|
||||
let community_id = data.community_id;
|
||||
let comment_id = data.comment_id;
|
||||
let unresolved_only = data.unresolved_only.unwrap_or_default();
|
||||
|
|
|
@ -6,7 +6,7 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_schema::{source::comment_report::CommentReport, traits::Reportable};
|
||||
use lemmy_db_views::structs::{CommentReportView, LocalUserView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
/// Resolves or unresolves a comment report and notifies the moderators of the community
|
||||
#[tracing::instrument(skip(context))]
|
||||
|
@ -14,7 +14,7 @@ pub async fn resolve_comment_report(
|
|||
data: Json<ResolveCommentReport>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommentReportResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommentReportResponse>> {
|
||||
let report_id = data.report_id;
|
||||
let person_id = local_user_view.person.id;
|
||||
let report = CommentReportView::read(&mut context.pool(), report_id, person_id).await?;
|
||||
|
|
|
@ -15,14 +15,14 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::structs::CommunityModeratorView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn add_mod_to_community(
|
||||
data: Json<AddModToCommunity>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<AddModToCommunityResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<AddModToCommunityResponse>> {
|
||||
let community_id = data.community_id;
|
||||
|
||||
// Verify that only mods or admins can add mod
|
||||
|
|
|
@ -21,7 +21,7 @@ use lemmy_db_schema::{
|
|||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::structs::PersonView;
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
||||
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
|
||||
utils::validation::is_valid_body_field,
|
||||
};
|
||||
|
||||
|
@ -30,7 +30,7 @@ pub async fn ban_from_community(
|
|||
data: Json<BanFromCommunity>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<BanFromCommunityResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<BanFromCommunityResponse>> {
|
||||
let banned_person_id = data.person_id;
|
||||
let remove_data = data.remove_data.unwrap_or(false);
|
||||
let expires = check_expire_time(data.expires)?;
|
||||
|
|
|
@ -14,14 +14,14 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::structs::CommunityView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn block_community(
|
||||
data: Json<BlockCommunity>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<BlockCommunityResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<BlockCommunityResponse>> {
|
||||
let community_id = data.community_id;
|
||||
let person_id = local_user_view.person.id;
|
||||
let community_block_form = CommunityBlockForm {
|
||||
|
|
|
@ -15,14 +15,14 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::structs::CommunityView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn follow_community(
|
||||
data: Json<FollowCommunity>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommunityResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommunityResponse>> {
|
||||
let community = Community::read(&mut context.pool(), data.community_id).await?;
|
||||
let mut community_follower_form = CommunityFollowerForm {
|
||||
community_id: community.id,
|
||||
|
|
|
@ -15,14 +15,14 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn hide_community(
|
||||
data: Json<HideCommunity>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<SuccessResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<SuccessResponse>> {
|
||||
// Verify its a admin (only admin can hide or unhide it)
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use lemmy_db_schema::{
|
|||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
||||
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
|
||||
location_info,
|
||||
};
|
||||
|
||||
|
@ -26,7 +26,7 @@ pub async fn transfer_community(
|
|||
data: Json<TransferCommunity>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<GetCommunityResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<GetCommunityResponse>> {
|
||||
let community_id = data.community_id;
|
||||
let mut community_mods =
|
||||
CommunityModeratorView::for_community(&mut context.pool(), community_id).await?;
|
||||
|
|
|
@ -26,7 +26,7 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorExt, LemmyErrorExt2, LemmyErrorType, LemmyResult},
|
||||
error::{LemmyErrorExt, LemmyErrorExt2, LemmyErrorType, LemmyResult},
|
||||
utils::slurs::check_slurs,
|
||||
};
|
||||
use std::io::Cursor;
|
||||
|
@ -44,7 +44,7 @@ pub mod site;
|
|||
pub mod sitemap;
|
||||
|
||||
/// Converts the captcha to a base64 encoded wav audio file
|
||||
pub(crate) fn captcha_as_wav_base64(captcha: &Captcha) -> Result<String, LemmyError> {
|
||||
pub(crate) fn captcha_as_wav_base64(captcha: &Captcha) -> LemmyResult<String> {
|
||||
let letters = captcha.as_wav();
|
||||
|
||||
// Decode each wav file, concatenate the samples
|
||||
|
@ -78,7 +78,7 @@ pub(crate) fn captcha_as_wav_base64(captcha: &Captcha) -> Result<String, LemmyEr
|
|||
}
|
||||
|
||||
/// Check size of report
|
||||
pub(crate) fn check_report_reason(reason: &str, local_site: &LocalSite) -> Result<(), LemmyError> {
|
||||
pub(crate) fn check_report_reason(reason: &str, local_site: &LocalSite) -> LemmyResult<()> {
|
||||
let slur_regex = &local_site_to_slur_regex(local_site);
|
||||
|
||||
check_slurs(reason, slur_regex)?;
|
||||
|
@ -91,7 +91,7 @@ pub(crate) fn check_report_reason(reason: &str, local_site: &LocalSite) -> Resul
|
|||
}
|
||||
}
|
||||
|
||||
pub fn read_auth_token(req: &HttpRequest) -> Result<Option<String>, LemmyError> {
|
||||
pub fn read_auth_token(req: &HttpRequest) -> LemmyResult<Option<String>> {
|
||||
// Try reading jwt from auth header
|
||||
if let Ok(header) = Authorization::<Bearer>::parse(req) {
|
||||
Ok(Some(header.as_ref().token().to_string()))
|
||||
|
@ -135,7 +135,7 @@ pub(crate) fn generate_totp_2fa_secret() -> String {
|
|||
Secret::generate_secret().to_string()
|
||||
}
|
||||
|
||||
fn build_totp_2fa(hostname: &str, username: &str, secret: &str) -> Result<TOTP, LemmyError> {
|
||||
fn build_totp_2fa(hostname: &str, username: &str, secret: &str) -> LemmyResult<TOTP> {
|
||||
let sec = Secret::Raw(secret.as_bytes().to_vec());
|
||||
let sec_bytes = sec
|
||||
.to_bytes()
|
||||
|
@ -248,7 +248,7 @@ pub(crate) async fn ban_nonlocal_user_from_local_communities(
|
|||
pub async fn local_user_view_from_jwt(
|
||||
jwt: &str,
|
||||
context: &LemmyContext,
|
||||
) -> Result<LocalUserView, LemmyError> {
|
||||
) -> LemmyResult<LocalUserView> {
|
||||
let local_user_id = Claims::validate(jwt, context)
|
||||
.await
|
||||
.with_lemmy_type(LemmyErrorType::NotLoggedIn)?;
|
||||
|
|
|
@ -13,14 +13,14 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::structs::PersonView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn add_admin(
|
||||
data: Json<AddAdmin>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<AddAdminResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<AddAdminResponse>> {
|
||||
// Make sure user is an admin
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ use lemmy_db_schema::{
|
|||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::structs::PersonView;
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
||||
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
|
||||
utils::validation::is_valid_body_field,
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,7 @@ pub async fn ban_from_site(
|
|||
data: Json<BanPerson>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<BanPersonResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<BanPersonResponse>> {
|
||||
// Make sure user is an admin
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
|
|
|
@ -9,14 +9,14 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::structs::PersonView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn block_person(
|
||||
data: Json<BlockPerson>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<BlockPersonResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<BlockPersonResponse>> {
|
||||
let target_id = data.person_id;
|
||||
let person_id = local_user_view.person.id;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_schema::source::{local_user::LocalUser, login_token::LoginToken};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn change_password(
|
||||
|
@ -19,7 +19,7 @@ pub async fn change_password(
|
|||
req: HttpRequest,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<LoginResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<LoginResponse>> {
|
||||
password_length_check(&data.new_password)?;
|
||||
|
||||
// Make sure passwords match
|
||||
|
|
|
@ -10,13 +10,13 @@ use lemmy_db_schema::source::{
|
|||
login_token::LoginToken,
|
||||
password_reset_request::PasswordResetRequest,
|
||||
};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn change_password_after_reset(
|
||||
data: Json<PasswordChangeAfterReset>,
|
||||
context: Data<LemmyContext>,
|
||||
) -> Result<Json<SuccessResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<SuccessResponse>> {
|
||||
// Fetch the user_id from the token
|
||||
let token = data.token.clone();
|
||||
let local_user_id = PasswordResetRequest::read_from_token(&mut context.pool(), &token)
|
||||
|
|
|
@ -8,7 +8,7 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_schema::source::local_user::{LocalUser, LocalUserUpdateForm};
|
||||
use lemmy_db_views::structs::{LocalUserView, SiteView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
/// Generate a new secret for two-factor-authentication. Afterwards you need to call [toggle_totp]
|
||||
/// to enable it. This can only be called if 2FA is currently disabled.
|
||||
|
@ -16,7 +16,7 @@ use lemmy_utils::error::{LemmyError, LemmyErrorType};
|
|||
pub async fn generate_totp_secret(
|
||||
local_user_view: LocalUserView,
|
||||
context: Data<LemmyContext>,
|
||||
) -> Result<Json<GenerateTotpSecretResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<GenerateTotpSecretResponse>> {
|
||||
let site_view = SiteView::read_local(&mut context.pool()).await?;
|
||||
|
||||
if local_user_view.local_user.totp_2fa_enabled {
|
||||
|
|
|
@ -17,10 +17,10 @@ use lemmy_db_schema::source::{
|
|||
captcha_answer::{CaptchaAnswer, CaptchaAnswerForm},
|
||||
local_site::LocalSite,
|
||||
};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn get_captcha(context: Data<LemmyContext>) -> Result<HttpResponse, LemmyError> {
|
||||
pub async fn get_captcha(context: Data<LemmyContext>) -> LemmyResult<HttpResponse> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
let mut res = HttpResponseBuilder::new(StatusCode::OK);
|
||||
res.insert_header(CacheControl(vec![CacheDirective::NoStore]));
|
||||
|
|
|
@ -2,12 +2,12 @@ use actix_web::web::{Data, Json};
|
|||
use lemmy_api_common::{context::LemmyContext, person::BannedPersonsResponse, utils::is_admin};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::structs::PersonView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
pub async fn list_banned_users(
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<BannedPersonsResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<BannedPersonsResponse>> {
|
||||
// Make sure user is an admin
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@ use actix_web::web::{Data, Json};
|
|||
use lemmy_api_common::context::LemmyContext;
|
||||
use lemmy_db_schema::source::login_token::LoginToken;
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
pub async fn list_logins(
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<Vec<LoginToken>>, LemmyError> {
|
||||
) -> LemmyResult<Json<Vec<LoginToken>>> {
|
||||
let logins = LoginToken::list(&mut context.pool(), local_user_view.local_user.id).await?;
|
||||
|
||||
Ok(Json(logins))
|
||||
|
|
|
@ -5,14 +5,14 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_schema::source::images::LocalImage;
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn list_media(
|
||||
data: Query<ListMedia>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<ListMediaResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<ListMediaResponse>> {
|
||||
let page = data.page;
|
||||
let limit = data.limit;
|
||||
let images = LocalImage::get_all_paged_by_local_user_id(
|
||||
|
|
|
@ -16,14 +16,14 @@ use lemmy_db_schema::{
|
|||
RegistrationMode,
|
||||
};
|
||||
use lemmy_db_views::structs::{LocalUserView, SiteView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn login(
|
||||
data: Json<Login>,
|
||||
req: HttpRequest,
|
||||
context: Data<LemmyContext>,
|
||||
) -> Result<Json<LoginResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<LoginResponse>> {
|
||||
let site_view = SiteView::read_local(&mut context.pool()).await?;
|
||||
|
||||
// Fetch that username / email
|
||||
|
@ -70,7 +70,7 @@ async fn check_registration_application(
|
|||
local_user_view: &LocalUserView,
|
||||
local_site: &LocalSite,
|
||||
pool: &mut DbPool<'_>,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
if (local_site.registration_mode == RegistrationMode::RequireApplication
|
||||
|| local_site.registration_mode == RegistrationMode::Closed)
|
||||
&& !local_user_view.local_user.accepted_application
|
||||
|
|
|
@ -5,14 +5,14 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::person_mention_view::PersonMentionQuery;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn list_mentions(
|
||||
data: Query<GetPersonMentions>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<GetPersonMentionsResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<GetPersonMentionsResponse>> {
|
||||
let sort = data.sort;
|
||||
let page = data.page;
|
||||
let limit = data.limit;
|
||||
|
|
|
@ -5,14 +5,14 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::comment_reply_view::CommentReplyQuery;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn list_replies(
|
||||
data: Query<GetReplies>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<GetRepliesResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<GetRepliesResponse>> {
|
||||
let sort = data.sort;
|
||||
let page = data.page;
|
||||
let limit = data.limit;
|
||||
|
|
|
@ -6,13 +6,13 @@ use lemmy_db_schema::source::{
|
|||
private_message::PrivateMessage,
|
||||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn mark_all_notifications_read(
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<GetRepliesResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<GetRepliesResponse>> {
|
||||
let person_id = local_user_view.person.id;
|
||||
|
||||
// Mark all comment_replies as read
|
||||
|
|
|
@ -9,14 +9,14 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::structs::PersonMentionView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn mark_person_mention_as_read(
|
||||
data: Json<MarkPersonMentionAsRead>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PersonMentionResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PersonMentionResponse>> {
|
||||
let person_mention_id = data.person_mention_id;
|
||||
let read_person_mention = PersonMention::read(&mut context.pool(), person_mention_id).await?;
|
||||
|
||||
|
|
|
@ -9,14 +9,14 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::structs::CommentReplyView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn mark_reply_as_read(
|
||||
data: Json<MarkCommentReplyAsRead>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommentReplyResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommentReplyResponse>> {
|
||||
let comment_reply_id = data.comment_reply_id;
|
||||
let read_comment_reply = CommentReply::read(&mut context.pool(), comment_reply_id).await?;
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ use actix_web::web::{Data, Json};
|
|||
use lemmy_api_common::{context::LemmyContext, person::GetUnreadCountResponse};
|
||||
use lemmy_db_views::structs::{LocalUserView, PrivateMessageView};
|
||||
use lemmy_db_views_actor::structs::{CommentReplyView, PersonMentionView};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn unread_count(
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<GetUnreadCountResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<GetUnreadCountResponse>> {
|
||||
let person_id = local_user_view.person.id;
|
||||
|
||||
let replies = CommentReplyView::get_unread_replies(&mut context.pool(), person_id).await?;
|
||||
|
|
|
@ -10,14 +10,14 @@ use lemmy_db_views::structs::{
|
|||
PostReportView,
|
||||
PrivateMessageReportView,
|
||||
};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn report_count(
|
||||
data: Query<GetReportCount>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<GetReportCountResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<GetReportCountResponse>> {
|
||||
let person_id = local_user_view.person.id;
|
||||
let admin = local_user_view.local_user.admin;
|
||||
let community_id = data.community_id;
|
||||
|
|
|
@ -25,7 +25,7 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::{LocalUserView, SiteView};
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorType},
|
||||
error::{LemmyErrorType, LemmyResult},
|
||||
utils::validation::{is_valid_bio_field, is_valid_display_name, is_valid_matrix_id},
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,7 @@ pub async fn save_user_settings(
|
|||
data: Json<SaveUserSettings>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<SuccessResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<SuccessResponse>> {
|
||||
let site_view = SiteView::read_local(&mut context.pool()).await?;
|
||||
|
||||
let slur_regex = local_site_to_slur_regex(&site_view.local_site);
|
||||
|
|
|
@ -6,7 +6,7 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_schema::source::local_user::{LocalUser, LocalUserUpdateForm};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
/// Enable or disable two-factor-authentication. The current setting is determined from
|
||||
/// [LocalUser.totp_2fa_enabled].
|
||||
|
@ -21,7 +21,7 @@ pub async fn update_totp(
|
|||
data: Json<UpdateTotp>,
|
||||
local_user_view: LocalUserView,
|
||||
context: Data<LemmyContext>,
|
||||
) -> Result<Json<UpdateTotpResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<UpdateTotpResponse>> {
|
||||
check_totp_2fa_valid(
|
||||
&local_user_view,
|
||||
&Some(data.totp_token.clone()),
|
||||
|
|
|
@ -4,7 +4,7 @@ use actix_web::{
|
|||
HttpRequest,
|
||||
};
|
||||
use lemmy_api_common::{context::LemmyContext, SuccessResponse};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
/// Returns an error message if the auth token is invalid for any reason. Necessary because other
|
||||
/// endpoints silently treat any call with invalid auth as unauthenticated.
|
||||
|
@ -12,7 +12,7 @@ use lemmy_utils::error::{LemmyError, LemmyErrorType};
|
|||
pub async fn validate_auth(
|
||||
req: HttpRequest,
|
||||
context: Data<LemmyContext>,
|
||||
) -> Result<Json<SuccessResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<SuccessResponse>> {
|
||||
let jwt = read_auth_token(&req)?;
|
||||
if let Some(jwt) = jwt {
|
||||
local_user_view_from_jwt(&jwt, &context).await?;
|
||||
|
|
|
@ -16,14 +16,14 @@ use lemmy_db_schema::{
|
|||
PostFeatureType,
|
||||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn feature_post(
|
||||
data: Json<FeaturePost>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PostResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PostResponse>> {
|
||||
let post_id = data.post_id;
|
||||
let orig_post = Post::read(&mut context.pool(), post_id).await?;
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@ use lemmy_api_common::{
|
|||
post::{GetSiteMetadata, GetSiteMetadataResponse},
|
||||
request::fetch_link_metadata,
|
||||
};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn get_link_metadata(
|
||||
data: Query<GetSiteMetadata>,
|
||||
context: Data<LemmyContext>,
|
||||
) -> Result<Json<GetSiteMetadataResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<GetSiteMetadataResponse>> {
|
||||
let metadata = fetch_link_metadata(&data.url, false, &context).await?;
|
||||
|
||||
Ok(Json(GetSiteMetadataResponse { metadata }))
|
||||
|
|
|
@ -2,7 +2,7 @@ use actix_web::web::{Data, Json};
|
|||
use lemmy_api_common::{context::LemmyContext, post::HidePost, SuccessResponse};
|
||||
use lemmy_db_schema::source::post::PostHide;
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType, MAX_API_PARAM_ELEMENTS};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult, MAX_API_PARAM_ELEMENTS};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
|
@ -10,7 +10,7 @@ pub async fn hide_post(
|
|||
data: Json<HidePost>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<SuccessResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<SuccessResponse>> {
|
||||
let post_ids = HashSet::from_iter(data.post_ids.clone());
|
||||
|
||||
if post_ids.len() > MAX_API_PARAM_ELEMENTS {
|
||||
|
|
|
@ -21,7 +21,7 @@ use lemmy_db_schema::{
|
|||
traits::{Crud, Likeable},
|
||||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
use std::ops::Deref;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
|
@ -29,7 +29,7 @@ pub async fn like_post(
|
|||
data: Json<CreatePostLike>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PostResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PostResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
// Don't do a downvote if site has downvotes disabled
|
||||
|
|
|
@ -6,7 +6,7 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_schema::{source::post::Post, traits::Crud};
|
||||
use lemmy_db_views::structs::{LocalUserView, VoteView};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
/// Lists likes for a post
|
||||
#[tracing::instrument(skip(context))]
|
||||
|
@ -14,7 +14,7 @@ pub async fn list_post_likes(
|
|||
data: Query<ListPostLikes>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<ListPostLikesResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<ListPostLikesResponse>> {
|
||||
let post = Post::read(&mut context.pool(), data.post_id).await?;
|
||||
is_mod_or_admin(
|
||||
&mut context.pool(),
|
||||
|
|
|
@ -15,14 +15,14 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn lock_post(
|
||||
data: Json<LockPost>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PostResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PostResponse>> {
|
||||
let post_id = data.post_id;
|
||||
let orig_post = Post::read(&mut context.pool(), post_id).await?;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use actix_web::web::{Data, Json};
|
|||
use lemmy_api_common::{context::LemmyContext, post::MarkPostAsRead, SuccessResponse};
|
||||
use lemmy_db_schema::source::post::PostRead;
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType, MAX_API_PARAM_ELEMENTS};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult, MAX_API_PARAM_ELEMENTS};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
|
@ -10,7 +10,7 @@ pub async fn mark_post_as_read(
|
|||
data: Json<MarkPostAsRead>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<SuccessResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<SuccessResponse>> {
|
||||
let post_ids = HashSet::from_iter(data.post_ids.clone());
|
||||
|
||||
if post_ids.len() > MAX_API_PARAM_ELEMENTS {
|
||||
|
|
|
@ -9,14 +9,14 @@ use lemmy_db_schema::{
|
|||
traits::Saveable,
|
||||
};
|
||||
use lemmy_db_views::structs::{LocalUserView, PostView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn save_post(
|
||||
data: Json<SavePost>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PostResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PostResponse>> {
|
||||
let post_saved_form = PostSavedForm {
|
||||
post_id: data.post_id,
|
||||
person_id: local_user_view.person.id,
|
||||
|
|
|
@ -19,7 +19,7 @@ use lemmy_db_schema::{
|
|||
traits::Reportable,
|
||||
};
|
||||
use lemmy_db_views::structs::{LocalUserView, PostReportView, PostView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
/// Creates a post report and notifies the moderators of the community
|
||||
#[tracing::instrument(skip(context))]
|
||||
|
@ -27,7 +27,7 @@ pub async fn create_post_report(
|
|||
data: Json<CreatePostReport>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PostReportResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PostReportResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
let reason = data.reason.trim().to_string();
|
||||
|
|
|
@ -5,7 +5,7 @@ use lemmy_api_common::{
|
|||
utils::check_community_mod_of_any_or_admin_action,
|
||||
};
|
||||
use lemmy_db_views::{post_report_view::PostReportQuery, structs::LocalUserView};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
/// Lists post reports for a community if an id is supplied
|
||||
/// or returns all post reports for communities a user moderates
|
||||
|
@ -14,7 +14,7 @@ pub async fn list_post_reports(
|
|||
data: Query<ListPostReports>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<ListPostReportsResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<ListPostReportsResponse>> {
|
||||
let community_id = data.community_id;
|
||||
let post_id = data.post_id;
|
||||
let unresolved_only = data.unresolved_only.unwrap_or_default();
|
||||
|
|
|
@ -6,7 +6,7 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_schema::{source::post_report::PostReport, traits::Reportable};
|
||||
use lemmy_db_views::structs::{LocalUserView, PostReportView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
/// Resolves or unresolves a post report and notifies the moderators of the community
|
||||
#[tracing::instrument(skip(context))]
|
||||
|
@ -14,7 +14,7 @@ pub async fn resolve_post_report(
|
|||
data: Json<ResolvePostReport>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PostReportResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PostReportResponse>> {
|
||||
let report_id = data.report_id;
|
||||
let person_id = local_user_view.person.id;
|
||||
let report = PostReportView::read(&mut context.pool(), report_id, person_id).await?;
|
||||
|
|
|
@ -8,14 +8,14 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views::structs::{LocalUserView, PrivateMessageView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn mark_pm_as_read(
|
||||
data: Json<MarkPrivateMessageAsRead>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PrivateMessageResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PrivateMessageResponse>> {
|
||||
// Checking permissions
|
||||
let private_message_id = data.private_message_id;
|
||||
let orig_private_message = PrivateMessage::read(&mut context.pool(), private_message_id).await?;
|
||||
|
|
|
@ -14,14 +14,14 @@ use lemmy_db_schema::{
|
|||
traits::{Crud, Reportable},
|
||||
};
|
||||
use lemmy_db_views::structs::{LocalUserView, PrivateMessageReportView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn create_pm_report(
|
||||
data: Json<CreatePrivateMessageReport>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PrivateMessageReportResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PrivateMessageReportResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
let reason = data.reason.trim().to_string();
|
||||
|
|
|
@ -8,14 +8,14 @@ use lemmy_db_views::{
|
|||
private_message_report_view::PrivateMessageReportQuery,
|
||||
structs::LocalUserView,
|
||||
};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn list_pm_reports(
|
||||
data: Query<ListPrivateMessageReports>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<ListPrivateMessageReportsResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<ListPrivateMessageReportsResponse>> {
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
let unresolved_only = data.unresolved_only.unwrap_or_default();
|
||||
|
|
|
@ -6,14 +6,14 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_schema::{source::private_message_report::PrivateMessageReport, traits::Reportable};
|
||||
use lemmy_db_views::structs::{LocalUserView, PrivateMessageReportView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn resolve_pm_report(
|
||||
data: Json<ResolvePrivateMessageReport>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PrivateMessageReportResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PrivateMessageReportResponse>> {
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
let report_id = data.report_id;
|
||||
|
|
|
@ -9,14 +9,14 @@ use lemmy_db_schema::{
|
|||
traits::Blockable,
|
||||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn block_instance(
|
||||
data: Json<BlockInstance>,
|
||||
local_user_view: LocalUserView,
|
||||
context: Data<LemmyContext>,
|
||||
) -> Result<Json<BlockInstanceResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<BlockInstanceResponse>> {
|
||||
let instance_id = data.instance_id;
|
||||
let person_id = local_user_view.person.id;
|
||||
if local_user_view.person.instance_id == instance_id {
|
||||
|
|
|
@ -5,12 +5,12 @@ use lemmy_api_common::{
|
|||
utils::build_federated_instances,
|
||||
};
|
||||
use lemmy_db_views::structs::SiteView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn get_federated_instances(
|
||||
context: Data<LemmyContext>,
|
||||
) -> Result<Json<GetFederatedInstancesResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<GetFederatedInstancesResponse>> {
|
||||
let site_view = SiteView::read_local(&mut context.pool()).await?;
|
||||
let federated_instances =
|
||||
build_federated_instances(&site_view.local_site, &mut context.pool()).await?;
|
||||
|
|
|
@ -14,7 +14,7 @@ use lemmy_db_schema::{
|
|||
use lemmy_db_views::structs::{CustomEmojiView, LocalUserView, SiteView};
|
||||
use lemmy_db_views_actor::structs::PersonView;
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorType},
|
||||
error::{LemmyErrorType, LemmyResult},
|
||||
VERSION,
|
||||
};
|
||||
|
||||
|
@ -22,7 +22,7 @@ use lemmy_utils::{
|
|||
pub async fn leave_admin(
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<GetSiteResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<GetSiteResponse>> {
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
// Make sure there isn't just one admin (so if one leaves, there will still be one left)
|
||||
|
|
|
@ -6,14 +6,14 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_schema::source::images::LocalImage;
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn list_all_media(
|
||||
data: Query<ListMedia>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<ListMediaResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<ListMediaResponse>> {
|
||||
// Only let admins view all media
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ use lemmy_db_views_moderator::structs::{
|
|||
ModTransferCommunityView,
|
||||
ModlogListParams,
|
||||
};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
use ModlogActionType::*;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
|
@ -32,7 +32,7 @@ pub async fn get_mod_log(
|
|||
data: Query<GetModlog>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: Option<LocalUserView>,
|
||||
) -> Result<Json<GetModlogResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<GetModlogResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
check_private_instance(&local_user_view, &local_site)?;
|
||||
|
|
|
@ -15,14 +15,14 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views::structs::{CommentView, LocalUserView};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn purge_comment(
|
||||
data: Json<PurgeComment>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<SuccessResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<SuccessResponse>> {
|
||||
// Only let admin purge an item
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn purge_community(
|
||||
data: Json<PurgeCommunity>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<SuccessResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<SuccessResponse>> {
|
||||
// Only let admin purge an item
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn purge_person(
|
||||
data: Json<PurgePerson>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<SuccessResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<SuccessResponse>> {
|
||||
// Only let admin purge an item
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn purge_post(
|
||||
data: Json<PurgePost>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<SuccessResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<SuccessResponse>> {
|
||||
// Only let admin purge an item
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
|
|
|
@ -13,13 +13,13 @@ use lemmy_db_schema::{
|
|||
utils::diesel_option_overwrite,
|
||||
};
|
||||
use lemmy_db_views::structs::{LocalUserView, RegistrationApplicationView};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
pub async fn approve_registration_application(
|
||||
data: Json<ApproveRegistrationApplication>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<RegistrationApplicationResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<RegistrationApplicationResponse>> {
|
||||
let app_id = data.id;
|
||||
|
||||
// Only let admins do this
|
||||
|
|
|
@ -9,14 +9,14 @@ use lemmy_db_views::{
|
|||
registration_application_view::RegistrationApplicationQuery,
|
||||
structs::LocalUserView,
|
||||
};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
/// Lists registration applications, filterable by undenied only.
|
||||
pub async fn list_registration_applications(
|
||||
data: Query<ListRegistrationApplications>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<ListRegistrationApplicationsResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<ListRegistrationApplicationsResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
// Make sure user is an admin
|
||||
|
|
|
@ -6,12 +6,12 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_schema::source::local_site::LocalSite;
|
||||
use lemmy_db_views::structs::{LocalUserView, RegistrationApplicationView};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
pub async fn get_unread_registration_application_count(
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<GetUnreadRegistrationApplicationCountResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<GetUnreadRegistrationApplicationCountResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
// Only let admins do this
|
||||
|
|
|
@ -25,7 +25,7 @@ use lemmy_db_schema::{
|
|||
use lemmy_db_views::structs::{CommentView, LocalUserView, PostView};
|
||||
use lemmy_db_views_actor::structs::CommunityView;
|
||||
use lemmy_utils::{
|
||||
error::LemmyError,
|
||||
error::LemmyResult,
|
||||
utils::{markdown::markdown_to_html, mention::MentionData},
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,7 @@ pub async fn build_comment_response(
|
|||
comment_id: CommentId,
|
||||
local_user_view: Option<LocalUserView>,
|
||||
recipient_ids: Vec<LocalUserId>,
|
||||
) -> Result<CommentResponse, LemmyError> {
|
||||
) -> LemmyResult<CommentResponse> {
|
||||
let person_id = local_user_view.map(|l| l.person.id);
|
||||
let comment_view = CommentView::read(&mut context.pool(), comment_id, person_id).await?;
|
||||
Ok(CommentResponse {
|
||||
|
@ -47,7 +47,7 @@ pub async fn build_community_response(
|
|||
context: &LemmyContext,
|
||||
local_user_view: LocalUserView,
|
||||
community_id: CommunityId,
|
||||
) -> Result<Json<CommunityResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommunityResponse>> {
|
||||
let is_mod_or_admin = is_mod_or_admin(&mut context.pool(), &local_user_view.person, community_id)
|
||||
.await
|
||||
.is_ok();
|
||||
|
@ -72,7 +72,7 @@ pub async fn build_post_response(
|
|||
community_id: CommunityId,
|
||||
person: &Person,
|
||||
post_id: PostId,
|
||||
) -> Result<Json<PostResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PostResponse>> {
|
||||
let is_mod_or_admin = is_mod_or_admin(&mut context.pool(), person, community_id)
|
||||
.await
|
||||
.is_ok();
|
||||
|
@ -94,7 +94,7 @@ pub async fn send_local_notifs(
|
|||
person: &Person,
|
||||
do_send_email: bool,
|
||||
context: &LemmyContext,
|
||||
) -> Result<Vec<LocalUserId>, LemmyError> {
|
||||
) -> LemmyResult<Vec<LocalUserId>> {
|
||||
let mut recipient_ids = Vec::new();
|
||||
let inbox_link = format!("{}/inbox", context.settings().get_protocol_and_hostname());
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ pub extern crate lemmy_utils;
|
|||
|
||||
pub use lemmy_utils::LemmyErrorType;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::time::Duration;
|
||||
use std::{cmp::min, time::Duration};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(ts_rs::TS))]
|
||||
|
@ -43,7 +43,39 @@ impl Default for SuccessResponse {
|
|||
}
|
||||
}
|
||||
|
||||
/// how long to sleep based on how many retries have already happened
|
||||
// TODO: use from_days once stabilized
|
||||
// https://github.com/rust-lang/rust/issues/120301
|
||||
const DAY: Duration = Duration::from_secs(24 * 60 * 60);
|
||||
|
||||
/// Calculate how long to sleep until next federation send based on how many
|
||||
/// retries have already happened. Uses exponential backoff with maximum of one day. The first
|
||||
/// error is ignored.
|
||||
pub fn federate_retry_sleep_duration(retry_count: i32) -> Duration {
|
||||
Duration::from_secs_f64(2.0_f64.powf(f64::from(retry_count)))
|
||||
debug_assert!(retry_count != 0);
|
||||
if retry_count == 1 {
|
||||
return Duration::from_secs(0);
|
||||
}
|
||||
let retry_count = retry_count - 1;
|
||||
let pow = 1.25_f64.powf(retry_count.into());
|
||||
let pow = Duration::try_from_secs_f64(pow).unwrap_or(DAY);
|
||||
min(DAY, pow)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_federate_retry_sleep_duration() {
|
||||
assert_eq!(Duration::from_secs(0), federate_retry_sleep_duration(1));
|
||||
assert_eq!(
|
||||
Duration::new(1, 250000000),
|
||||
federate_retry_sleep_duration(2)
|
||||
);
|
||||
assert_eq!(
|
||||
Duration::new(2, 441406250),
|
||||
federate_retry_sleep_duration(5)
|
||||
);
|
||||
assert_eq!(DAY, federate_retry_sleep_duration(100));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ use lemmy_db_schema::{
|
|||
},
|
||||
};
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorType},
|
||||
error::{LemmyError, LemmyErrorType, LemmyResult},
|
||||
settings::structs::{PictrsImageMode, Settings},
|
||||
spawn_try_task,
|
||||
REQWEST_TIMEOUT,
|
||||
|
@ -46,7 +46,7 @@ pub async fn fetch_link_metadata(
|
|||
url: &Url,
|
||||
generate_thumbnail: bool,
|
||||
context: &LemmyContext,
|
||||
) -> Result<LinkMetadata, LemmyError> {
|
||||
) -> LemmyResult<LinkMetadata> {
|
||||
info!("Fetching site metadata for url: {}", url);
|
||||
let response = context.client().get(url.as_str()).send().await?;
|
||||
|
||||
|
@ -97,29 +97,46 @@ pub fn generate_post_link_metadata(
|
|||
context: Data<LemmyContext>,
|
||||
) {
|
||||
spawn_try_task(async move {
|
||||
// Decide if the thumbnail should be generated
|
||||
let allow_sensitive = local_site_opt_to_sensitive(&local_site);
|
||||
let page_is_sensitive = post.nsfw;
|
||||
let allow_generate_thumbnail = allow_sensitive || !page_is_sensitive;
|
||||
let mut thumbnail_url = custom_thumbnail.or_else(|| post.thumbnail_url.map(Into::into));
|
||||
let do_generate_thumbnail = thumbnail_url.is_none() && allow_generate_thumbnail;
|
||||
let do_generate_thumbnail =
|
||||
allow_generate_thumbnail && custom_thumbnail.is_none() && post.thumbnail_url.is_none();
|
||||
|
||||
// Generate local thumbnail only if no thumbnail was federated and 'sensitive' attributes allow it.
|
||||
let metadata = fetch_link_metadata_opt(
|
||||
post.url.map(Into::into).as_ref(),
|
||||
post.url.as_ref().map(DbUrl::inner),
|
||||
do_generate_thumbnail,
|
||||
&context,
|
||||
)
|
||||
.await;
|
||||
if let Some(thumbnail_url_) = metadata.thumbnail {
|
||||
thumbnail_url = Some(thumbnail_url_.into());
|
||||
}
|
||||
let thumbnail_url = proxy_image_link_opt_apub(thumbnail_url, &context).await?;
|
||||
|
||||
// If its an image post, it needs to overwrite the thumbnail, and take precedence
|
||||
let image_url = if metadata
|
||||
.content_type
|
||||
.as_ref()
|
||||
.is_some_and(|content_type| content_type.starts_with("image"))
|
||||
{
|
||||
post.url.map(Into::into)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// Build the thumbnail url based on either the post image url, custom thumbnail, metadata fetch, or existing thumbnail.
|
||||
let thumbnail_url = image_url
|
||||
.or(custom_thumbnail)
|
||||
.or(metadata.thumbnail.map(Into::into))
|
||||
.or(post.thumbnail_url.map(Into::into));
|
||||
|
||||
// Proxy the image fetch if necessary
|
||||
let proxied_thumbnail_url = proxy_image_link_opt_apub(thumbnail_url, &context).await?;
|
||||
|
||||
let form = PostUpdateForm {
|
||||
embed_title: Some(metadata.opengraph_data.title),
|
||||
embed_description: Some(metadata.opengraph_data.description),
|
||||
embed_video_url: Some(metadata.opengraph_data.embed_video_url),
|
||||
thumbnail_url: Some(thumbnail_url),
|
||||
thumbnail_url: Some(proxied_thumbnail_url),
|
||||
url_content_type: Some(metadata.content_type),
|
||||
..Default::default()
|
||||
};
|
||||
|
@ -132,7 +149,7 @@ pub fn generate_post_link_metadata(
|
|||
}
|
||||
|
||||
/// Extract site metadata from HTML Opengraph attributes.
|
||||
fn extract_opengraph_data(html_bytes: &[u8], url: &Url) -> Result<OpenGraphData, LemmyError> {
|
||||
fn extract_opengraph_data(html_bytes: &[u8], url: &Url) -> LemmyResult<OpenGraphData> {
|
||||
let html = String::from_utf8_lossy(html_bytes);
|
||||
|
||||
// Make sure the first line is doctype html
|
||||
|
@ -240,10 +257,7 @@ struct PictrsPurgeResponse {
|
|||
/// - It might fail due to image being not local
|
||||
/// - It might not be an image
|
||||
/// - Pictrs might not be set up
|
||||
pub async fn purge_image_from_pictrs(
|
||||
image_url: &Url,
|
||||
context: &LemmyContext,
|
||||
) -> Result<(), LemmyError> {
|
||||
pub async fn purge_image_from_pictrs(image_url: &Url, context: &LemmyContext) -> LemmyResult<()> {
|
||||
is_image_content_type(context.client(), image_url).await?;
|
||||
|
||||
let alias = image_url
|
||||
|
@ -278,7 +292,7 @@ pub async fn delete_image_from_pictrs(
|
|||
alias: &str,
|
||||
delete_token: &str,
|
||||
context: &LemmyContext,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
let pictrs_config = context.settings().pictrs_config()?;
|
||||
let url = format!(
|
||||
"{}image/delete/{}/{}",
|
||||
|
@ -296,15 +310,16 @@ pub async fn delete_image_from_pictrs(
|
|||
|
||||
/// Retrieves the image with local pict-rs and generates a thumbnail. Returns the thumbnail url.
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn generate_pictrs_thumbnail(
|
||||
image_url: &Url,
|
||||
context: &LemmyContext,
|
||||
) -> Result<Url, LemmyError> {
|
||||
async fn generate_pictrs_thumbnail(image_url: &Url, context: &LemmyContext) -> LemmyResult<Url> {
|
||||
let pictrs_config = context.settings().pictrs_config()?;
|
||||
|
||||
if pictrs_config.image_mode() == PictrsImageMode::ProxyAllImages {
|
||||
return Ok(proxy_image_link(image_url.clone(), context).await?.into());
|
||||
}
|
||||
match pictrs_config.image_mode() {
|
||||
PictrsImageMode::None => return Ok(image_url.clone()),
|
||||
PictrsImageMode::ProxyAllImages => {
|
||||
return Ok(proxy_image_link(image_url.clone(), context).await?.into())
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
// fetch remote non-pictrs images for persistent thumbnail link
|
||||
// TODO: should limit size once supported by pictrs
|
||||
|
@ -345,7 +360,7 @@ async fn generate_pictrs_thumbnail(
|
|||
|
||||
// TODO: get rid of this by reading content type from db
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn is_image_content_type(client: &ClientWithMiddleware, url: &Url) -> Result<(), LemmyError> {
|
||||
async fn is_image_content_type(client: &ClientWithMiddleware, url: &Url) -> LemmyResult<()> {
|
||||
let response = client.get(url.as_str()).send().await?;
|
||||
if response
|
||||
.headers()
|
||||
|
@ -365,7 +380,7 @@ pub async fn replace_image(
|
|||
new_image: &Option<String>,
|
||||
old_image: &Option<DbUrl>,
|
||||
context: &Data<LemmyContext>,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
if new_image.is_some() {
|
||||
// Ignore errors because image may be stored externally.
|
||||
if let Some(avatar) = &old_image {
|
||||
|
|
|
@ -42,7 +42,7 @@ use lemmy_utils::{
|
|||
markdown::{markdown_check_for_blocked_urls, markdown_rewrite_image_links},
|
||||
slurs::{build_slur_regex, remove_slurs},
|
||||
},
|
||||
CACHE_DURATION_SHORT,
|
||||
CACHE_DURATION_FEDERATION,
|
||||
};
|
||||
use moka::future::Cache;
|
||||
use once_cell::sync::Lazy;
|
||||
|
@ -60,7 +60,7 @@ pub async fn is_mod_or_admin(
|
|||
pool: &mut DbPool<'_>,
|
||||
person: &Person,
|
||||
community_id: CommunityId,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
check_user_valid(person)?;
|
||||
|
||||
let is_mod_or_admin = CommunityView::is_mod_or_admin(pool, person.id, community_id).await?;
|
||||
|
@ -76,7 +76,7 @@ pub async fn is_mod_or_admin_opt(
|
|||
pool: &mut DbPool<'_>,
|
||||
local_user_view: Option<&LocalUserView>,
|
||||
community_id: Option<CommunityId>,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
if let Some(local_user_view) = local_user_view {
|
||||
if let Some(community_id) = community_id {
|
||||
is_mod_or_admin(pool, &local_user_view.person, community_id).await
|
||||
|
@ -108,7 +108,7 @@ pub async fn check_community_mod_of_any_or_admin_action(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_admin(local_user_view: &LocalUserView) -> Result<(), LemmyError> {
|
||||
pub fn is_admin(local_user_view: &LocalUserView) -> LemmyResult<()> {
|
||||
check_user_valid(&local_user_view.person)?;
|
||||
if !local_user_view.local_user.admin {
|
||||
Err(LemmyErrorType::NotAnAdmin)?
|
||||
|
@ -122,7 +122,7 @@ pub fn is_admin(local_user_view: &LocalUserView) -> Result<(), LemmyError> {
|
|||
pub fn is_top_mod(
|
||||
local_user_view: &LocalUserView,
|
||||
community_mods: &[CommunityModeratorView],
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
check_user_valid(&local_user_view.person)?;
|
||||
if local_user_view.person.id
|
||||
!= community_mods
|
||||
|
@ -137,7 +137,7 @@ pub fn is_top_mod(
|
|||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn get_post(post_id: PostId, pool: &mut DbPool<'_>) -> Result<Post, LemmyError> {
|
||||
pub async fn get_post(post_id: PostId, pool: &mut DbPool<'_>) -> LemmyResult<Post> {
|
||||
Post::read(pool, post_id)
|
||||
.await
|
||||
.with_lemmy_type(LemmyErrorType::CouldntFindPost)
|
||||
|
@ -148,14 +148,14 @@ pub async fn mark_post_as_read(
|
|||
person_id: PersonId,
|
||||
post_id: PostId,
|
||||
pool: &mut DbPool<'_>,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
PostRead::mark_as_read(pool, HashSet::from([post_id]), person_id)
|
||||
.await
|
||||
.with_lemmy_type(LemmyErrorType::CouldntMarkPostAsRead)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn check_user_valid(person: &Person) -> Result<(), LemmyError> {
|
||||
pub fn check_user_valid(person: &Person) -> LemmyResult<()> {
|
||||
// Check for a site ban
|
||||
if person.banned {
|
||||
Err(LemmyErrorType::SiteBan)?
|
||||
|
@ -230,7 +230,7 @@ pub async fn check_community_mod_action(
|
|||
}
|
||||
|
||||
/// Don't allow creating reports for removed / deleted posts
|
||||
pub fn check_post_deleted_or_removed(post: &Post) -> Result<(), LemmyError> {
|
||||
pub fn check_post_deleted_or_removed(post: &Post) -> LemmyResult<()> {
|
||||
if post.deleted || post.removed {
|
||||
Err(LemmyErrorType::Deleted)?
|
||||
} else {
|
||||
|
@ -238,7 +238,7 @@ pub fn check_post_deleted_or_removed(post: &Post) -> Result<(), LemmyError> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_comment_deleted_or_removed(comment: &Comment) -> Result<(), LemmyError> {
|
||||
pub fn check_comment_deleted_or_removed(comment: &Comment) -> LemmyResult<()> {
|
||||
if comment.deleted || comment.removed {
|
||||
Err(LemmyErrorType::Deleted)?
|
||||
} else {
|
||||
|
@ -252,7 +252,7 @@ pub async fn check_person_block(
|
|||
my_id: PersonId,
|
||||
potential_blocker_id: PersonId,
|
||||
pool: &mut DbPool<'_>,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
let is_blocked = PersonBlock::read(pool, potential_blocker_id, my_id).await?;
|
||||
if is_blocked {
|
||||
Err(LemmyErrorType::PersonIsBlocked)?
|
||||
|
@ -267,7 +267,7 @@ async fn check_community_block(
|
|||
community_id: CommunityId,
|
||||
person_id: PersonId,
|
||||
pool: &mut DbPool<'_>,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
let is_blocked = CommunityBlock::read(pool, person_id, community_id).await?;
|
||||
if is_blocked {
|
||||
Err(LemmyErrorType::CommunityIsBlocked)?
|
||||
|
@ -282,7 +282,7 @@ async fn check_instance_block(
|
|||
instance_id: InstanceId,
|
||||
person_id: PersonId,
|
||||
pool: &mut DbPool<'_>,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
let is_blocked = InstanceBlock::read(pool, person_id, instance_id).await?;
|
||||
if is_blocked {
|
||||
Err(LemmyErrorType::InstanceIsBlocked)?
|
||||
|
@ -298,7 +298,7 @@ pub async fn check_person_instance_community_block(
|
|||
community_instance_id: InstanceId,
|
||||
community_id: CommunityId,
|
||||
pool: &mut DbPool<'_>,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
check_person_block(my_id, potential_blocker_id, pool).await?;
|
||||
check_instance_block(community_instance_id, potential_blocker_id, pool).await?;
|
||||
check_community_block(community_id, potential_blocker_id, pool).await?;
|
||||
|
@ -306,7 +306,7 @@ pub async fn check_person_instance_community_block(
|
|||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub fn check_downvotes_enabled(score: i16, local_site: &LocalSite) -> Result<(), LemmyError> {
|
||||
pub fn check_downvotes_enabled(score: i16, local_site: &LocalSite) -> LemmyResult<()> {
|
||||
if score == -1 && !local_site.enable_downvotes {
|
||||
Err(LemmyErrorType::DownvotesAreDisabled)?
|
||||
} else {
|
||||
|
@ -316,7 +316,7 @@ pub fn check_downvotes_enabled(score: i16, local_site: &LocalSite) -> Result<(),
|
|||
|
||||
/// Dont allow bots to do certain actions, like voting
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub fn check_bot_account(person: &Person) -> Result<(), LemmyError> {
|
||||
pub fn check_bot_account(person: &Person) -> LemmyResult<()> {
|
||||
if person.bot_account {
|
||||
Err(LemmyErrorType::InvalidBotAction)?
|
||||
} else {
|
||||
|
@ -328,7 +328,7 @@ pub fn check_bot_account(person: &Person) -> Result<(), LemmyError> {
|
|||
pub fn check_private_instance(
|
||||
local_user_view: &Option<LocalUserView>,
|
||||
local_site: &LocalSite,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
if local_user_view.is_none() && local_site.private_instance {
|
||||
Err(LemmyErrorType::InstanceIsPrivate)?
|
||||
} else {
|
||||
|
@ -340,7 +340,7 @@ pub fn check_private_instance(
|
|||
pub async fn build_federated_instances(
|
||||
local_site: &LocalSite,
|
||||
pool: &mut DbPool<'_>,
|
||||
) -> Result<Option<FederatedInstances>, LemmyError> {
|
||||
) -> LemmyResult<Option<FederatedInstances>> {
|
||||
if local_site.federation_enabled {
|
||||
let mut linked = Vec::new();
|
||||
let mut allowed = Vec::new();
|
||||
|
@ -375,7 +375,7 @@ pub async fn build_federated_instances(
|
|||
}
|
||||
|
||||
/// Checks the password length
|
||||
pub fn password_length_check(pass: &str) -> Result<(), LemmyError> {
|
||||
pub fn password_length_check(pass: &str) -> LemmyResult<()> {
|
||||
if !(10..=60).contains(&pass.chars().count()) {
|
||||
Err(LemmyErrorType::InvalidPassword)?
|
||||
} else {
|
||||
|
@ -384,7 +384,7 @@ pub fn password_length_check(pass: &str) -> Result<(), LemmyError> {
|
|||
}
|
||||
|
||||
/// Checks for a honeypot. If this field is filled, fail the rest of the function
|
||||
pub fn honeypot_check(honeypot: &Option<String>) -> Result<(), LemmyError> {
|
||||
pub fn honeypot_check(honeypot: &Option<String>) -> LemmyResult<()> {
|
||||
if honeypot.is_some() && honeypot != &Some(String::new()) {
|
||||
Err(LemmyErrorType::HoneypotFailed)?
|
||||
} else {
|
||||
|
@ -422,7 +422,7 @@ pub async fn send_password_reset_email(
|
|||
user: &LocalUserView,
|
||||
pool: &mut DbPool<'_>,
|
||||
settings: &Settings,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
// Generate a random token
|
||||
let token = uuid::Uuid::new_v4().to_string();
|
||||
|
||||
|
@ -447,7 +447,7 @@ pub async fn send_verification_email(
|
|||
new_email: &str,
|
||||
pool: &mut DbPool<'_>,
|
||||
settings: &Settings,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
let form = EmailVerificationForm {
|
||||
local_user_id: user.local_user.id,
|
||||
email: new_email.to_string(),
|
||||
|
@ -524,7 +524,7 @@ 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(CACHE_DURATION_SHORT)
|
||||
.time_to_live(CACHE_DURATION_FEDERATION)
|
||||
.build()
|
||||
});
|
||||
|
||||
|
@ -564,7 +564,7 @@ pub async fn get_url_blocklist(context: &LemmyContext) -> LemmyResult<RegexSet>
|
|||
pub async fn send_application_approved_email(
|
||||
user: &LocalUserView,
|
||||
settings: &Settings,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
let email = &user.local_user.email.clone().expect("email");
|
||||
let lang = get_interface_language(user);
|
||||
let subject = lang.registration_approved_subject(&user.person.actor_id);
|
||||
|
@ -577,7 +577,7 @@ pub async fn send_new_applicant_email_to_admins(
|
|||
applicant_username: &str,
|
||||
pool: &mut DbPool<'_>,
|
||||
settings: &Settings,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
// Collect the admins with emails
|
||||
let admins = LocalUserView::list_admins_with_emails(pool).await?;
|
||||
|
||||
|
@ -602,7 +602,7 @@ pub async fn send_new_report_email_to_admins(
|
|||
reported_username: &str,
|
||||
pool: &mut DbPool<'_>,
|
||||
settings: &Settings,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
// Collect the admins with emails
|
||||
let admins = LocalUserView::list_admins_with_emails(pool).await?;
|
||||
|
||||
|
@ -618,9 +618,7 @@ pub async fn send_new_report_email_to_admins(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn check_private_instance_and_federation_enabled(
|
||||
local_site: &LocalSite,
|
||||
) -> Result<(), LemmyError> {
|
||||
pub fn check_private_instance_and_federation_enabled(local_site: &LocalSite) -> LemmyResult<()> {
|
||||
if local_site.private_instance && local_site.federation_enabled {
|
||||
Err(LemmyErrorType::CantEnablePrivateInstanceAndFederationTogether)?
|
||||
} else {
|
||||
|
@ -634,7 +632,7 @@ pub fn check_private_instance_and_federation_enabled(
|
|||
pub async fn read_site_for_actor(
|
||||
actor_id: DbUrl,
|
||||
context: &LemmyContext,
|
||||
) -> Result<Option<Site>, LemmyError> {
|
||||
) -> LemmyResult<Option<Site>> {
|
||||
let site_id = Site::instance_actor_id_from_url(actor_id.clone().into());
|
||||
let site = Site::read_from_apub_id(&mut context.pool(), &site_id.into()).await?;
|
||||
Ok(site)
|
||||
|
@ -643,7 +641,7 @@ pub async fn read_site_for_actor(
|
|||
pub async fn purge_image_posts_for_person(
|
||||
banned_person_id: PersonId,
|
||||
context: &LemmyContext,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
let pool = &mut context.pool();
|
||||
let posts = Post::fetch_pictrs_posts_for_creator(pool, banned_person_id).await?;
|
||||
for post in posts {
|
||||
|
@ -661,10 +659,7 @@ pub async fn purge_image_posts_for_person(
|
|||
}
|
||||
|
||||
/// Delete a local_user's images
|
||||
async fn delete_local_user_images(
|
||||
person_id: PersonId,
|
||||
context: &LemmyContext,
|
||||
) -> Result<(), LemmyError> {
|
||||
async fn delete_local_user_images(person_id: PersonId, context: &LemmyContext) -> LemmyResult<()> {
|
||||
if let Ok(local_user) = LocalUserView::read_person(&mut context.pool(), person_id).await {
|
||||
let pictrs_uploads =
|
||||
LocalImage::get_all_by_local_user_id(&mut context.pool(), local_user.local_user.id).await?;
|
||||
|
@ -682,7 +677,7 @@ async fn delete_local_user_images(
|
|||
pub async fn purge_image_posts_for_community(
|
||||
banned_community_id: CommunityId,
|
||||
context: &LemmyContext,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
let pool = &mut context.pool();
|
||||
let posts = Post::fetch_pictrs_posts_for_community(pool, banned_community_id).await?;
|
||||
for post in posts {
|
||||
|
@ -702,7 +697,7 @@ pub async fn purge_image_posts_for_community(
|
|||
pub async fn remove_user_data(
|
||||
banned_person_id: PersonId,
|
||||
context: &LemmyContext,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
let pool = &mut context.pool();
|
||||
// Purge user images
|
||||
let person = Person::read(pool, banned_person_id).await?;
|
||||
|
@ -785,7 +780,7 @@ pub async fn remove_user_data_in_community(
|
|||
community_id: CommunityId,
|
||||
banned_person_id: PersonId,
|
||||
pool: &mut DbPool<'_>,
|
||||
) -> Result<(), LemmyError> {
|
||||
) -> LemmyResult<()> {
|
||||
// Posts
|
||||
Post::update_removed_for_creator(pool, banned_person_id, Some(community_id), true).await?;
|
||||
|
||||
|
@ -815,10 +810,7 @@ pub async fn remove_user_data_in_community(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn purge_user_account(
|
||||
person_id: PersonId,
|
||||
context: &LemmyContext,
|
||||
) -> Result<(), LemmyError> {
|
||||
pub async fn purge_user_account(person_id: PersonId, context: &LemmyContext) -> LemmyResult<()> {
|
||||
let pool = &mut context.pool();
|
||||
|
||||
let person = Person::read(pool, person_id).await?;
|
||||
|
@ -888,7 +880,7 @@ pub fn generate_inbox_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
|
|||
Ok(Url::parse(&format!("{actor_id}/inbox"))?.into())
|
||||
}
|
||||
|
||||
pub fn generate_shared_inbox_url(settings: &Settings) -> Result<DbUrl, LemmyError> {
|
||||
pub fn generate_shared_inbox_url(settings: &Settings) -> LemmyResult<DbUrl> {
|
||||
let url = format!("{}/inbox", settings.get_protocol_and_hostname());
|
||||
Ok(Url::parse(&url)?.into())
|
||||
}
|
||||
|
@ -901,7 +893,7 @@ pub fn generate_featured_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
|
|||
Ok(Url::parse(&format!("{actor_id}/featured"))?.into())
|
||||
}
|
||||
|
||||
pub fn generate_moderators_url(community_id: &DbUrl) -> Result<DbUrl, LemmyError> {
|
||||
pub fn generate_moderators_url(community_id: &DbUrl) -> LemmyResult<DbUrl> {
|
||||
Ok(Url::parse(&format!("{community_id}/moderators"))?.into())
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
||||
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
|
||||
utils::{mention::scrape_text_for_mentions, validation::is_valid_body_field},
|
||||
};
|
||||
|
||||
|
@ -41,7 +41,7 @@ pub async fn create_comment(
|
|||
data: Json<CreateComment>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommentResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommentResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||
|
@ -207,7 +207,7 @@ pub async fn create_comment(
|
|||
))
|
||||
}
|
||||
|
||||
pub fn check_comment_depth(comment: &Comment) -> Result<(), LemmyError> {
|
||||
pub fn check_comment_depth(comment: &Comment) -> LemmyResult<()> {
|
||||
let path = &comment.path.0;
|
||||
let length = path.split('.').count();
|
||||
if length > MAX_COMMENT_DEPTH_LIMIT {
|
||||
|
|
|
@ -12,14 +12,14 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views::structs::{CommentView, LocalUserView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn delete_comment(
|
||||
data: Json<DeleteComment>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommentResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommentResponse>> {
|
||||
let comment_id = data.comment_id;
|
||||
let orig_comment = CommentView::read(&mut context.pool(), comment_id, None).await?;
|
||||
|
||||
|
|
|
@ -7,14 +7,14 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_schema::source::local_site::LocalSite;
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn get_comment(
|
||||
data: Query<GetComment>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: Option<LocalUserView>,
|
||||
) -> Result<Json<CommentResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommentResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
check_private_instance(&local_user_view, &local_site)?;
|
||||
|
|
|
@ -16,14 +16,14 @@ use lemmy_db_schema::{
|
|||
traits::{Crud, Reportable},
|
||||
};
|
||||
use lemmy_db_views::structs::{CommentView, LocalUserView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn remove_comment(
|
||||
data: Json<RemoveComment>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommentResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommentResponse>> {
|
||||
let comment_id = data.comment_id;
|
||||
let orig_comment = CommentView::read(&mut context.pool(), comment_id, None).await?;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::{CommentView, LocalUserView};
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
||||
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
|
||||
utils::{mention::scrape_text_for_mentions, validation::is_valid_body_field},
|
||||
};
|
||||
|
||||
|
@ -32,7 +32,7 @@ pub async fn update_comment(
|
|||
data: Json<EditComment>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommentResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommentResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
let comment_id = data.comment_id;
|
||||
|
|
|
@ -33,7 +33,7 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::{LocalUserView, SiteView};
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
||||
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
|
||||
utils::{
|
||||
slurs::check_slurs,
|
||||
validation::{is_valid_actor_name, is_valid_body_field},
|
||||
|
@ -45,7 +45,7 @@ pub async fn create_community(
|
|||
data: Json<CreateCommunity>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommunityResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommunityResponse>> {
|
||||
let site_view = SiteView::read_local(&mut context.pool()).await?;
|
||||
let local_site = site_view.local_site;
|
||||
|
||||
|
|
|
@ -13,14 +13,14 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::structs::CommunityModeratorView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn delete_community(
|
||||
data: Json<DeleteCommunity>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommunityResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommunityResponse>> {
|
||||
// Fetch the community mods
|
||||
let community_id = data.community_id;
|
||||
let community_mods =
|
||||
|
|
|
@ -6,14 +6,14 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_views::structs::{LocalUserView, SiteView};
|
||||
use lemmy_db_views_actor::community_view::CommunityQuery;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn list_communities(
|
||||
data: Query<ListCommunities>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: Option<LocalUserView>,
|
||||
) -> Result<Json<ListCommunitiesResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<ListCommunitiesResponse>> {
|
||||
let local_site = SiteView::read_local(&mut context.pool()).await?;
|
||||
let is_admin = local_user_view
|
||||
.as_ref()
|
||||
|
|
|
@ -15,14 +15,14 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn remove_community(
|
||||
data: Json<RemoveCommunity>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommunityResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommunityResponse>> {
|
||||
check_community_mod_action(
|
||||
&local_user_view.person,
|
||||
data.community_id,
|
||||
|
|
|
@ -25,7 +25,7 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
||||
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
|
||||
utils::{slurs::check_slurs_opt, validation::is_valid_body_field},
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,7 @@ pub async fn update_community(
|
|||
data: Json<EditCommunity>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommunityResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CommunityResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||
|
|
|
@ -11,14 +11,14 @@ use lemmy_db_schema::source::{
|
|||
local_site::LocalSite,
|
||||
};
|
||||
use lemmy_db_views::structs::{CustomEmojiView, LocalUserView};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn create_custom_emoji(
|
||||
data: Json<CreateCustomEmoji>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CustomEmojiResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CustomEmojiResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
// Make sure user is an admin
|
||||
is_admin(&local_user_view)?;
|
||||
|
|
|
@ -8,14 +8,14 @@ use lemmy_api_common::{
|
|||
};
|
||||
use lemmy_db_schema::source::custom_emoji::CustomEmoji;
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn delete_custom_emoji(
|
||||
data: Json<DeleteCustomEmoji>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<SuccessResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<SuccessResponse>> {
|
||||
// Make sure user is an admin
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
|
|
|
@ -11,14 +11,14 @@ use lemmy_db_schema::source::{
|
|||
local_site::LocalSite,
|
||||
};
|
||||
use lemmy_db_views::structs::{CustomEmojiView, LocalUserView};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn update_custom_emoji(
|
||||
data: Json<EditCustomEmoji>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CustomEmojiResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<CustomEmojiResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
// Make sure user is an admin
|
||||
is_admin(&local_user_view)?;
|
||||
|
|
|
@ -32,7 +32,7 @@ use lemmy_db_schema::{
|
|||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_db_views_actor::structs::CommunityModeratorView;
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
||||
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
|
||||
spawn_try_task,
|
||||
utils::{
|
||||
slurs::check_slurs,
|
||||
|
@ -55,7 +55,7 @@ pub async fn create_post(
|
|||
data: Json<CreatePost>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PostResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PostResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
honeypot_check(&data.honeypot)?;
|
||||
|
|
|
@ -12,14 +12,14 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn delete_post(
|
||||
data: Json<DeletePost>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PostResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PostResponse>> {
|
||||
let post_id = data.post_id;
|
||||
let orig_post = Post::read(&mut context.pool(), post_id).await?;
|
||||
|
||||
|
|
|
@ -14,14 +14,14 @@ use lemmy_db_views::{
|
|||
structs::{LocalUserView, PostView, SiteView},
|
||||
};
|
||||
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn get_post(
|
||||
data: Query<GetPost>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: Option<LocalUserView>,
|
||||
) -> Result<Json<GetPostResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<GetPostResponse>> {
|
||||
let local_site = SiteView::read_local(&mut context.pool()).await?;
|
||||
|
||||
check_private_instance(&local_user_view, &local_site.local_site)?;
|
||||
|
|
|
@ -16,14 +16,14 @@ use lemmy_db_schema::{
|
|||
traits::{Crud, Reportable},
|
||||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn remove_post(
|
||||
data: Json<RemovePost>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PostResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PostResponse>> {
|
||||
let post_id = data.post_id;
|
||||
let orig_post = Post::read(&mut context.pool(), post_id).await?;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
||||
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
|
||||
utils::{
|
||||
slurs::check_slurs_opt,
|
||||
validation::{
|
||||
|
@ -45,7 +45,7 @@ pub async fn update_post(
|
|||
data: Json<EditPost>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PostResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PostResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
// TODO No good way to handle a clear.
|
||||
|
|
|
@ -24,7 +24,7 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::{LocalUserView, PrivateMessageView};
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
||||
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
|
||||
utils::{markdown::markdown_to_html, validation::is_valid_body_field},
|
||||
};
|
||||
|
||||
|
@ -33,7 +33,7 @@ pub async fn create_private_message(
|
|||
data: Json<CreatePrivateMessage>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PrivateMessageResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PrivateMessageResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||
|
|
|
@ -10,14 +10,14 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_db_views::structs::{LocalUserView, PrivateMessageView};
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn delete_private_message(
|
||||
data: Json<DeletePrivateMessage>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PrivateMessageResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PrivateMessageResponse>> {
|
||||
// Checking permissions
|
||||
let private_message_id = data.private_message_id;
|
||||
let orig_private_message = PrivateMessage::read(&mut context.pool(), private_message_id).await?;
|
||||
|
|
|
@ -4,14 +4,14 @@ use lemmy_api_common::{
|
|||
private_message::{GetPrivateMessages, PrivateMessagesResponse},
|
||||
};
|
||||
use lemmy_db_views::{private_message_view::PrivateMessageQuery, structs::LocalUserView};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn get_private_message(
|
||||
data: Query<GetPrivateMessages>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PrivateMessagesResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PrivateMessagesResponse>> {
|
||||
let person_id = local_user_view.person.id;
|
||||
|
||||
let page = data.page;
|
||||
|
|
|
@ -16,7 +16,7 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_db_views::structs::{LocalUserView, PrivateMessageView};
|
||||
use lemmy_utils::{
|
||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
||||
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
|
||||
utils::validation::is_valid_body_field,
|
||||
};
|
||||
|
||||
|
@ -25,7 +25,7 @@ pub async fn update_private_message(
|
|||
data: Json<EditPrivateMessage>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<PrivateMessageResponse>, LemmyError> {
|
||||
) -> LemmyResult<Json<PrivateMessageResponse>> {
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
// Checking permissions
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue