Search combined (#5271)

* Renaming person_mention to person_comment_mention.

* Finishing up post body mentions.

* Combined tables try 2

* Finishing up combined report table.

* Fix ts optionals.

* Adding tests, triggers, and history updates for report_combined.

* Adding profile.

* Add cursor pagination to report_combined view (#5244)

* add pagination cursor

* store timestamp instead of id in cursor (partial)

* Revert "store timestamp instead of id in cursor (partial)"

This reverts commit 89359dde4b.

* use paginated query builder

* Fixing migration and paged API.

* Using dullbananas trigger procedure

* Removing pointless list routes, reorganizing tests.

* Fixing column XOR check.

* Forgot to remove list report actions.

* Cleanup.

* Use internal tagging.

* Fixing api tests.

* Adding a few indexes.

* Fixing migration name.

* Fixing unique constraints.

* Addressing PR comments.

* Start working on profile combined

* Adding views and replaceable schema.

* A few changes to profile view.

- Separating the profile fetch from its combined content fetch.
- Starting to separate saved_only into its own combined view.

* Finishing up combined person_saved and person_content.

* Fixing api tests.

* Moving to api-v4 routes.

* Fixing imports.

* Update crates/db_views/src/report_combined_view.rs

Co-authored-by: dullbananas <dull.bananas0@gmail.com>

* Update crates/db_views/src/report_combined_view.rs

Co-authored-by: dullbananas <dull.bananas0@gmail.com>

* Update crates/db_views/src/report_combined_view.rs

Co-authored-by: dullbananas <dull.bananas0@gmail.com>

* Update migrations/2024-12-02-181601_add_report_combined_table/up.sql

Co-authored-by: dullbananas <dull.bananas0@gmail.com>

* Update migrations/2024-12-02-181601_add_report_combined_table/up.sql

Co-authored-by: dullbananas <dull.bananas0@gmail.com>

* Fixing import and fmt.

* Fixing null types in postgres.

* Comment out err.

* Fixing TS issues.

* Adding types, fixing allow and blocklist crud.

* Starting to work on combined views.

* Using dullbananas trigger procedure

* Adding the full combined view queries.

* Adding tests.

* taplo fmt.

* Upgrading package.json deps.

* Updating pnpm

* Most of the bulk work done, need to add tests yet.

* Finishing up inbox.

* Using assert_length

* Fixing sql_format.

* Running fmt.

* Fixing cargo shear.

* Fixing clippy.

* Addressing PR comments.

* Starting to work on search combined.

* Fix

* Removing serialization

* Removing serialization

* Moving db_views_actor and _moderator into db_views.

- This is necessary because the combined views use both, and that
  separation was arbitrary to begin with. db_schema has no such crate
  separation.

* Adding search combined view, need to write tests yet.

* Filters done, working on tests.

* Adding tests for person, post, and community.

* Finishing up tests.

* Fixing duped trigger.

* Remove saved_only test.

* Remove pointless post_tags types.

* Remove pointless index.

* Changing published to saved for person_saved_combined.

* Removing comment.

* Renaming modlog when_ columns to published.

- Fixes #5312

* Adding strum and simplifying imports.

* Avoiding clone in map_to_enum

* Changing modded_person to other_person.

* Update crates/db_views_moderator/src/modlog_combined_view.rs

Co-authored-by: dullbananas <dull.bananas0@gmail.com>

* Update crates/db_views_moderator/src/modlog_combined_view.rs

Co-authored-by: dullbananas <dull.bananas0@gmail.com>

* Update crates/db_views_moderator/src/modlog_combined_view.rs

Co-authored-by: dullbananas <dull.bananas0@gmail.com>

* Addressing PR comments.

* Fixing split.

* Revert "Adding strum and simplifying imports."

This reverts commit 15f1671107.

* Running fmt.

* Using assert + matches instead of filter_map.

* Adding listPersonContent check.

* Updating lemmy-js-client

* Fixing mark all as read route, changing mark read to SuccessResponse.

* Adding post body mention api test, fixing api tests.

* Fixing route locations, and api tests.

* Formatting sql.

* Formatting sql 2.

* Fixing search result, running clippy.

* Fixing ts_option.

* Adding search_combined.score column, and DB triggers.

* Fixing API tests.

* Adding an index for score.

* Update crates/db_schema/src/newtypes.rs

Co-authored-by: dullbananas <dull.bananas0@gmail.com>

* Avoiding inner joins for up.sql

* Adding person_aggregates.published column.

---------

Co-authored-by: dullbananas <dull.bananas0@gmail.com>
This commit is contained in:
Dessalines 2025-01-27 22:58:19 -05:00 committed by GitHub
parent aa3f4f07e3
commit 52047459bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
126 changed files with 2418 additions and 1183 deletions

47
Cargo.lock generated
View file

@ -2566,8 +2566,6 @@ dependencies = [
"lemmy_api_crud",
"lemmy_db_schema",
"lemmy_db_views",
"lemmy_db_views_actor",
"lemmy_db_views_moderator",
"lemmy_utils",
"pretty_assertions",
"serial_test",
@ -2594,8 +2592,6 @@ dependencies = [
"jsonwebtoken",
"lemmy_db_schema",
"lemmy_db_views",
"lemmy_db_views_actor",
"lemmy_db_views_moderator",
"lemmy_utils",
"mime",
"mime_guess",
@ -2632,7 +2628,6 @@ dependencies = [
"lemmy_api_common",
"lemmy_db_schema",
"lemmy_db_views",
"lemmy_db_views_actor",
"lemmy_utils",
"regex",
"serde",
@ -2662,7 +2657,6 @@ dependencies = [
"lemmy_api_common",
"lemmy_db_schema",
"lemmy_db_views",
"lemmy_db_views_actor",
"lemmy_utils",
"moka",
"pretty_assertions",
@ -2753,6 +2747,7 @@ dependencies = [
"serde_json",
"serde_with",
"serial_test",
"strum",
"test-context",
"tokio",
"tracing",
@ -2760,43 +2755,6 @@ dependencies = [
"url",
]
[[package]]
name = "lemmy_db_views_actor"
version = "0.19.6-beta.7"
dependencies = [
"chrono",
"diesel",
"diesel-async",
"i-love-jesus",
"lemmy_db_schema",
"lemmy_utils",
"pretty_assertions",
"serde",
"serde_with",
"serial_test",
"strum",
"tokio",
"ts-rs",
"url",
]
[[package]]
name = "lemmy_db_views_moderator"
version = "0.19.6-beta.7"
dependencies = [
"diesel",
"diesel-async",
"i-love-jesus",
"lemmy_db_schema",
"lemmy_utils",
"pretty_assertions",
"serde",
"serde_with",
"serial_test",
"tokio",
"ts-rs",
]
[[package]]
name = "lemmy_federate"
version = "0.19.6-beta.7"
@ -2812,7 +2770,7 @@ dependencies = [
"lemmy_api_common",
"lemmy_apub",
"lemmy_db_schema",
"lemmy_db_views_actor",
"lemmy_db_views",
"lemmy_utils",
"mockall",
"moka",
@ -2847,7 +2805,6 @@ dependencies = [
"lemmy_api_common",
"lemmy_db_schema",
"lemmy_db_views",
"lemmy_db_views_actor",
"lemmy_utils",
"pretty_assertions",
"prometheus",

View file

@ -49,8 +49,6 @@ members = [
"crates/db_perf",
"crates/db_schema",
"crates/db_views",
"crates/db_views_actor",
"crates/db_views_actor",
"crates/routes",
"crates/federate",
]
@ -90,8 +88,6 @@ lemmy_db_schema = { version = "=0.19.6-beta.7", path = "./crates/db_schema" }
lemmy_api_common = { version = "=0.19.6-beta.7", path = "./crates/api_common" }
lemmy_routes = { version = "=0.19.6-beta.7", path = "./crates/routes" }
lemmy_db_views = { version = "=0.19.6-beta.7", path = "./crates/db_views" }
lemmy_db_views_actor = { version = "=0.19.6-beta.7", path = "./crates/db_views_actor" }
lemmy_db_views_moderator = { version = "=0.19.6-beta.7", path = "./crates/db_views_moderator" }
lemmy_federate = { version = "=0.19.6-beta.7", path = "./crates/federate" }
activitypub_federation = { version = "0.6.1", default-features = false, features = [
"actix-web",

View file

@ -22,16 +22,16 @@
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/node": "^22.10.6",
"@typescript-eslint/eslint-plugin": "^8.20.0",
"@typescript-eslint/parser": "^8.20.0",
"@types/node": "^22.10.7",
"@typescript-eslint/eslint-plugin": "^8.21.0",
"@typescript-eslint/parser": "^8.21.0",
"eslint": "^9.18.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-prettier": "^5.2.3",
"jest": "^29.5.0",
"lemmy-js-client": "0.20.0-inbox-combined.1",
"lemmy-js-client": "0.20.0-search-combined.1",
"prettier": "^3.4.2",
"ts-jest": "^29.1.0",
"typescript": "^5.7.3",
"typescript-eslint": "^8.20.0"
"typescript-eslint": "^8.21.0"
}
}

View file

@ -12,38 +12,38 @@ importers:
specifier: ^29.5.12
version: 29.5.14
'@types/node':
specifier: ^22.10.6
version: 22.10.6
specifier: ^22.10.7
version: 22.10.7
'@typescript-eslint/eslint-plugin':
specifier: ^8.20.0
version: 8.20.0(@typescript-eslint/parser@8.20.0(eslint@9.18.0)(typescript@5.7.3))(eslint@9.18.0)(typescript@5.7.3)
specifier: ^8.21.0
version: 8.21.0(@typescript-eslint/parser@8.21.0(eslint@9.18.0)(typescript@5.7.3))(eslint@9.18.0)(typescript@5.7.3)
'@typescript-eslint/parser':
specifier: ^8.20.0
version: 8.20.0(eslint@9.18.0)(typescript@5.7.3)
specifier: ^8.21.0
version: 8.21.0(eslint@9.18.0)(typescript@5.7.3)
eslint:
specifier: ^9.18.0
version: 9.18.0
eslint-plugin-prettier:
specifier: ^5.1.3
version: 5.2.1(eslint@9.18.0)(prettier@3.4.2)
specifier: ^5.2.3
version: 5.2.3(eslint@9.18.0)(prettier@3.4.2)
jest:
specifier: ^29.5.0
version: 29.7.0(@types/node@22.10.6)
version: 29.7.0(@types/node@22.10.7)
lemmy-js-client:
specifier: 0.20.0-inbox-combined.1
version: 0.20.0-inbox-combined.1
specifier: 0.20.0-search-combined.1
version: 0.20.0-search-combined.1
prettier:
specifier: ^3.4.2
version: 3.4.2
ts-jest:
specifier: ^29.1.0
version: 29.2.5(@babel/core@7.23.9)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.23.9))(jest@29.7.0(@types/node@22.10.6))(typescript@5.7.3)
version: 29.2.5(@babel/core@7.23.9)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.23.9))(jest@29.7.0(@types/node@22.10.7))(typescript@5.7.3)
typescript:
specifier: ^5.7.3
version: 5.7.3
typescript-eslint:
specifier: ^8.20.0
version: 8.20.0(eslint@9.18.0)(typescript@5.7.3)
specifier: ^8.21.0
version: 8.21.0(eslint@9.18.0)(typescript@5.7.3)
packages:
@ -422,8 +422,8 @@ packages:
'@types/json-schema@7.0.15':
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
'@types/node@22.10.6':
resolution: {integrity: sha512-qNiuwC4ZDAUNcY47xgaSuS92cjf8JbSUoaKS77bmLG1rU7MlATVSiw/IlrjtIyyskXBZ8KkNfjK/P5na7rgXbQ==}
'@types/node@22.10.7':
resolution: {integrity: sha512-V09KvXxFiutGp6B7XkpaDXlNadZxrzajcY50EuoLIpQ6WWYCSvf19lVIazzfIzQvhUN2HjX12spLojTnhuKlGg==}
'@types/stack-utils@2.0.3':
resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==}
@ -434,51 +434,51 @@ packages:
'@types/yargs@17.0.32':
resolution: {integrity: sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog==}
'@typescript-eslint/eslint-plugin@8.20.0':
resolution: {integrity: sha512-naduuphVw5StFfqp4Gq4WhIBE2gN1GEmMUExpJYknZJdRnc+2gDzB8Z3+5+/Kv33hPQRDGzQO/0opHE72lZZ6A==}
'@typescript-eslint/eslint-plugin@8.21.0':
resolution: {integrity: sha512-eTH+UOR4I7WbdQnG4Z48ebIA6Bgi7WO8HvFEneeYBxG8qCOYgTOFPSg6ek9ITIDvGjDQzWHcoWHCDO2biByNzA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
'@typescript-eslint/parser': ^8.0.0 || ^8.0.0-alpha.0
eslint: ^8.57.0 || ^9.0.0
typescript: '>=4.8.4 <5.8.0'
'@typescript-eslint/parser@8.20.0':
resolution: {integrity: sha512-gKXG7A5HMyjDIedBi6bUrDcun8GIjnI8qOwVLiY3rx6T/sHP/19XLJOnIq/FgQvWLHja5JN/LSE7eklNBr612g==}
'@typescript-eslint/parser@8.21.0':
resolution: {integrity: sha512-Wy+/sdEH9kI3w9civgACwabHbKl+qIOu0uFZ9IMKzX3Jpv9og0ZBJrZExGrPpFAY7rWsXuxs5e7CPPP17A4eYA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
typescript: '>=4.8.4 <5.8.0'
'@typescript-eslint/scope-manager@8.20.0':
resolution: {integrity: sha512-J7+VkpeGzhOt3FeG1+SzhiMj9NzGD/M6KoGn9f4dbz3YzK9hvbhVTmLj/HiTp9DazIzJ8B4XcM80LrR9Dm1rJw==}
'@typescript-eslint/scope-manager@8.21.0':
resolution: {integrity: sha512-G3IBKz0/0IPfdeGRMbp+4rbjfSSdnGkXsM/pFZA8zM9t9klXDnB/YnKOBQ0GoPmoROa4bCq2NeHgJa5ydsQ4mA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@typescript-eslint/type-utils@8.20.0':
resolution: {integrity: sha512-bPC+j71GGvA7rVNAHAtOjbVXbLN5PkwqMvy1cwGeaxUoRQXVuKCebRoLzm+IPW/NtFFpstn1ummSIasD5t60GA==}
'@typescript-eslint/type-utils@8.21.0':
resolution: {integrity: sha512-95OsL6J2BtzoBxHicoXHxgk3z+9P3BEcQTpBKriqiYzLKnM2DeSqs+sndMKdamU8FosiadQFT3D+BSL9EKnAJQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
typescript: '>=4.8.4 <5.8.0'
'@typescript-eslint/types@8.20.0':
resolution: {integrity: sha512-cqaMiY72CkP+2xZRrFt3ExRBu0WmVitN/rYPZErA80mHjHx/Svgp8yfbzkJmDoQ/whcytOPO9/IZXnOc+wigRA==}
'@typescript-eslint/types@8.21.0':
resolution: {integrity: sha512-PAL6LUuQwotLW2a8VsySDBwYMm129vFm4tMVlylzdoTybTHaAi0oBp7Ac6LhSrHHOdLM3efH+nAR6hAWoMF89A==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@typescript-eslint/typescript-estree@8.20.0':
resolution: {integrity: sha512-Y7ncuy78bJqHI35NwzWol8E0X7XkRVS4K4P4TCyzWkOJih5NDvtoRDW4Ba9YJJoB2igm9yXDdYI/+fkiiAxPzA==}
'@typescript-eslint/typescript-estree@8.21.0':
resolution: {integrity: sha512-x+aeKh/AjAArSauz0GiQZsjT8ciadNMHdkUSwBB9Z6PrKc/4knM4g3UfHml6oDJmKC88a6//cdxnO/+P2LkMcg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
typescript: '>=4.8.4 <5.8.0'
'@typescript-eslint/utils@8.20.0':
resolution: {integrity: sha512-dq70RUw6UK9ei7vxc4KQtBRk7qkHZv447OUZ6RPQMQl71I3NZxQJX/f32Smr+iqWrB02pHKn2yAdHBb0KNrRMA==}
'@typescript-eslint/utils@8.21.0':
resolution: {integrity: sha512-xcXBfcq0Kaxgj7dwejMbFyq7IOHgpNMtVuDveK7w3ZGwG9owKzhALVwKpTF2yrZmEwl9SWdetf3fxNzJQaVuxw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
typescript: '>=4.8.4 <5.8.0'
'@typescript-eslint/visitor-keys@8.20.0':
resolution: {integrity: sha512-v/BpkeeYAsPkKCkR8BDwcno0llhzWVqPOamQrAEMdpZav2Y9OVjd9dwJyBLJWwf335B5DmlifECIkZRJCaGaHA==}
'@typescript-eslint/visitor-keys@8.21.0':
resolution: {integrity: sha512-BkLMNpdV6prozk8LlyK/SOoWLmUFi+ZD+pcqti9ILCbVvHGk1ui1g4jJOc2WDLaeExz2qWwojxlPce5PljcT3w==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
acorn-jsx@5.3.2:
@ -709,8 +709,8 @@ packages:
resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==}
engines: {node: '>=10'}
eslint-plugin-prettier@5.2.1:
resolution: {integrity: sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==}
eslint-plugin-prettier@5.2.3:
resolution: {integrity: sha512-qJ+y0FfCp/mQYQ/vWQ3s7eUlFEL4PyKfAJxsnYTJ4YT73nsJBWqmEpFryxV9OeUiqmsTsYJ5Y+KDNaeP31wrRw==}
engines: {node: ^14.18.0 || >=16.0.0}
peerDependencies:
'@types/eslint': '>=8.0.0'
@ -1157,8 +1157,8 @@ packages:
resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==}
engines: {node: '>=6'}
lemmy-js-client@0.20.0-inbox-combined.1:
resolution: {integrity: sha512-sFJJePXdMHIVQwCa3fN+nIcIvfD7ZbBEZn08fmITXEA6/qbJLvZGWG/rEcRNkZM+lRKnhfrZihWKx1AHZE9wqA==}
lemmy-js-client@0.20.0-search-combined.1:
resolution: {integrity: sha512-K4bk6r+26lxZqL8WKiJlqfZb+ZnhNrZz1gAQTb4FQkGXQLFeqQ41ZyGmQZzjX+NPy7O9mt9d9d7zI8t/QYJ82Q==}
leven@3.1.0:
resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==}
@ -1528,8 +1528,8 @@ packages:
resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==}
engines: {node: '>=10'}
typescript-eslint@8.20.0:
resolution: {integrity: sha512-Kxz2QRFsgbWj6Xcftlw3Dd154b3cEPFqQC+qMZrMypSijPd4UanKKvoKDrJ4o8AIfZFKAF+7sMaEIR8mTElozA==}
typescript-eslint@8.21.0:
resolution: {integrity: sha512-txEKYY4XMKwPXxNkN8+AxAdX6iIJAPiJbHE/FpQccs/sxw8Lf26kqwC3cn0xkHlW8kEbLhkhCsjWuMveaY9Rxw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
@ -1869,7 +1869,7 @@ snapshots:
'@jest/console@29.7.0':
dependencies:
'@jest/types': 29.6.3
'@types/node': 22.10.6
'@types/node': 22.10.7
chalk: 4.1.2
jest-message-util: 29.7.0
jest-util: 29.7.0
@ -1882,14 +1882,14 @@ snapshots:
'@jest/test-result': 29.7.0
'@jest/transform': 29.7.0
'@jest/types': 29.6.3
'@types/node': 22.10.6
'@types/node': 22.10.7
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@22.10.6)
jest-config: 29.7.0(@types/node@22.10.7)
jest-haste-map: 29.7.0
jest-message-util: 29.7.0
jest-regex-util: 29.6.3
@ -1914,7 +1914,7 @@ snapshots:
dependencies:
'@jest/fake-timers': 29.7.0
'@jest/types': 29.6.3
'@types/node': 22.10.6
'@types/node': 22.10.7
jest-mock: 29.7.0
'@jest/expect-utils@29.7.0':
@ -1932,7 +1932,7 @@ snapshots:
dependencies:
'@jest/types': 29.6.3
'@sinonjs/fake-timers': 10.3.0
'@types/node': 22.10.6
'@types/node': 22.10.7
jest-message-util: 29.7.0
jest-mock: 29.7.0
jest-util: 29.7.0
@ -1954,7 +1954,7 @@ snapshots:
'@jest/transform': 29.7.0
'@jest/types': 29.6.3
'@jridgewell/trace-mapping': 0.3.22
'@types/node': 22.10.6
'@types/node': 22.10.7
chalk: 4.1.2
collect-v8-coverage: 1.0.2
exit: 0.1.2
@ -2024,7 +2024,7 @@ snapshots:
'@jest/schemas': 29.6.3
'@types/istanbul-lib-coverage': 2.0.6
'@types/istanbul-reports': 3.0.4
'@types/node': 22.10.6
'@types/node': 22.10.7
'@types/yargs': 17.0.32
chalk: 4.1.2
@ -2094,7 +2094,7 @@ snapshots:
'@types/graceful-fs@4.1.9':
dependencies:
'@types/node': 22.10.6
'@types/node': 22.10.7
'@types/istanbul-lib-coverage@2.0.6': {}
@ -2113,7 +2113,7 @@ snapshots:
'@types/json-schema@7.0.15': {}
'@types/node@22.10.6':
'@types/node@22.10.7':
dependencies:
undici-types: 6.20.0
@ -2125,14 +2125,14 @@ snapshots:
dependencies:
'@types/yargs-parser': 21.0.3
'@typescript-eslint/eslint-plugin@8.20.0(@typescript-eslint/parser@8.20.0(eslint@9.18.0)(typescript@5.7.3))(eslint@9.18.0)(typescript@5.7.3)':
'@typescript-eslint/eslint-plugin@8.21.0(@typescript-eslint/parser@8.21.0(eslint@9.18.0)(typescript@5.7.3))(eslint@9.18.0)(typescript@5.7.3)':
dependencies:
'@eslint-community/regexpp': 4.12.1
'@typescript-eslint/parser': 8.20.0(eslint@9.18.0)(typescript@5.7.3)
'@typescript-eslint/scope-manager': 8.20.0
'@typescript-eslint/type-utils': 8.20.0(eslint@9.18.0)(typescript@5.7.3)
'@typescript-eslint/utils': 8.20.0(eslint@9.18.0)(typescript@5.7.3)
'@typescript-eslint/visitor-keys': 8.20.0
'@typescript-eslint/parser': 8.21.0(eslint@9.18.0)(typescript@5.7.3)
'@typescript-eslint/scope-manager': 8.21.0
'@typescript-eslint/type-utils': 8.21.0(eslint@9.18.0)(typescript@5.7.3)
'@typescript-eslint/utils': 8.21.0(eslint@9.18.0)(typescript@5.7.3)
'@typescript-eslint/visitor-keys': 8.21.0
eslint: 9.18.0
graphemer: 1.4.0
ignore: 5.3.2
@ -2142,27 +2142,27 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@typescript-eslint/parser@8.20.0(eslint@9.18.0)(typescript@5.7.3)':
'@typescript-eslint/parser@8.21.0(eslint@9.18.0)(typescript@5.7.3)':
dependencies:
'@typescript-eslint/scope-manager': 8.20.0
'@typescript-eslint/types': 8.20.0
'@typescript-eslint/typescript-estree': 8.20.0(typescript@5.7.3)
'@typescript-eslint/visitor-keys': 8.20.0
'@typescript-eslint/scope-manager': 8.21.0
'@typescript-eslint/types': 8.21.0
'@typescript-eslint/typescript-estree': 8.21.0(typescript@5.7.3)
'@typescript-eslint/visitor-keys': 8.21.0
debug: 4.4.0
eslint: 9.18.0
typescript: 5.7.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/scope-manager@8.20.0':
'@typescript-eslint/scope-manager@8.21.0':
dependencies:
'@typescript-eslint/types': 8.20.0
'@typescript-eslint/visitor-keys': 8.20.0
'@typescript-eslint/types': 8.21.0
'@typescript-eslint/visitor-keys': 8.21.0
'@typescript-eslint/type-utils@8.20.0(eslint@9.18.0)(typescript@5.7.3)':
'@typescript-eslint/type-utils@8.21.0(eslint@9.18.0)(typescript@5.7.3)':
dependencies:
'@typescript-eslint/typescript-estree': 8.20.0(typescript@5.7.3)
'@typescript-eslint/utils': 8.20.0(eslint@9.18.0)(typescript@5.7.3)
'@typescript-eslint/typescript-estree': 8.21.0(typescript@5.7.3)
'@typescript-eslint/utils': 8.21.0(eslint@9.18.0)(typescript@5.7.3)
debug: 4.4.0
eslint: 9.18.0
ts-api-utils: 2.0.0(typescript@5.7.3)
@ -2170,12 +2170,12 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@typescript-eslint/types@8.20.0': {}
'@typescript-eslint/types@8.21.0': {}
'@typescript-eslint/typescript-estree@8.20.0(typescript@5.7.3)':
'@typescript-eslint/typescript-estree@8.21.0(typescript@5.7.3)':
dependencies:
'@typescript-eslint/types': 8.20.0
'@typescript-eslint/visitor-keys': 8.20.0
'@typescript-eslint/types': 8.21.0
'@typescript-eslint/visitor-keys': 8.21.0
debug: 4.4.0
fast-glob: 3.3.3
is-glob: 4.0.3
@ -2186,20 +2186,20 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@typescript-eslint/utils@8.20.0(eslint@9.18.0)(typescript@5.7.3)':
'@typescript-eslint/utils@8.21.0(eslint@9.18.0)(typescript@5.7.3)':
dependencies:
'@eslint-community/eslint-utils': 4.4.1(eslint@9.18.0)
'@typescript-eslint/scope-manager': 8.20.0
'@typescript-eslint/types': 8.20.0
'@typescript-eslint/typescript-estree': 8.20.0(typescript@5.7.3)
'@typescript-eslint/scope-manager': 8.21.0
'@typescript-eslint/types': 8.21.0
'@typescript-eslint/typescript-estree': 8.21.0(typescript@5.7.3)
eslint: 9.18.0
typescript: 5.7.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/visitor-keys@8.20.0':
'@typescript-eslint/visitor-keys@8.21.0':
dependencies:
'@typescript-eslint/types': 8.20.0
'@typescript-eslint/types': 8.21.0
eslint-visitor-keys: 4.2.0
acorn-jsx@5.3.2(acorn@8.14.0):
@ -2367,13 +2367,13 @@ snapshots:
convert-source-map@2.0.0: {}
create-jest@29.7.0(@types/node@22.10.6):
create-jest@29.7.0(@types/node@22.10.7):
dependencies:
'@jest/types': 29.6.3
chalk: 4.1.2
exit: 0.1.2
graceful-fs: 4.2.11
jest-config: 29.7.0(@types/node@22.10.6)
jest-config: 29.7.0(@types/node@22.10.7)
jest-util: 29.7.0
prompts: 2.4.2
transitivePeerDependencies:
@ -2428,7 +2428,7 @@ snapshots:
escape-string-regexp@4.0.0: {}
eslint-plugin-prettier@5.2.1(eslint@9.18.0)(prettier@3.4.2):
eslint-plugin-prettier@5.2.3(eslint@9.18.0)(prettier@3.4.2):
dependencies:
eslint: 9.18.0
prettier: 3.4.2
@ -2735,7 +2735,7 @@ snapshots:
'@jest/expect': 29.7.0
'@jest/test-result': 29.7.0
'@jest/types': 29.6.3
'@types/node': 22.10.6
'@types/node': 22.10.7
chalk: 4.1.2
co: 4.6.0
dedent: 1.5.1
@ -2755,16 +2755,16 @@ snapshots:
- babel-plugin-macros
- supports-color
jest-cli@29.7.0(@types/node@22.10.6):
jest-cli@29.7.0(@types/node@22.10.7):
dependencies:
'@jest/core': 29.7.0
'@jest/test-result': 29.7.0
'@jest/types': 29.6.3
chalk: 4.1.2
create-jest: 29.7.0(@types/node@22.10.6)
create-jest: 29.7.0(@types/node@22.10.7)
exit: 0.1.2
import-local: 3.1.0
jest-config: 29.7.0(@types/node@22.10.6)
jest-config: 29.7.0(@types/node@22.10.7)
jest-util: 29.7.0
jest-validate: 29.7.0
yargs: 17.7.2
@ -2774,7 +2774,7 @@ snapshots:
- supports-color
- ts-node
jest-config@29.7.0(@types/node@22.10.6):
jest-config@29.7.0(@types/node@22.10.7):
dependencies:
'@babel/core': 7.23.9
'@jest/test-sequencer': 29.7.0
@ -2799,7 +2799,7 @@ snapshots:
slash: 3.0.0
strip-json-comments: 3.1.1
optionalDependencies:
'@types/node': 22.10.6
'@types/node': 22.10.7
transitivePeerDependencies:
- babel-plugin-macros
- supports-color
@ -2828,7 +2828,7 @@ snapshots:
'@jest/environment': 29.7.0
'@jest/fake-timers': 29.7.0
'@jest/types': 29.6.3
'@types/node': 22.10.6
'@types/node': 22.10.7
jest-mock: 29.7.0
jest-util: 29.7.0
@ -2838,7 +2838,7 @@ snapshots:
dependencies:
'@jest/types': 29.6.3
'@types/graceful-fs': 4.1.9
'@types/node': 22.10.6
'@types/node': 22.10.7
anymatch: 3.1.3
fb-watchman: 2.0.2
graceful-fs: 4.2.11
@ -2877,7 +2877,7 @@ snapshots:
jest-mock@29.7.0:
dependencies:
'@jest/types': 29.6.3
'@types/node': 22.10.6
'@types/node': 22.10.7
jest-util: 29.7.0
jest-pnp-resolver@1.2.3(jest-resolve@29.7.0):
@ -2912,7 +2912,7 @@ snapshots:
'@jest/test-result': 29.7.0
'@jest/transform': 29.7.0
'@jest/types': 29.6.3
'@types/node': 22.10.6
'@types/node': 22.10.7
chalk: 4.1.2
emittery: 0.13.1
graceful-fs: 4.2.11
@ -2940,7 +2940,7 @@ snapshots:
'@jest/test-result': 29.7.0
'@jest/transform': 29.7.0
'@jest/types': 29.6.3
'@types/node': 22.10.6
'@types/node': 22.10.7
chalk: 4.1.2
cjs-module-lexer: 1.2.3
collect-v8-coverage: 1.0.2
@ -2986,7 +2986,7 @@ snapshots:
jest-util@29.7.0:
dependencies:
'@jest/types': 29.6.3
'@types/node': 22.10.6
'@types/node': 22.10.7
chalk: 4.1.2
ci-info: 3.9.0
graceful-fs: 4.2.11
@ -3005,7 +3005,7 @@ snapshots:
dependencies:
'@jest/test-result': 29.7.0
'@jest/types': 29.6.3
'@types/node': 22.10.6
'@types/node': 22.10.7
ansi-escapes: 4.3.2
chalk: 4.1.2
emittery: 0.13.1
@ -3014,17 +3014,17 @@ snapshots:
jest-worker@29.7.0:
dependencies:
'@types/node': 22.10.6
'@types/node': 22.10.7
jest-util: 29.7.0
merge-stream: 2.0.0
supports-color: 8.1.1
jest@29.7.0(@types/node@22.10.6):
jest@29.7.0(@types/node@22.10.7):
dependencies:
'@jest/core': 29.7.0
'@jest/types': 29.6.3
import-local: 3.1.0
jest-cli: 29.7.0(@types/node@22.10.6)
jest-cli: 29.7.0(@types/node@22.10.7)
transitivePeerDependencies:
- '@types/node'
- babel-plugin-macros
@ -3060,7 +3060,7 @@ snapshots:
kleur@3.0.3: {}
lemmy-js-client@0.20.0-inbox-combined.1: {}
lemmy-js-client@0.20.0-search-combined.1: {}
leven@3.1.0: {}
@ -3339,12 +3339,12 @@ snapshots:
dependencies:
typescript: 5.7.3
ts-jest@29.2.5(@babel/core@7.23.9)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.23.9))(jest@29.7.0(@types/node@22.10.6))(typescript@5.7.3):
ts-jest@29.2.5(@babel/core@7.23.9)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.23.9))(jest@29.7.0(@types/node@22.10.7))(typescript@5.7.3):
dependencies:
bs-logger: 0.2.6
ejs: 3.1.10
fast-json-stable-stringify: 2.1.0
jest: 29.7.0(@types/node@22.10.6)
jest: 29.7.0(@types/node@22.10.7)
jest-util: 29.7.0
json5: 2.2.3
lodash.memoize: 4.1.2
@ -3368,11 +3368,11 @@ snapshots:
type-fest@0.21.3: {}
typescript-eslint@8.20.0(eslint@9.18.0)(typescript@5.7.3):
typescript-eslint@8.21.0(eslint@9.18.0)(typescript@5.7.3):
dependencies:
'@typescript-eslint/eslint-plugin': 8.20.0(@typescript-eslint/parser@8.20.0(eslint@9.18.0)(typescript@5.7.3))(eslint@9.18.0)(typescript@5.7.3)
'@typescript-eslint/parser': 8.20.0(eslint@9.18.0)(typescript@5.7.3)
'@typescript-eslint/utils': 8.20.0(eslint@9.18.0)(typescript@5.7.3)
'@typescript-eslint/eslint-plugin': 8.21.0(@typescript-eslint/parser@8.21.0(eslint@9.18.0)(typescript@5.7.3))(eslint@9.18.0)(typescript@5.7.3)
'@typescript-eslint/parser': 8.21.0(eslint@9.18.0)(typescript@5.7.3)
'@typescript-eslint/utils': 8.21.0(eslint@9.18.0)(typescript@5.7.3)
eslint: 9.18.0
typescript: 5.7.3
transitivePeerDependencies:

View file

@ -9,7 +9,7 @@ then
fi
export RUST_BACKTRACE=1
export RUST_LOG="warn,lemmy_server=$LEMMY_LOG_LEVEL,lemmy_federate=$LEMMY_LOG_LEVEL,lemmy_api=$LEMMY_LOG_LEVEL,lemmy_api_common=$LEMMY_LOG_LEVEL,lemmy_api_crud=$LEMMY_LOG_LEVEL,lemmy_apub=$LEMMY_LOG_LEVEL,lemmy_db_schema=$LEMMY_LOG_LEVEL,lemmy_db_views=$LEMMY_LOG_LEVEL,lemmy_db_views_actor=$LEMMY_LOG_LEVEL,lemmy_db_views_moderator=$LEMMY_LOG_LEVEL,lemmy_routes=$LEMMY_LOG_LEVEL,lemmy_utils=$LEMMY_LOG_LEVEL,lemmy_websocket=$LEMMY_LOG_LEVEL"
export RUST_LOG="warn,lemmy_server=$LEMMY_LOG_LEVEL,lemmy_federate=$LEMMY_LOG_LEVEL,lemmy_api=$LEMMY_LOG_LEVEL,lemmy_api_common=$LEMMY_LOG_LEVEL,lemmy_api_crud=$LEMMY_LOG_LEVEL,lemmy_apub=$LEMMY_LOG_LEVEL,lemmy_db_schema=$LEMMY_LOG_LEVEL,lemmy_db_views=$LEMMY_LOG_LEVEL,lemmy_routes=$LEMMY_LOG_LEVEL,lemmy_utils=$LEMMY_LOG_LEVEL,lemmy_websocket=$LEMMY_LOG_LEVEL"
export LEMMY_TEST_FAST_FEDERATION=1 # by default, the persistent federation queue has delays in the scale of 30s-5min

View file

@ -488,7 +488,7 @@ test("Dont receive community activities after unsubscribe", async () => {
// await longDelay();
let postResBeta = searchPostLocal(beta, postRes.post_view.post);
expect((await postResBeta).posts.length).toBe(0);
expect((await postResBeta).results.length).toBe(0);
});
test("Fetch community, includes posts", async () => {

View file

@ -324,9 +324,8 @@ export async function searchPostLocal(
post: Post,
): Promise<SearchResponse> {
let form: Search = {
q: post.name,
search_term: post.name,
type_: "Posts",
sort: "TopAll",
listing_type: "All",
};
return api.search(form);
@ -339,7 +338,7 @@ export async function waitForPost(
checker: (t: PostView | undefined) => boolean = p => !!p,
) {
return waitUntil<PostView>(
() => searchPostLocal(api, post).then(p => p.posts[0]),
() => searchPostLocal(api, post).then(p => p.results[0] as PostView),
checker,
);
}

View file

@ -21,8 +21,6 @@ workspace = true
lemmy_utils = { workspace = true }
lemmy_db_schema = { workspace = true, features = ["full"] }
lemmy_db_views = { workspace = true, features = ["full"] }
lemmy_db_views_moderator = { workspace = true, features = ["full"] }
lemmy_db_views_actor = { workspace = true, features = ["full"] }
lemmy_api_common = { workspace = true, features = ["full"] }
activitypub_federation = { workspace = true }
bcrypt = { workspace = true }

View file

@ -14,8 +14,7 @@ use lemmy_db_schema::{
},
traits::{Crud, Joinable},
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::CommunityModeratorView;
use lemmy_db_views::structs::{CommunityModeratorView, LocalUserView};
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
#[tracing::instrument(skip(context))]

View file

@ -24,8 +24,7 @@ use lemmy_db_schema::{
},
traits::{Bannable, Crud, Followable},
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::PersonView;
use lemmy_db_views::structs::{LocalUserView, PersonView};
use lemmy_utils::{
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
utils::validation::is_valid_body_field,

View file

@ -12,8 +12,7 @@ use lemmy_db_schema::{
},
traits::{Blockable, Followable},
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::CommunityView;
use lemmy_db_views::structs::{CommunityView, LocalUserView};
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
#[tracing::instrument(skip(context))]

View file

@ -14,8 +14,7 @@ use lemmy_db_schema::{
traits::{Crud, Followable},
CommunityVisibility,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::{CommunityPersonBanView, CommunityView};
use lemmy_db_views::structs::{CommunityPersonBanView, CommunityView, LocalUserView};
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
#[tracing::instrument(skip(context))]

View file

@ -4,8 +4,7 @@ use lemmy_api_common::{
context::LemmyContext,
utils::is_mod_or_admin,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::CommunityFollowerView;
use lemmy_db_views::structs::{CommunityFollowerView, LocalUserView};
use lemmy_utils::error::LemmyResult;
pub async fn get_pending_follows_count(

View file

@ -4,8 +4,7 @@ use lemmy_api_common::{
context::LemmyContext,
utils::check_community_mod_of_any_or_admin_action,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::CommunityFollowerView;
use lemmy_db_views::structs::{CommunityFollowerView, LocalUserView};
use lemmy_utils::error::LemmyResult;
pub async fn get_pending_follows_list(

View file

@ -10,8 +10,7 @@ use lemmy_db_schema::source::{
community::Community,
local_site::LocalSite,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::CommunityView;
use lemmy_db_views::structs::{CommunityView, LocalUserView};
use lemmy_utils::error::LemmyResult;
#[tracing::instrument(skip(context))]

View file

@ -12,8 +12,7 @@ use lemmy_db_schema::{
},
traits::{Crud, Joinable},
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
use lemmy_db_views::structs::{CommunityModeratorView, CommunityView, LocalUserView};
use lemmy_utils::{
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
location_info,

View file

@ -11,8 +11,7 @@ use lemmy_db_schema::{
},
traits::Crud,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::PersonView;
use lemmy_db_views::structs::{LocalUserView, PersonView};
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
#[tracing::instrument(skip(context))]

View file

@ -16,8 +16,7 @@ use lemmy_db_schema::{
},
traits::Crud,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::PersonView;
use lemmy_db_views::structs::{LocalUserView, PersonView};
use lemmy_utils::{
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
utils::validation::is_valid_body_field,

View file

@ -7,8 +7,7 @@ use lemmy_db_schema::{
source::person_block::{PersonBlock, PersonBlockForm},
traits::Blockable,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::PersonView;
use lemmy_db_views::structs::{LocalUserView, PersonView};
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
#[tracing::instrument(skip(context))]

View file

@ -1,7 +1,6 @@
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_db_views::structs::{LocalUserView, PersonView};
use lemmy_utils::error::LemmyResult;
pub async fn list_banned_users(

View file

@ -6,7 +6,7 @@ use lemmy_api_common::{
utils::check_private_instance,
};
use lemmy_db_views::{
person_saved_combined_view::PersonSavedCombinedQuery,
combined::person_saved_combined_view::PersonSavedCombinedQuery,
structs::{LocalUserView, SiteView},
};
use lemmy_utils::error::LemmyResult;

View file

@ -3,8 +3,7 @@ use lemmy_api_common::{
context::LemmyContext,
person::{ListInbox, ListInboxResponse},
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::inbox_combined_view::InboxCombinedQuery;
use lemmy_db_views::{combined::inbox_combined_view::InboxCombinedQuery, structs::LocalUserView};
use lemmy_utils::error::LemmyResult;
#[tracing::instrument(skip(context))]

View file

@ -1,7 +1,6 @@
use actix_web::web::{Data, Json};
use lemmy_api_common::{context::LemmyContext, person::GetUnreadCountResponse};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::InboxCombinedViewInternal;
use lemmy_db_views::structs::{InboxCombinedViewInternal, LocalUserView};
use lemmy_utils::error::LemmyResult;
#[tracing::instrument(skip(context))]

View file

@ -4,7 +4,7 @@ use lemmy_api_common::{
reports::combined::{ListReports, ListReportsResponse},
utils::check_community_mod_of_any_or_admin_action,
};
use lemmy_db_views::{report_combined_view::ReportCombinedQuery, structs::LocalUserView};
use lemmy_db_views::{combined::report_combined_view::ReportCombinedQuery, structs::LocalUserView};
use lemmy_utils::error::LemmyResult;
/// Lists reports for a community if an id is supplied

View file

@ -12,8 +12,7 @@ use lemmy_db_schema::{
},
traits::Crud,
};
use lemmy_db_views::structs::{LocalUserView, SiteView};
use lemmy_db_views_actor::structs::PersonView;
use lemmy_db_views::structs::{LocalUserView, PersonView, SiteView};
use lemmy_utils::{
error::{LemmyErrorType, LemmyResult},
VERSION,

View file

@ -5,8 +5,7 @@ use lemmy_api_common::{
utils::{check_community_mod_of_any_or_admin_action, check_private_instance},
};
use lemmy_db_schema::source::local_site::LocalSite;
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_moderator::{self, modlog_combined_view::ModlogCombinedQuery};
use lemmy_db_views::{combined::modlog_combined_view::ModlogCombinedQuery, structs::LocalUserView};
use lemmy_utils::error::LemmyResult;
#[tracing::instrument(skip(context))]

View file

@ -17,8 +17,7 @@ use lemmy_db_schema::{
},
traits::Crud,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::CommunityModeratorView;
use lemmy_db_views::structs::{CommunityModeratorView, LocalUserView};
use lemmy_utils::error::LemmyResult;
#[tracing::instrument(skip(context))]

View file

@ -7,7 +7,7 @@ use lemmy_api_common::{
};
use lemmy_db_schema::source::local_site::LocalSite;
use lemmy_db_views::{
registration_application_view::RegistrationApplicationQuery,
registration_applications::registration_application_view::RegistrationApplicationQuery,
structs::LocalUserView,
};
use lemmy_utils::error::LemmyResult;

View file

@ -21,8 +21,6 @@ full = [
"tracing",
"rosetta-i18n",
"lemmy_db_views/full",
"lemmy_db_views_actor/full",
"lemmy_db_views_moderator/full",
"lemmy_utils/full",
"activitypub_federation",
"encoding_rs",
@ -43,8 +41,6 @@ full = [
[dependencies]
lemmy_db_views = { workspace = true }
lemmy_db_views_moderator = { workspace = true }
lemmy_db_views_actor = { workspace = true }
lemmy_db_schema = { workspace = true }
lemmy_utils = { workspace = true }
activitypub_federation = { workspace = true, optional = true }

View file

@ -25,8 +25,7 @@ use lemmy_db_schema::{
},
traits::Crud,
};
use lemmy_db_views::structs::{CommentView, LocalUserView, PostView};
use lemmy_db_views_actor::structs::CommunityView;
use lemmy_db_views::structs::{CommentView, CommunityView, LocalUserView, PostView};
use lemmy_utils::{
error::LemmyResult,
utils::{markdown::markdown_to_html, mention::MentionData},

View file

@ -4,7 +4,7 @@ use lemmy_db_schema::{
CommunityVisibility,
ListingType,
};
use lemmy_db_views_actor::structs::{
use lemmy_db_views::structs::{
CommunityModeratorView,
CommunitySortType,
CommunityView,

View file

@ -24,8 +24,6 @@ pub mod utils;
pub extern crate lemmy_db_schema;
pub extern crate lemmy_db_views;
pub extern crate lemmy_db_views_actor;
pub extern crate lemmy_db_views_moderator;
pub extern crate lemmy_utils;
pub use lemmy_utils::error::LemmyErrorType;

View file

@ -17,15 +17,13 @@ use lemmy_db_schema::{
PostSortType,
};
use lemmy_db_views::structs::{
CommunityModeratorView,
InboxCombinedPaginationCursor,
InboxCombinedView,
LocalImageView,
PersonContentCombinedPaginationCursor,
PersonContentCombinedView,
PersonSavedCombinedPaginationCursor,
};
use lemmy_db_views_actor::structs::{
CommunityModeratorView,
InboxCombinedPaginationCursor,
InboxCombinedView,
PersonView,
};
use serde::{Deserialize, Serialize};

View file

@ -4,8 +4,13 @@ use lemmy_db_schema::{
PostFeatureType,
PostSortType,
};
use lemmy_db_views::structs::{PaginationCursor, PostView, VoteView};
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
use lemmy_db_views::structs::{
CommunityModeratorView,
CommunityView,
PaginationCursor,
PostView,
VoteView,
};
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
#[cfg(feature = "full")]

View file

@ -1,5 +1,5 @@
use lemmy_db_schema::newtypes::{PersonId, PrivateMessageId};
use lemmy_db_views_actor::structs::PrivateMessageView;
use lemmy_db_views::structs::PrivateMessageView;
use serde::{Deserialize, Serialize};
#[cfg(feature = "full")]
use ts_rs::TS;

View file

@ -11,7 +11,7 @@ use lemmy_db_schema::{
private_message::PrivateMessage,
},
};
use lemmy_db_views_actor::structs::PrivateMessageView;
use lemmy_db_views::structs::PrivateMessageView;
use lemmy_utils::error::LemmyResult;
use std::sync::{LazyLock, OnceLock};
use tokio::{

View file

@ -27,22 +27,24 @@ use lemmy_db_schema::{
PostListingMode,
PostSortType,
RegistrationMode,
SearchSortType,
SearchType,
};
use lemmy_db_views::structs::{
CommentView,
LocalUserView,
PostView,
RegistrationApplicationView,
SiteView,
};
use lemmy_db_views_actor::structs::{
CommunityFollowerView,
CommunityModeratorView,
CommunityView,
LocalUserView,
ModlogCombinedPaginationCursor,
ModlogCombinedView,
PersonView,
PostView,
RegistrationApplicationView,
SearchCombinedPaginationCursor,
SearchCombinedView,
SiteView,
};
use lemmy_db_views_moderator::structs::{ModlogCombinedPaginationCursor, ModlogCombinedView};
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
#[cfg(feature = "full")]
@ -52,9 +54,10 @@ use ts_rs::TS;
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "full", derive(TS))]
#[cfg_attr(feature = "full", ts(export))]
/// Searches the site, given a query string, and some optional filters.
/// Searches the site, given a search term, and some optional filters.
pub struct Search {
pub q: String,
#[cfg_attr(feature = "full", ts(optional))]
pub search_term: Option<String>,
#[cfg_attr(feature = "full", ts(optional))]
pub community_id: Option<CommunityId>,
#[cfg_attr(feature = "full", ts(optional))]
@ -64,14 +67,10 @@ pub struct Search {
#[cfg_attr(feature = "full", ts(optional))]
pub type_: Option<SearchType>,
#[cfg_attr(feature = "full", ts(optional))]
pub sort: Option<PostSortType>,
pub sort: Option<SearchSortType>,
#[cfg_attr(feature = "full", ts(optional))]
pub listing_type: Option<ListingType>,
#[cfg_attr(feature = "full", ts(optional))]
pub page: Option<i64>,
#[cfg_attr(feature = "full", ts(optional))]
pub limit: Option<i64>,
#[cfg_attr(feature = "full", ts(optional))]
pub title_only: Option<bool>,
#[cfg_attr(feature = "full", ts(optional))]
pub post_url_only: Option<bool>,
@ -79,19 +78,18 @@ pub struct Search {
pub liked_only: Option<bool>,
#[cfg_attr(feature = "full", ts(optional))]
pub disliked_only: Option<bool>,
#[cfg_attr(feature = "full", ts(optional))]
pub page_cursor: Option<SearchCombinedPaginationCursor>,
#[cfg_attr(feature = "full", ts(optional))]
pub page_back: Option<bool>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[cfg_attr(feature = "full", derive(TS))]
#[cfg_attr(feature = "full", ts(export))]
/// The search response, containing lists of the return type possibilities
// TODO this should be redone as a list of tagged enums
pub struct SearchResponse {
pub type_: SearchType,
pub comments: Vec<CommentView>,
pub posts: Vec<PostView>,
pub communities: Vec<CommunityView>,
pub users: Vec<PersonView>,
pub results: Vec<SearchCombinedView>,
}
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]

View file

@ -47,14 +47,16 @@ use lemmy_db_schema::{
RegistrationMode,
};
use lemmy_db_views::{
comment_view::CommentQuery,
structs::{LocalImageView, LocalUserView, SiteView},
};
use lemmy_db_views_actor::structs::{
CommunityFollowerView,
CommunityModeratorView,
CommunityPersonBanView,
CommunityView,
comment::comment_view::CommentQuery,
structs::{
CommunityFollowerView,
CommunityModeratorView,
CommunityPersonBanView,
CommunityView,
LocalImageView,
LocalUserView,
SiteView,
},
};
use lemmy_utils::{
email::{send_email, translations::Lang},
@ -1213,8 +1215,8 @@ mod tests {
},
ModlogActionType,
};
use lemmy_db_views_moderator::{
modlog_combined_view::ModlogCombinedQuery,
use lemmy_db_views::{
combined::modlog_combined_view::ModlogCombinedQuery,
structs::{ModRemoveCommentView, ModRemovePostView, ModlogCombinedView},
};
use pretty_assertions::assert_eq;

View file

@ -16,7 +16,6 @@ workspace = true
lemmy_utils = { workspace = true, features = ["full"] }
lemmy_db_schema = { workspace = true, features = ["full"] }
lemmy_db_views = { workspace = true, features = ["full"] }
lemmy_db_views_actor = { workspace = true, features = ["full"] }
lemmy_api_common = { workspace = true, features = ["full"] }
activitypub_federation = { workspace = true }
bcrypt = { workspace = true }

View file

@ -11,8 +11,7 @@ use lemmy_db_schema::{
source::community::{Community, CommunityUpdateForm},
traits::Crud,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::CommunityModeratorView;
use lemmy_db_views::structs::{CommunityModeratorView, LocalUserView};
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
#[tracing::instrument(skip(context))]

View file

@ -4,8 +4,10 @@ use lemmy_api_common::{
context::LemmyContext,
utils::{check_private_instance, is_admin},
};
use lemmy_db_views::structs::{LocalUserView, SiteView};
use lemmy_db_views_actor::community_view::CommunityQuery;
use lemmy_db_views::{
community::community_view::CommunityQuery,
structs::{LocalUserView, SiteView},
};
use lemmy_utils::error::LemmyResult;
#[tracing::instrument(skip(context))]

View file

@ -27,8 +27,7 @@ use lemmy_db_schema::{
traits::{Crud, Likeable},
utils::diesel_url_create,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::CommunityModeratorView;
use lemmy_db_views::structs::{CommunityModeratorView, LocalUserView};
use lemmy_utils::{
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
utils::{

View file

@ -12,10 +12,9 @@ use lemmy_db_schema::{
traits::Crud,
};
use lemmy_db_views::{
post_view::PostQuery,
structs::{LocalUserView, PostView, SiteView},
post::post_view::PostQuery,
structs::{CommunityModeratorView, CommunityView, LocalUserView, PostView, SiteView},
};
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
#[tracing::instrument(skip(context))]

View file

@ -21,8 +21,7 @@ use lemmy_db_schema::{
},
traits::Crud,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::PrivateMessageView;
use lemmy_db_views::structs::{LocalUserView, PrivateMessageView};
use lemmy_utils::{
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
utils::{markdown::markdown_to_html, validation::is_valid_body_field},

View file

@ -9,8 +9,7 @@ use lemmy_db_schema::{
source::private_message::{PrivateMessage, PrivateMessageUpdateForm},
traits::Crud,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::PrivateMessageView;
use lemmy_db_views::structs::{LocalUserView, PrivateMessageView};
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
#[tracing::instrument(skip(context))]

View file

@ -14,8 +14,7 @@ use lemmy_db_schema::{
},
traits::Crud,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::PrivateMessageView;
use lemmy_db_views::structs::{LocalUserView, PrivateMessageView};
use lemmy_utils::{
error::{LemmyErrorExt, LemmyErrorType, LemmyResult},
utils::validation::is_valid_body_field,

View file

@ -8,8 +8,7 @@ use lemmy_db_schema::source::{
oauth_provider::OAuthProvider,
tagline::Tagline,
};
use lemmy_db_views::structs::{LocalUserView, SiteView};
use lemmy_db_views_actor::structs::PersonView;
use lemmy_db_views::structs::{LocalUserView, PersonView, SiteView};
use lemmy_utils::{build_cache, error::LemmyResult, CacheLock, VERSION};
use std::sync::LazyLock;

View file

@ -6,8 +6,7 @@ use lemmy_db_schema::source::{
instance_block::InstanceBlock,
person_block::PersonBlock,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::{CommunityFollowerView, CommunityModeratorView};
use lemmy_db_views::structs::{CommunityFollowerView, CommunityModeratorView, LocalUserView};
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
#[tracing::instrument(skip(context))]

View file

@ -21,7 +21,6 @@ workspace = true
lemmy_utils = { workspace = true, features = ["full"] }
lemmy_db_schema = { workspace = true, features = ["full"] }
lemmy_db_views = { workspace = true, features = ["full"] }
lemmy_db_views_actor = { workspace = true, features = ["full"] }
lemmy_api_common = { workspace = true, features = ["full"] }
activitypub_federation = { workspace = true }
diesel = { workspace = true }

View file

@ -29,7 +29,7 @@ use lemmy_db_schema::{
},
traits::{Crud, Reportable},
};
use lemmy_db_views_actor::structs::CommunityModeratorView;
use lemmy_db_views::structs::CommunityModeratorView;
use lemmy_utils::error::{LemmyError, LemmyResult};
use url::Url;

View file

@ -14,7 +14,7 @@ use activitypub_federation::{
};
use lemmy_api_common::context::LemmyContext;
use lemmy_db_schema::source::activity::ActivitySendTargets;
use lemmy_db_views_actor::structs::PrivateMessageView;
use lemmy_db_views::structs::PrivateMessageView;
use lemmy_utils::error::{LemmyError, LemmyResult};
use url::Url;

View file

@ -43,7 +43,7 @@ use lemmy_db_schema::{
traits::Crud,
CommunityVisibility,
};
use lemmy_db_views_actor::structs::{CommunityPersonBanView, CommunityView};
use lemmy_db_views::structs::{CommunityPersonBanView, CommunityView};
use lemmy_utils::error::{FederationError, LemmyError, LemmyErrorExt, LemmyErrorType, LemmyResult};
use serde::Serialize;
use tracing::info;

View file

@ -16,7 +16,7 @@ use lemmy_db_schema::{
traits::Crud,
};
use lemmy_db_views::{
comment_view::CommentQuery,
comment::comment_view::CommentQuery,
structs::{CommentView, LocalUserView, SiteView},
};
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};

View file

@ -7,7 +7,7 @@ use lemmy_api_common::{
utils::check_private_instance,
};
use lemmy_db_views::{
person_content_combined_view::PersonContentCombinedQuery,
combined::person_content_combined_view::PersonContentCombinedQuery,
structs::{LocalUserView, SiteView},
};
use lemmy_utils::error::LemmyResult;

View file

@ -15,7 +15,7 @@ use lemmy_db_schema::{
source::{community::Community, post::PostRead},
};
use lemmy_db_views::{
post_view::PostQuery,
post::post_view::PostQuery,
structs::{LocalUserView, PaginationCursor, SiteView},
};
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};

View file

@ -11,8 +11,7 @@ use lemmy_db_schema::source::{
community::Community,
local_site::LocalSite,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
use lemmy_db_views::structs::{CommunityModeratorView, CommunityView, LocalUserView};
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
#[tracing::instrument(skip(context))]

View file

@ -6,8 +6,7 @@ use lemmy_api_common::{
person::{GetPersonDetails, GetPersonDetailsResponse},
utils::{check_private_instance, is_admin, read_site_for_actor},
};
use lemmy_db_views::structs::{LocalUserView, SiteView};
use lemmy_db_views_actor::structs::{CommunityModeratorView, PersonView};
use lemmy_db_views::structs::{CommunityModeratorView, LocalUserView, PersonView, SiteView};
use lemmy_utils::error::LemmyResult;
#[tracing::instrument(skip(context))]

View file

@ -11,8 +11,7 @@ use lemmy_api_common::{
utils::check_private_instance,
};
use lemmy_db_schema::{source::local_site::LocalSite, utils::DbPool};
use lemmy_db_views::structs::{CommentView, LocalUserView, PostView};
use lemmy_db_views_actor::structs::{CommunityView, PersonView};
use lemmy_db_views::structs::{CommentView, CommunityView, LocalUserView, PersonView, PostView};
use lemmy_utils::error::{LemmyErrorExt2, LemmyErrorType, LemmyResult};
#[tracing::instrument(skip(context))]

View file

@ -4,19 +4,13 @@ use actix_web::web::{Json, Query};
use lemmy_api_common::{
context::LemmyContext,
site::{Search, SearchResponse},
utils::{check_conflicting_like_filters, check_private_instance, is_admin},
utils::{check_conflicting_like_filters, check_private_instance},
};
use lemmy_db_schema::{source::community::Community, utils::post_to_comment_sort_type, SearchType};
use lemmy_db_schema::source::community::Community;
use lemmy_db_views::{
comment_view::CommentQuery,
post_view::PostQuery,
combined::search_combined_view::SearchCombinedQuery,
structs::{LocalUserView, SiteView},
};
use lemmy_db_views_actor::{
community_view::CommunityQuery,
person_view::PersonQuery,
structs::CommunitySortType,
};
use lemmy_utils::error::LemmyResult;
#[tracing::instrument(skip(context))]
@ -28,154 +22,43 @@ pub async fn search(
let local_site = SiteView::read_local(&mut context.pool()).await?;
check_private_instance(&local_user_view, &local_site.local_site)?;
check_conflicting_like_filters(data.liked_only, data.disliked_only)?;
let is_admin = local_user_view
.as_ref()
.map(|luv| is_admin(luv).is_ok())
.unwrap_or_default();
let mut posts = Vec::new();
let mut comments = Vec::new();
let mut communities = Vec::new();
let mut users = Vec::new();
// TODO no clean / non-nsfw searching rn
let Query(Search {
q,
community_id,
community_name,
creator_id,
type_,
sort,
listing_type,
page,
limit,
title_only,
post_url_only,
liked_only,
disliked_only,
}) = data;
let q = q.clone();
let search_type = type_.unwrap_or(SearchType::All);
let community_id = if let Some(name) = &community_name {
let community_id = if let Some(name) = &data.community_name {
Some(
resolve_actor_identifier::<ApubCommunity, Community>(name, &context, &local_user_view, false)
.await?,
)
.map(|c| c.id)
} else {
community_id
data.community_id
};
let local_user = local_user_view.as_ref().map(|l| &l.local_user);
let search_term = data.search_term.clone();
check_conflicting_like_filters(liked_only, disliked_only)?;
// parse pagination token
let page_after = if let Some(pa) = &data.page_cursor {
Some(pa.read(&mut context.pool()).await?)
} else {
None
};
let page_back = data.page_back;
let posts_query = PostQuery {
sort,
listing_type,
let results = SearchCombinedQuery {
search_term,
community_id,
creator_id,
local_user,
search_term: Some(q.clone()),
page,
limit,
title_only,
url_only: post_url_only,
liked_only,
disliked_only,
..Default::default()
};
creator_id: data.creator_id,
type_: data.type_,
sort: data.sort,
listing_type: data.listing_type,
title_only: data.title_only,
post_url_only: data.post_url_only,
liked_only: data.liked_only,
disliked_only: data.disliked_only,
page_after,
page_back,
}
.list(&mut context.pool(), &local_user_view)
.await?;
let comment_query = CommentQuery {
sort: sort.map(post_to_comment_sort_type),
listing_type,
search_term: Some(q.clone()),
community_id,
creator_id,
local_user,
page,
limit,
liked_only,
disliked_only,
..Default::default()
};
let community_query = CommunityQuery {
sort: sort.map(CommunitySortType::from),
listing_type,
search_term: Some(q.clone()),
title_only,
local_user,
is_mod_or_admin: is_admin,
page,
limit,
..Default::default()
};
let person_query = PersonQuery {
sort,
search_term: Some(q.clone()),
listing_type,
page,
limit,
};
match search_type {
SearchType::Posts => {
posts = posts_query
.list(&local_site.site, &mut context.pool())
.await?;
}
SearchType::Comments => {
comments = comment_query
.list(&local_site.site, &mut context.pool())
.await?;
}
SearchType::Communities => {
communities = community_query
.list(&local_site.site, &mut context.pool())
.await?;
}
SearchType::Users => {
users = person_query.list(&mut context.pool()).await?;
}
SearchType::All => {
// If the community or creator is included, dont search communities or users
let community_or_creator_included =
community_id.is_some() || community_name.is_some() || creator_id.is_some();
posts = posts_query
.list(&local_site.site, &mut context.pool())
.await?;
comments = comment_query
.list(&local_site.site, &mut context.pool())
.await?;
communities = if community_or_creator_included {
vec![]
} else {
community_query
.list(&local_site.site, &mut context.pool())
.await?
};
users = if community_or_creator_included {
vec![]
} else {
person_query.list(&mut context.pool()).await?
};
}
};
// Return the jwt
Ok(Json(SearchResponse {
type_: search_type,
comments,
posts,
communities,
users,
}))
Ok(Json(SearchResponse { results }))
}

View file

@ -323,8 +323,7 @@ pub(crate) mod tests {
},
traits::{Crud, Followable},
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::CommunityFollowerView;
use lemmy_db_views::structs::{CommunityFollowerView, LocalUserView};
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
use serial_test::serial;
use std::time::Duration;

View file

@ -10,7 +10,7 @@ use activitypub_federation::{
};
use lemmy_api_common::{context::LemmyContext, utils::generate_followers_url};
use lemmy_db_schema::aggregates::structs::CommunityAggregates;
use lemmy_db_views_actor::structs::CommunityFollowerView;
use lemmy_db_views::structs::CommunityFollowerView;
use lemmy_utils::error::LemmyError;
use url::Url;

View file

@ -14,7 +14,7 @@ use lemmy_db_schema::{
source::community::{CommunityModerator, CommunityModeratorForm},
traits::Joinable,
};
use lemmy_db_views_actor::structs::CommunityModeratorView;
use lemmy_db_views::structs::CommunityModeratorView;
use lemmy_utils::error::{LemmyError, LemmyResult};
use url::Url;

View file

@ -19,7 +19,7 @@ use activitypub_federation::{
use futures::future::join_all;
use lemmy_api_common::{context::LemmyContext, utils::generate_outbox_url};
use lemmy_db_schema::{source::site::Site, utils::FETCH_LIMIT_MAX, PostSortType};
use lemmy_db_views::post_view::PostQuery;
use lemmy_db_views::post::post_view::PostQuery;
use lemmy_utils::error::{LemmyError, LemmyResult};
use url::Url;

View file

@ -23,7 +23,7 @@ use actix_web::{
};
use lemmy_api_common::context::LemmyContext;
use lemmy_db_schema::{source::community::Community, traits::ApubActor, CommunityVisibility};
use lemmy_db_views_actor::structs::CommunityFollowerView;
use lemmy_db_views::structs::CommunityFollowerView;
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
use serde::Deserialize;

View file

@ -18,7 +18,7 @@ use lemmy_db_schema::{
source::{activity::SentActivity, community::Community},
CommunityVisibility,
};
use lemmy_db_views_actor::structs::CommunityFollowerView;
use lemmy_db_views::structs::CommunityFollowerView;
use lemmy_utils::error::{FederationError, LemmyErrorExt, LemmyErrorType, LemmyResult};
use serde::{Deserialize, Serialize};
use std::{ops::Deref, time::Duration};

View file

@ -40,7 +40,7 @@ use lemmy_db_schema::{
traits::{ApubActor, Crud},
CommunityVisibility,
};
use lemmy_db_views_actor::structs::CommunityFollowerView;
use lemmy_db_views::structs::CommunityFollowerView;
use lemmy_utils::{
error::{LemmyError, LemmyResult},
spawn_try_task,

View file

@ -36,7 +36,7 @@ use lemmy_db_schema::{
},
traits::Crud,
};
use lemmy_db_views_actor::structs::CommunityModeratorView;
use lemmy_db_views::structs::CommunityModeratorView;
use lemmy_utils::{
error::{LemmyError, LemmyResult},
spawn_try_task,

View file

@ -22,7 +22,7 @@ use lemmy_db_schema::{
utils::{build_db_pool, get_conn, now},
PostSortType,
};
use lemmy_db_views::{post_view::PostQuery, structs::PaginationCursor};
use lemmy_db_views::{post::post_view::PostQuery, structs::PaginationCursor};
use lemmy_utils::error::{LemmyErrorExt2, LemmyResult};
use std::num::NonZeroU32;
use url::Url;
@ -160,7 +160,7 @@ async fn try_main() -> LemmyResult<()> {
.list(&site()?, &mut conn.into())
.await?;
if let Some(post_view) = post_views.into_iter().last() {
if let Some(post_view) = post_views.into_iter().next_back() {
println!("👀 getting pagination cursor data for next page");
let cursor_data = PaginationCursor::after_post(&post_view)
.read(&mut conn.into(), None)

View file

@ -927,3 +927,126 @@ CREATE TRIGGER require_uplete
FOR EACH STATEMENT
EXECUTE FUNCTION r.require_uplete ();
-- search: (post, comment, community, person)
CREATE PROCEDURE r.create_search_combined_trigger (table_name text)
LANGUAGE plpgsql
AS $a$
BEGIN
EXECUTE replace($b$ CREATE FUNCTION r.search_combined_thing_insert ( )
RETURNS TRIGGER
LANGUAGE plpgsql
AS $$
BEGIN
-- TODO need to figure out how to do the other columns here
INSERT INTO search_combined (published, thing_id)
VALUES (NEW.published, NEW.id);
RETURN NEW;
END $$;
CREATE TRIGGER search_combined
AFTER INSERT ON thing
FOR EACH ROW
EXECUTE FUNCTION r.search_combined_thing_insert ( );
$b$,
'thing',
table_name);
END;
$a$;
CALL r.create_search_combined_trigger ('post');
CALL r.create_search_combined_trigger ('comment');
CALL r.create_search_combined_trigger ('community');
CALL r.create_search_combined_trigger ('person');
-- You also need to triggers to update the `score` column.
-- post | post_aggregates::score
-- comment | comment_aggregates::score
-- community | community_aggregates::users_active_monthly
-- person | person_aggregates::post_score
--
-- Post score
CREATE FUNCTION r.search_combined_post_score_update ()
RETURNS TRIGGER
LANGUAGE plpgsql
AS $$
BEGIN
UPDATE
search_combined
SET
score = NEW.score
WHERE
post_id = NEW.post_id;
RETURN NULL;
END
$$;
CREATE TRIGGER search_combined_post_score
AFTER UPDATE OF score ON post_aggregates
FOR EACH ROW
EXECUTE FUNCTION r.search_combined_post_score_update ();
-- Comment score
CREATE FUNCTION r.search_combined_comment_score_update ()
RETURNS TRIGGER
LANGUAGE plpgsql
AS $$
BEGIN
UPDATE
search_combined
SET
score = NEW.score
WHERE
comment_id = NEW.comment_id;
RETURN NULL;
END
$$;
CREATE TRIGGER search_combined_comment_score
AFTER UPDATE OF score ON comment_aggregates
FOR EACH ROW
EXECUTE FUNCTION r.search_combined_comment_score_update ();
-- Person score
CREATE FUNCTION r.search_combined_person_score_update ()
RETURNS TRIGGER
LANGUAGE plpgsql
AS $$
BEGIN
UPDATE
search_combined
SET
score = NEW.post_score
WHERE
person_id = NEW.person_id;
RETURN NULL;
END
$$;
CREATE TRIGGER search_combined_person_score
AFTER UPDATE OF post_score ON person_aggregates
FOR EACH ROW
EXECUTE FUNCTION r.search_combined_person_score_update ();
-- Community score
CREATE FUNCTION r.search_combined_community_score_update ()
RETURNS TRIGGER
LANGUAGE plpgsql
AS $$
BEGIN
UPDATE
search_combined
SET
score = NEW.users_active_month
WHERE
community_id = NEW.community_id;
RETURN NULL;
END
$$;
CREATE TRIGGER search_combined_community_score
AFTER UPDATE OF users_active_month ON community_aggregates
FOR EACH ROW
EXECUTE FUNCTION r.search_combined_community_score_update ();

View file

@ -66,7 +66,7 @@ impl LocalImage {
}
pub async fn delete_by_url(pool: &mut DbPool<'_>, url: &DbUrl) -> Result<Self, Error> {
let alias = url.as_str().split('/').last().ok_or(NotFound)?;
let alias = url.as_str().split('/').next_back().ok_or(NotFound)?;
Self::delete_by_alias(pool, alias).await
}
}

View file

@ -101,6 +101,19 @@ pub enum CommentSortType {
Controversial,
}
#[derive(
EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, Hash,
)]
#[cfg_attr(feature = "full", derive(TS))]
#[cfg_attr(feature = "full", ts(export))]
/// The search sort types.
pub enum SearchSortType {
#[default]
New,
Top,
Old,
}
#[derive(
EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, Hash,
)]
@ -166,11 +179,14 @@ pub enum PostListingMode {
SmallCard,
}
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash)]
#[derive(
EnumString, Display, Debug, Serialize, Deserialize, Default, Clone, Copy, PartialEq, Eq, Hash,
)]
#[cfg_attr(feature = "full", derive(TS))]
#[cfg_attr(feature = "full", ts(export))]
/// The type of content returned from a search.
pub enum SearchType {
#[default]
All,
Comments,
Posts,

View file

@ -220,6 +220,11 @@ pub struct ModlogCombinedId(i32);
/// The inbox combined id
pub struct InboxCombinedId(i32);
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
#[cfg_attr(feature = "full", derive(DieselNewType))]
/// The search combined id
pub struct SearchCombinedId(i32);
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
#[cfg_attr(feature = "full", derive(DieselNewType, TS))]
#[cfg_attr(feature = "full", ts(export))]

View file

@ -995,6 +995,18 @@ diesel::table! {
}
}
diesel::table! {
search_combined (id) {
id -> Int4,
published -> Timestamptz,
score -> Int8,
post_id -> Nullable<Int4>,
comment_id -> Nullable<Int4>,
community_id -> Nullable<Int4>,
person_id -> Nullable<Int4>,
}
}
diesel::table! {
secret (id) {
id -> Int4,
@ -1196,6 +1208,10 @@ diesel::joinable!(report_combined -> comment_report (comment_report_id));
diesel::joinable!(report_combined -> community_report (community_report_id));
diesel::joinable!(report_combined -> post_report (post_report_id));
diesel::joinable!(report_combined -> private_message_report (private_message_report_id));
diesel::joinable!(search_combined -> comment (comment_id));
diesel::joinable!(search_combined -> community (community_id));
diesel::joinable!(search_combined -> person (person_id));
diesel::joinable!(search_combined -> post (post_id));
diesel::joinable!(site -> instance (instance_id));
diesel::joinable!(site_aggregates -> site (site_id));
diesel::joinable!(site_language -> language (language_id));
@ -1274,6 +1290,7 @@ diesel::allow_tables_to_appear_in_same_query!(
registration_application,
remote_image,
report_combined,
search_combined,
secret,
sent_activity,
site,

View file

@ -3,3 +3,4 @@ pub mod modlog;
pub mod person_content;
pub mod person_saved;
pub mod report;
pub mod search;

View file

@ -0,0 +1,28 @@
use crate::newtypes::{CommentId, CommunityId, PersonId, PostId, SearchCombinedId};
#[cfg(feature = "full")]
use crate::schema::search_combined;
use chrono::{DateTime, Utc};
#[cfg(feature = "full")]
use i_love_jesus::CursorKeysModule;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
#[skip_serializing_none]
#[derive(PartialEq, Eq, Serialize, Deserialize, Debug, Clone)]
#[cfg_attr(
feature = "full",
derive(Identifiable, Queryable, Selectable, CursorKeysModule)
)]
#[cfg_attr(feature = "full", diesel(table_name = search_combined))]
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
#[cfg_attr(feature = "full", cursor_keys_module(name = search_combined_keys))]
/// A combined table for a search (posts, comments, communities, persons)
pub struct SearchCombined {
pub id: SearchCombinedId,
pub published: DateTime<Utc>,
pub score: i64,
pub post_id: Option<PostId>,
pub comment_id: Option<CommentId>,
pub community_id: Option<CommunityId>,
pub person_id: Option<PersonId>,
}

View file

@ -42,6 +42,7 @@ actix-web = { workspace = true, optional = true }
i-love-jesus = { workspace = true, optional = true }
chrono = { workspace = true }
derive-new.workspace = true
strum = { workspace = true }
[dev-dependencies]
serial_test = { workspace = true }

View file

@ -40,7 +40,9 @@ use lemmy_db_schema::{
post,
post_actions,
post_aggregates,
post_tag,
private_message,
tag,
},
source::{
combined::inbox::{inbox_combined_keys as key, InboxCombined},
@ -244,6 +246,15 @@ impl InboxCombinedQuery {
let community_join = post::community_id.eq(community::id);
let post_tags = post_tag::table
.inner_join(tag::table)
.select(diesel::dsl::sql::<diesel::sql_types::Json>(
"json_agg(tag.*)",
))
.filter(post_tag::post_id.eq(post::id))
.filter(tag::deleted.eq(false))
.single_value();
let mut query = inbox_combined::table
.left_join(comment_reply::table)
.left_join(person_comment_mention::table)
@ -308,6 +319,7 @@ impl InboxCombinedQuery {
post_actions::hidden.nullable().is_not_null(),
post_actions::like_score.nullable(),
image_details::all_columns.nullable(),
post_tags,
private_message::all_columns.nullable(),
// Shared
post::all_columns.nullable(),
@ -520,6 +532,7 @@ impl InternalToCombinedView for InboxCombinedViewInternal {
hidden: v.post_hidden,
my_vote: v.my_post_vote,
image_details: v.image_details,
post_tags: v.post_tags,
banned_from_community: v.banned_from_community,
}))
} else if let Some(private_message) = v.private_message {
@ -538,7 +551,7 @@ impl InternalToCombinedView for InboxCombinedViewInternal {
#[expect(clippy::indexing_slicing)]
mod tests {
use crate::{
inbox_combined_view::InboxCombinedQuery,
combined::inbox_combined_view::InboxCombinedQuery,
structs::{InboxCombinedView, InboxCombinedViewInternal, PrivateMessageView},
};
use lemmy_db_schema::{

View file

@ -0,0 +1,12 @@
#[cfg(feature = "full")]
pub mod inbox_combined_view;
#[cfg(feature = "full")]
pub mod modlog_combined_view;
#[cfg(feature = "full")]
pub mod person_content_combined_view;
#[cfg(feature = "full")]
pub mod person_saved_combined_view;
#[cfg(feature = "full")]
pub mod report_combined_view;
#[cfg(feature = "full")]
pub mod search_combined_view;

View file

@ -592,7 +592,7 @@ impl InternalToCombinedView for ModlogCombinedViewInternal {
#[expect(clippy::indexing_slicing)]
mod tests {
use crate::{modlog_combined_view::ModlogCombinedQuery, structs::ModlogCombinedView};
use crate::{combined::modlog_combined_view::ModlogCombinedQuery, structs::ModlogCombinedView};
use lemmy_db_schema::{
newtypes::PersonId,
source::{

View file

@ -3,7 +3,7 @@ use crate::structs::{
LocalUserView,
PersonContentCombinedPaginationCursor,
PersonContentCombinedView,
PersonContentViewInternal,
PersonContentCombinedViewInternal,
PostView,
};
use diesel::{
@ -235,7 +235,9 @@ impl PersonContentCombinedQuery {
// Tie breaker
.then_desc(key::id);
let res = query.load::<PersonContentViewInternal>(conn).await?;
let res = query
.load::<PersonContentCombinedViewInternal>(conn)
.await?;
// Map the query results to the enum
let out = res
@ -247,7 +249,7 @@ impl PersonContentCombinedQuery {
}
}
impl InternalToCombinedView for PersonContentViewInternal {
impl InternalToCombinedView for PersonContentCombinedViewInternal {
type CombinedView = PersonContentCombinedView;
fn map_to_enum(self) -> Option<Self::CombinedView> {
@ -299,7 +301,7 @@ impl InternalToCombinedView for PersonContentViewInternal {
mod tests {
use crate::{
person_content_combined_view::PersonContentCombinedQuery,
combined::person_content_combined_view::PersonContentCombinedQuery,
structs::PersonContentCombinedView,
};
use lemmy_db_schema::{

View file

@ -1,7 +1,7 @@
use crate::structs::{
LocalUserView,
PersonContentCombinedView,
PersonContentViewInternal,
PersonContentCombinedViewInternal,
PersonSavedCombinedPaginationCursor,
};
use diesel::{
@ -236,7 +236,9 @@ impl PersonSavedCombinedQuery {
// Tie breaker
.then_desc(key::id);
let res = query.load::<PersonContentViewInternal>(conn).await?;
let res = query
.load::<PersonContentCombinedViewInternal>(conn)
.await?;
// Map the query results to the enum
let out = res
@ -253,7 +255,7 @@ impl PersonSavedCombinedQuery {
mod tests {
use crate::{
person_saved_combined_view::PersonSavedCombinedQuery,
combined::person_saved_combined_view::PersonSavedCombinedQuery,
structs::{LocalUserView, PersonContentCombinedView},
};
use lemmy_db_schema::{

View file

@ -491,7 +491,7 @@ impl InternalToCombinedView for ReportCombinedViewInternal {
mod tests {
use crate::{
report_combined_view::ReportCombinedQuery,
combined::report_combined_view::ReportCombinedQuery,
structs::{
CommentReportView,
LocalUserView,

File diff suppressed because it is too large Load diff

View file

@ -374,7 +374,7 @@ fn handle_deleted(mut c: CommentView, is_admin: bool) -> CommentView {
mod tests {
use crate::{
comment_view::{CommentQuery, CommentSortType, CommentView, DbPool},
comment::comment_view::{CommentQuery, CommentSortType, CommentView, DbPool},
structs::LocalUserView,
};
use lemmy_db_schema::{

View file

@ -0,0 +1,2 @@
#[cfg(feature = "full")]
pub mod comment_view;

View file

@ -266,7 +266,7 @@ impl CommunityQuery<'_> {
mod tests {
use crate::{
community_view::CommunityQuery,
community::community_view::CommunityQuery,
structs::{CommunitySortType, CommunityView},
};
use lemmy_db_schema::{

View file

@ -6,10 +6,3 @@ pub mod community_moderator_view;
pub mod community_person_ban_view;
#[cfg(feature = "full")]
pub mod community_view;
#[cfg(feature = "full")]
pub mod inbox_combined_view;
#[cfg(feature = "full")]
pub mod person_view;
#[cfg(feature = "full")]
pub mod private_message_view;
pub mod structs;

View file

@ -2,33 +2,23 @@
extern crate serial_test;
#[cfg(feature = "full")]
pub mod comment_report_view;
pub mod combined;
#[cfg(feature = "full")]
pub mod comment_view;
pub mod comment;
#[cfg(feature = "full")]
pub mod custom_emoji_view;
pub mod community;
#[cfg(feature = "full")]
pub mod local_image_view;
pub mod local_user;
#[cfg(feature = "full")]
pub mod local_user_view;
pub mod person;
#[cfg(feature = "full")]
pub mod person_content_combined_view;
pub mod post;
#[cfg(feature = "full")]
pub mod person_saved_combined_view;
pub mod private_message;
#[cfg(feature = "full")]
pub mod post_report_view;
pub mod registration_applications;
#[cfg(feature = "full")]
pub mod post_tags_view;
pub mod reports;
#[cfg(feature = "full")]
pub mod post_view;
#[cfg(feature = "full")]
pub mod private_message_report_view;
#[cfg(feature = "full")]
pub mod registration_application_view;
#[cfg(feature = "full")]
pub mod report_combined_view;
#[cfg(feature = "full")]
pub mod site_view;
pub mod site;
pub mod structs;
#[cfg(feature = "full")]
pub mod vote_view;

View file

@ -0,0 +1,2 @@
#[cfg(feature = "full")]
pub mod local_user_view;

View file

@ -0,0 +1,2 @@
#[cfg(feature = "full")]
pub mod person_view;

View file

@ -0,0 +1,4 @@
#[cfg(feature = "full")]
pub mod post_tags_view;
#[cfg(feature = "full")]
pub mod post_view;

View file

@ -638,7 +638,7 @@ impl<'a> PostQuery<'a> {
#[cfg(test)]
mod tests {
use crate::{
post_view::{PaginationCursorData, PostQuery, PostView},
post::post_view::{PaginationCursorData, PostQuery, PostView},
structs::{LocalUserView, PostTags},
};
use chrono::Utc;
@ -1604,7 +1604,7 @@ mod tests {
listed_post_ids.extend(post_listings.iter().map(|p| p.post.id));
if let Some(p) = post_listings.into_iter().last() {
if let Some(p) = post_listings.into_iter().next_back() {
page_after = Some(p.counts);
} else {
break;

View file

@ -0,0 +1,2 @@
#[cfg(feature = "full")]
pub mod private_message_view;

Some files were not shown because too many files have changed in this diff Show more