Commit graph

517 commits

Author SHA1 Message Date
Dessalines
079ca69312
Adding Modlog RSS feed. (#5708)
* Adding Modlog RSS feed.

- Fixes #3179

* Addressing PR comments

* Fixing clippy.

* Fixing markdown test.

* Creating common format_actor_url function.

* Clippy

* Adding boolean strings for remove/restore

* Addressing PR comments
2025-06-04 10:18:53 -04:00
Nutomic
64ed2a3cd2
Mark some *Action struct fields as serde(skip) (ref #5532) (#5739) 2025-06-04 09:58:24 +02:00
Anton Boitsov
f323da00f8
Simplifying transaction call (#5703) (#5726)
* Simplifying transaction call (#5703)

* fmt fix

* changing other transaction calls

* fmt fix
2025-06-03 09:43:02 +02:00
Dessalines
9250460b11
Add endpoint to get Liked / Disliked comments and posts. (#5616)
* migration

* update code

* tests

* triggers

* fix

* fmt

* clippy

* post aggregate migration

* changes for post aggregate code

* wip: update tests for post aggregate

* format

* fix partialeq

* trigger fix

* fix post insert trigger

* wip

* reorder

* fixes

* community aggregate migration

* update code

* triggers

* person aggregate migration

* person aggregate code

* person triggers

* test fixes

* fix scheduled task

* update api tests

* site_aggregates to local_site migration

* site_aggregates code changes

* triggers, tests

* more fixes

* Rename PersonPostAggregates to PostActions

* Merge local_user_vote_display_mode into local_user

* fix schema

* Extracting pagination cursor utils into a trait.

- Fixes #5275

* Refactoring to avoid stack overflows.

* Fixing api_common feature.

* Adding pagination for GetBannedPersons.

- Must come after #5424
- Fixes #2847

* Starting to work on removing rest of page / limit.

* Issues with community pagination.

* Rename the traits and paginationcursor::new

* remove duplicate fields

* remove "aggregates" from index names

* uncomment indices

* if count = 0

* Using combined trait.

* remove commentaggregates

* Fix triggers in remove aggregates tables pr (#5451)

* prevent all db_schema test errors

* fix the delete_comments_before_post problem in a way that doesn't affect the returned number of affected rows

* remove unnecessary recursion checks and add comment to remaining check

* clean up

* Fixing SQL format.

* Update triggers.sql

* Update triggers.sql

* Update triggers.sql

* Update triggers.sql

* remove update of deleted column

---------

Co-authored-by: Dessalines <tyhou13@gmx.com>

* rename migration

* Fix migration errors

* Move community.hidden to visibility (fixes #5458)

* Removing empty files.

* Fixing person_saved_combined. (#5481)

* Remove comment and post specific action structs. #5473

* Doing reports

* fix up migration by dropping index

* also add enum variant `LocalOnlyPublic`, rename `LocalOnly` to `LocalOnlyPrivate`

fixes #5351

* fix column order in down.sql

* wip

* Moving blocks.

* Adding a few more views.

* more wip

* fixes

* migration for modlog

* fix migration

* Working views and schema.

* Fix ts_optionals.

* wip

* db_schema compiling

* make the code compile

* Merging from main.

* lint

* Fixing SQL format.

* fix down migration

* Fixing api tests.

* Adding field comments for the actions tables.

* Refactoring CommunityFollower to include follow_state

* fix test

* make hidden status federate

* ts attr

* fix

* fix api test

* Update crates/api/src/reports/post_report/resolve.rs

Co-authored-by: Nutomic <me@nutomic.com>

* Addressing PR comments

* Fix ts export.

* update api client

* review

* Extracting filter_not_hidden_or_is_subscribed (#5497)

* Extracting filter_not_hidden_or_is_subscribed

* Cleanup.

* Cleanup 2.

* Remove follower_state_helper function.

* Cleaning up some utils functions.

* rename hidden to unlisted

* Updating lemmy-js-client.

* Fixing a few cases.

* Fixing list_banned.

* Starting to convert to lemmy results.

* Fixing vote_view.

* Close to finishing up errors.

* Got compiling.

* Remove tracing for CI.

* Removing unused errors.

* Fixing merge from main.

* lower_name community_view sort.

* Syntax errors.

* Removing rest of Result from db_schema, db_views.

* Finally compiling again.

* fmt.

* Subpath tries again.

* Adding some more indexes./

* Fixing shear.

* Fix keyword_blocks test.

* @dullbananas fixes to Subpath, fixing comment tests.

* sql fmt

* Fixing unused error.

* API test fixing

* Moving read_only_posts to its own endpoint, sorted by read date.

- Fixes #5505

* Adding endpoint to list hidden posts.

- Fixes #5607

* Adding a first_id helper function.

* Fixing api_common

* Adding a person/liked endpoint for posts and comments.

- Fixes #4499

* Get rid of old liked_only filters.

* Formatting sql.

* Clippy

* Fixing view tests.

* SQL fmt

* Addressing PR comments

* Addressing PR comments 1.

* Using id desc.

* Addressing PR comments 2.

* Removing the reverse_timestamp keys for the post table.

* Make community_title and community_lower_name indexes desc

* Remove featured_community from post sort

* Forgot to drop index.

* Addressing PR comments

* Fixing clippy.

* Adding person_local column to post_actions and comment_actions

* Fixing pg_format

* Fixing pg_format 2

* Revert "Adding person_local column to post_actions and comment_actions"

This reverts commit e5145d8b07.

* Adding local person check to liked and saved combined.

* Formatting sql.

* Adding local check to migration.

* Addressing PR comments

* Try to add versioned pg_formatter 1

* Try to add versioned pg_formatter 2

* Try to add versioned pg_formatter 3

* Try to add versioned pg_formatter 4

* Moving back to correct location.

---------

Co-authored-by: Felix Ableitner <me@nutomic.com>
Co-authored-by: dullbananas <dull.bananas0@gmail.com>
2025-06-02 11:15:27 +02:00
Nutomic
b4180a57bf
Use same federation keypair for all new users and communities (#5709) 2025-05-29 14:07:39 +02:00
Nutomic
3c7f6be908
Write to mod_change_community_visibility table (fixes #5704) (#5706)
* Write to mod_change_community_visibility table (fixes #5704)

* cleanup duplicate code

* remove todo

* ci

* fix down migration
2025-05-28 05:04:09 -04:00
Dessalines
5095092d3a
Removing hide_modlog_mod_names setting. (#5681)
* Simplify modlog name removals.

- #5614

* Removing hide_modlog_mod_names setting.

* Addressing PR comments 2
2025-05-21 09:49:22 +02:00
Anton Boitsov
9267b50bd7
Deleting local image from db only if pict-rs client returned OK (fixes #5671) (#5680)
* Deleting local image only if pict-rs client returned OK (fixes #5671)

* Adding validation of image, and making some refactoring

* fmt fix

* removed unnecessary validations

* Increase max query duration in PostView speed_check

* TypeScript type CommunityIdQuery for community icon/banner uploads (#5679)

Co-authored-by: Nutomic <me@nutomic.com>

* Add list of local user accounts for admins (fixes #4419) (#5668)

* Add list of local user accounts for admins (fixes #4419)

* add api route

* Merge list_banned_users into admin_list_users

* revert sql

* Optional columns are handled correctly in insert and update forms (ref #5672) (#5675)

* Optional columns are handled correctly in insert and update forms (ref #5672)

* Linter fix

* Downscale proxied thumbnails (fixes #5673) (#5674)

* Downscale proxied thumbnails (fixes #5673)

* add param

* fix tests

* Remove some api_common dependencies (ref #5642) (#5678)

* Adding validation of image, and making some refactoring

* fmt fix

* removed unnecessary validations

---------

Co-authored-by: aboitsov <anton.boitsov@zalando.fi>
Co-authored-by: Felix Ableitner <me@nutomic.com>
Co-authored-by: matc-pub <161147791+matc-pub@users.noreply.github.com>
Co-authored-by: Dessalines <tyhou13@gmx.com>
2025-05-19 16:48:56 -04:00
Dessalines
68008a0e2c
Change local_image to reference person_id, to track thumbnail creators. (#5664)
* Migrations before column fixes

* Change local_image to reference person_id, to track thumbnail creators.

- Fixes #5564

* Fixing API tests.

* Increase the post query duration time. #5661

* Adding thumbnail_and_post_id column

* Forgot ts-optional

* Fixing post spec tests.

* Try using promise.allSettled to ignore errors.

* Using consistent pictrs api key.

* Dont fetch thumbnails for user API.

* Dont delete thumbnails for user deletion.

* Dont filter out thumbnail images when fetching or deleting.

* Update crates/api_common/src/utils.rs

Co-authored-by: Richard Schwab <gitrichardschwab-7a2qxq42kj@central-intelligence.agency>

* Addressing PR comments

* Add comment.

* Rename to thumbnail_for_post_id

* Addressing PR comments

---------

Co-authored-by: Richard Schwab <gitrichardschwab-7a2qxq42kj@central-intelligence.agency>
2025-05-19 15:30:02 -04:00
Nutomic
c840c9b2ae
Deny as conversions (#5688)
* Deny `as` conversions

* comment
2025-05-15 10:31:23 -04:00
Anton Boitsov
3421754ad8
Optional columns are handled correctly in insert and update forms (ref #5672) (#5675)
* Optional columns are handled correctly in insert and update forms (ref #5672)

* Linter fix
2025-05-13 14:22:56 -04:00
Dessalines
18a042fb62
Adding reason for mod_lock_post. (#5670)
* Adding reason for mod_lock_post.

- Fixes #5631

* Fix comment.
2025-05-09 09:40:06 -04:00
Nutomic
0d4c7c9261
Add comments for site/instance (#5666) 2025-05-08 11:31:38 -04:00
Dessalines
d047310633
Only remove email on account deletion, if the user wasn't banned. (#5650)
* Allow deleted / banned users to be able to log in, and delete their data.

- Fixes #3973

* Only delete email if local user isnt banned.

- Fixes #5629
2025-05-05 12:53:41 +02:00
Dessalines
8a6e621633
Adding ability to show downvotes for other users only. (#5644)
* Adding ability to show downvotes for other users only.

- Fixes #5639

* Forgot to add migrations

* Changing default back to Show.
2025-05-05 05:58:55 -04:00
Dessalines
457e1285a2
Fixing post_view largest community prefetch. (#5647)
* Fixing post_view largest community prefetch.

- Fixes #5621

* Cache the largest community result.

* Fixing community largest cache.

* Use cache duration

* Use 1-day cache for largest community
2025-04-30 09:10:08 -04:00
Dessalines
92663fd27d
Allow deleted / banned users to be able to log in, and delete their account. (#5643)
* Allow deleted / banned users to be able to log in, and delete their data.

- Fixes #3973

* Add api test.
2025-04-29 10:41:50 -04:00
matc-pub
dfe69e78a2
Fix can_mod comparison with null and admin creator check (#5628)
* Fix can_mod comparison with null and admin creator check

* Rename local user join helper

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
2025-04-25 11:09:35 +02:00
Dessalines
88dbf58373
Move read only posts to its own endpoint. (#5610)
* migration

* update code

* tests

* triggers

* fix

* fmt

* clippy

* post aggregate migration

* changes for post aggregate code

* wip: update tests for post aggregate

* format

* fix partialeq

* trigger fix

* fix post insert trigger

* wip

* reorder

* fixes

* community aggregate migration

* update code

* triggers

* person aggregate migration

* person aggregate code

* person triggers

* test fixes

* fix scheduled task

* update api tests

* site_aggregates to local_site migration

* site_aggregates code changes

* triggers, tests

* more fixes

* Rename PersonPostAggregates to PostActions

* Merge local_user_vote_display_mode into local_user

* fix schema

* Extracting pagination cursor utils into a trait.

- Fixes #5275

* Refactoring to avoid stack overflows.

* Fixing api_common feature.

* Adding pagination for GetBannedPersons.

- Must come after #5424
- Fixes #2847

* Starting to work on removing rest of page / limit.

* Issues with community pagination.

* Rename the traits and paginationcursor::new

* remove duplicate fields

* remove "aggregates" from index names

* uncomment indices

* if count = 0

* Using combined trait.

* remove commentaggregates

* Fix triggers in remove aggregates tables pr (#5451)

* prevent all db_schema test errors

* fix the delete_comments_before_post problem in a way that doesn't affect the returned number of affected rows

* remove unnecessary recursion checks and add comment to remaining check

* clean up

* Fixing SQL format.

* Update triggers.sql

* Update triggers.sql

* Update triggers.sql

* Update triggers.sql

* remove update of deleted column

---------

Co-authored-by: Dessalines <tyhou13@gmx.com>

* rename migration

* Fix migration errors

* Move community.hidden to visibility (fixes #5458)

* Removing empty files.

* Fixing person_saved_combined. (#5481)

* Remove comment and post specific action structs. #5473

* Doing reports

* fix up migration by dropping index

* also add enum variant `LocalOnlyPublic`, rename `LocalOnly` to `LocalOnlyPrivate`

fixes #5351

* fix column order in down.sql

* wip

* Moving blocks.

* Adding a few more views.

* more wip

* fixes

* migration for modlog

* fix migration

* Working views and schema.

* Fix ts_optionals.

* wip

* db_schema compiling

* make the code compile

* Merging from main.

* lint

* Fixing SQL format.

* fix down migration

* Fixing api tests.

* Adding field comments for the actions tables.

* Refactoring CommunityFollower to include follow_state

* fix test

* make hidden status federate

* ts attr

* fix

* fix api test

* Update crates/api/src/reports/post_report/resolve.rs

Co-authored-by: Nutomic <me@nutomic.com>

* Addressing PR comments

* Fix ts export.

* update api client

* review

* Extracting filter_not_hidden_or_is_subscribed (#5497)

* Extracting filter_not_hidden_or_is_subscribed

* Cleanup.

* Cleanup 2.

* Remove follower_state_helper function.

* Cleaning up some utils functions.

* rename hidden to unlisted

* Updating lemmy-js-client.

* Fixing a few cases.

* Fixing list_banned.

* Starting to convert to lemmy results.

* Fixing vote_view.

* Close to finishing up errors.

* Got compiling.

* Remove tracing for CI.

* Removing unused errors.

* Fixing merge from main.

* lower_name community_view sort.

* Syntax errors.

* Removing rest of Result from db_schema, db_views.

* Finally compiling again.

* fmt.

* Subpath tries again.

* Adding some more indexes./

* Fixing shear.

* Fix keyword_blocks test.

* @dullbananas fixes to Subpath, fixing comment tests.

* sql fmt

* Fixing unused error.

* API test fixing

* Moving read_only_posts to its own endpoint, sorted by read date.

- Fixes #5505

* Adding a first_id helper function.

* Fixing api_common

* Addressing PR comments

* Addressing PR comments 1.

* Using id desc.

* Addressing PR comments 2.

* Removing the reverse_timestamp keys for the post table.

* Make community_title and community_lower_name indexes desc

* Remove featured_community from post sort

* Forgot to drop index.

* Addressing PR comments

---------

Co-authored-by: Felix Ableitner <me@nutomic.com>
Co-authored-by: dullbananas <dull.bananas0@gmail.com>
2025-04-23 13:59:10 -04:00
Dessalines
fe50d8ad67
Splitting DB_views into separate crates. (#5617)
* migration

* update code

* tests

* triggers

* fix

* fmt

* clippy

* post aggregate migration

* changes for post aggregate code

* wip: update tests for post aggregate

* format

* fix partialeq

* trigger fix

* fix post insert trigger

* wip

* reorder

* fixes

* community aggregate migration

* update code

* triggers

* person aggregate migration

* person aggregate code

* person triggers

* test fixes

* fix scheduled task

* update api tests

* site_aggregates to local_site migration

* site_aggregates code changes

* triggers, tests

* more fixes

* Rename PersonPostAggregates to PostActions

* Merge local_user_vote_display_mode into local_user

* fix schema

* Extracting pagination cursor utils into a trait.

- Fixes #5275

* Refactoring to avoid stack overflows.

* Fixing api_common feature.

* Adding pagination for GetBannedPersons.

- Must come after #5424
- Fixes #2847

* Starting to work on removing rest of page / limit.

* Issues with community pagination.

* Rename the traits and paginationcursor::new

* remove duplicate fields

* remove "aggregates" from index names

* uncomment indices

* if count = 0

* Using combined trait.

* remove commentaggregates

* Fix triggers in remove aggregates tables pr (#5451)

* prevent all db_schema test errors

* fix the delete_comments_before_post problem in a way that doesn't affect the returned number of affected rows

* remove unnecessary recursion checks and add comment to remaining check

* clean up

* Fixing SQL format.

* Update triggers.sql

* Update triggers.sql

* Update triggers.sql

* Update triggers.sql

* remove update of deleted column

---------

Co-authored-by: Dessalines <tyhou13@gmx.com>

* rename migration

* Fix migration errors

* Move community.hidden to visibility (fixes #5458)

* Removing empty files.

* Fixing person_saved_combined. (#5481)

* Remove comment and post specific action structs. #5473

* Doing reports

* fix up migration by dropping index

* also add enum variant `LocalOnlyPublic`, rename `LocalOnly` to `LocalOnlyPrivate`

fixes #5351

* fix column order in down.sql

* wip

* Moving blocks.

* Adding a few more views.

* more wip

* fixes

* migration for modlog

* fix migration

* Working views and schema.

* Fix ts_optionals.

* wip

* db_schema compiling

* make the code compile

* Merging from main.

* lint

* Fixing SQL format.

* fix down migration

* Fixing api tests.

* Adding field comments for the actions tables.

* Refactoring CommunityFollower to include follow_state

* fix test

* make hidden status federate

* ts attr

* fix

* fix api test

* Update crates/api/src/reports/post_report/resolve.rs

Co-authored-by: Nutomic <me@nutomic.com>

* Addressing PR comments

* Fix ts export.

* update api client

* review

* Extracting filter_not_hidden_or_is_subscribed (#5497)

* Extracting filter_not_hidden_or_is_subscribed

* Cleanup.

* Cleanup 2.

* Remove follower_state_helper function.

* Cleaning up some utils functions.

* rename hidden to unlisted

* Updating lemmy-js-client.

* Fixing a few cases.

* Fixing list_banned.

* Starting to convert to lemmy results.

* Fixing vote_view.

* Close to finishing up errors.

* Got compiling.

* Remove tracing for CI.

* Removing unused errors.

* Fixing merge from main.

* lower_name community_view sort.

* Syntax errors.

* Removing rest of Result from db_schema, db_views.

* Finally compiling again.

* fmt.

* Subpath tries again.

* Adding some more indexes./

* Fixing shear.

* Fix keyword_blocks test.

* @dullbananas fixes to Subpath, fixing comment tests.

* sql fmt

* Fixing unused error.

* API test fixing

* Adding a first_id helper function.

* Fixing api_common

* Addressing PR comments

* Views to workspace, halfway done.

* More views done.

* Finishing up views

* Running cargo shear.

* taplo fmt.

* cargo fmt

* Remove empty files

* Splitting out combined views.

* Fixing api_common diesel

* taplo

* Fixing imports for api_common

* Addressing PR comments 1.

* Using id desc.

* Addressing PR comments 2.

* Removing the reverse_timestamp keys for the post table.

* Make community_title and community_lower_name indexes desc

* Remove featured_community from post sort

* Forgot to drop index.

---------

Co-authored-by: Felix Ableitner <me@nutomic.com>
Co-authored-by: dullbananas <dull.bananas0@gmail.com>
2025-04-23 14:55:26 +02:00
Dessalines
e431fce02e
Remove rest of page limit (#5429)
* migration

* update code

* tests

* triggers

* fix

* fmt

* clippy

* post aggregate migration

* changes for post aggregate code

* wip: update tests for post aggregate

* format

* fix partialeq

* trigger fix

* fix post insert trigger

* wip

* reorder

* fixes

* community aggregate migration

* update code

* triggers

* person aggregate migration

* person aggregate code

* person triggers

* test fixes

* fix scheduled task

* update api tests

* site_aggregates to local_site migration

* site_aggregates code changes

* triggers, tests

* more fixes

* Rename PersonPostAggregates to PostActions

* Merge local_user_vote_display_mode into local_user

* fix schema

* Extracting pagination cursor utils into a trait.

- Fixes #5275

* Refactoring to avoid stack overflows.

* Fixing api_common feature.

* Adding pagination for GetBannedPersons.

- Must come after #5424
- Fixes #2847

* Starting to work on removing rest of page / limit.

* Issues with community pagination.

* Rename the traits and paginationcursor::new

* remove duplicate fields

* remove "aggregates" from index names

* uncomment indices

* if count = 0

* Using combined trait.

* remove commentaggregates

* Fix triggers in remove aggregates tables pr (#5451)

* prevent all db_schema test errors

* fix the delete_comments_before_post problem in a way that doesn't affect the returned number of affected rows

* remove unnecessary recursion checks and add comment to remaining check

* clean up

* Fixing SQL format.

* Update triggers.sql

* Update triggers.sql

* Update triggers.sql

* Update triggers.sql

* remove update of deleted column

---------

Co-authored-by: Dessalines <tyhou13@gmx.com>

* rename migration

* Fix migration errors

* Move community.hidden to visibility (fixes #5458)

* Removing empty files.

* Fixing person_saved_combined. (#5481)

* Remove comment and post specific action structs. #5473

* Doing reports

* fix up migration by dropping index

* also add enum variant `LocalOnlyPublic`, rename `LocalOnly` to `LocalOnlyPrivate`

fixes #5351

* fix column order in down.sql

* wip

* Moving blocks.

* Adding a few more views.

* more wip

* fixes

* migration for modlog

* fix migration

* Working views and schema.

* Fix ts_optionals.

* wip

* db_schema compiling

* make the code compile

* Merging from main.

* lint

* Fixing SQL format.

* fix down migration

* Fixing api tests.

* Adding field comments for the actions tables.

* Refactoring CommunityFollower to include follow_state

* fix test

* make hidden status federate

* ts attr

* fix

* fix api test

* Update crates/api/src/reports/post_report/resolve.rs

Co-authored-by: Nutomic <me@nutomic.com>

* Addressing PR comments

* Fix ts export.

* update api client

* review

* Extracting filter_not_hidden_or_is_subscribed (#5497)

* Extracting filter_not_hidden_or_is_subscribed

* Cleanup.

* Cleanup 2.

* Remove follower_state_helper function.

* Cleaning up some utils functions.

* rename hidden to unlisted

* Updating lemmy-js-client.

* Fixing a few cases.

* Fixing list_banned.

* Starting to convert to lemmy results.

* Fixing vote_view.

* Close to finishing up errors.

* Got compiling.

* Remove tracing for CI.

* Removing unused errors.

* Fixing merge from main.

* lower_name community_view sort.

* Syntax errors.

* Removing rest of Result from db_schema, db_views.

* Finally compiling again.

* fmt.

* Subpath tries again.

* Adding some more indexes./

* Fixing shear.

* Fix keyword_blocks test.

* @dullbananas fixes to Subpath, fixing comment tests.

* sql fmt

* Fixing unused error.

* API test fixing

* Adding a first_id helper function.

* Fixing api_common

* Addressing PR comments

* Addressing PR comments 1.

* Using id desc.

* Addressing PR comments 2.

* Removing the reverse_timestamp keys for the post table.

* Make community_title and community_lower_name indexes desc

* Remove featured_community from post sort

* Forgot to drop index.

---------

Co-authored-by: Felix Ableitner <me@nutomic.com>
Co-authored-by: dullbananas <dull.bananas0@gmail.com>
2025-04-15 21:24:46 -04:00
Nutomic
80a5406c7e
Add instance setting to disable email notifications (fixes #3011) (#5603)
* Add instance setting to disable email notifications (fixes #3011)

* Dont read site_view again. (#5606)

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
2025-04-09 10:04:41 -04:00
leoseg
f027eca661
Feature filter keywords 3710 (#5263)
* created new table post_keyword_block related to a person and corresponding functions in diesel

* created corresponding api functions

* converted like to ilike in filter

* Fixxed errors for adding keywords for blocking posts

* Fixxed errors in diesel migrations

* Removed debug print

* #3710: Fixxed errors caused by cargo check

* #3710: added up and down scripts for diesel

* added tmp.schema to gitignore

* updated tests

* fixxed test

* fixxed error from rebasing

* Added max number of block tags and modified max length of block tags

* formatted code

* added migration to restrict block keyword length

* #3710: Added check if Blocked keyword is already existing

* #3710: Removed deprecated any

* #3710: Updated keyword length

* #3710: Fixxed errors from master merge

* #3710: Formatting

* #3710: Removed api to block keywords for post from v3 and changed of api path in v4

* #3710: Renamed post_keyword_block table to user_post_keyword_block and replaced id as primary key with the composed key person_id and keyword. Also now use update function which updates the blocked keywords for an user with a new list instead keyword by keyword.

* #3710: Formatted code

* #3710: Removed unnecessary parts for the block API in post as this will be done over the user settings

* #3710: Modified data structure for blocking keywords to reference local user and added update function which will update at all keywords for a local user at once

* #3710: Modified code so updating blocked keywords is now done over user settings

* #3710: Fixxed merging error

* #3710: Fixxed filter query

* #3710: Formatted Code

* #3710: Added suggested changes from review: keyword block update now does delete and then insert, postview uses read from LocalKeywordBlock, and validation with min_length_check and max_length_check

* #3710: formatted code

* c

* #3710: removed BlockKeywordForPost struct

* #3710: formatted code

* #3710: formatted code

* #3710: formatted code
2025-04-08 09:39:52 +02:00
Dessalines
2f7ce1cb63
Adding admin image deletion endpoint. (#5588)
* Adding admin image deletion endpoint.

- Also moving the list media endpoints, since these can go under a
  common heading.
- Fixes #5563

* Changing list_all to list

* Fixing api tests.

* Delete all aliases.

* Fixing comment.

* Updating lemmy-js-client.
2025-04-07 17:17:29 -04:00
phiresky
74701af627
Community post tags (part 2: API methods) (#5389)
* post tags part 2

* post tags part 2 (api methods)

* re-remove tracing

* api tests

* update according to comments

* update lints and api package

* validate tags, fix compile

* insert many simultaneously

* o

* temp revert for tests

* update dep

* Revert "temp revert for tests"

This reverts commit 62f17de60d.

* fix deps

* limit tag length

* fix comments

* rename display_name

* lint

* lint

* bullshit

* clarify comment

* fix after merge

* lint.sh

* upgrade dep

* rename

* dep

---------

Co-authored-by: Dessalines <tyhou13@gmx.com>
2025-04-04 14:26:25 -04:00
Nutomic
e4c87748bf
Move sql schema to separate Rust crate (#5581)
* Move db schema file to new crate

* db schema compiling

* wip

* db views

* compiling

* cleanup

* clippy

* fix path

* move some more files to new crate

* fixes

* fix

* fix
2025-04-03 19:21:27 -04:00
Dessalines
ba4c9a0c8f
Some site person ban fixes, and code cleanup (#5556)
* Receive and store remote site bans (fixes #3399)

* db schema changes, handly expiration

* partial federation changes

* add column `mod_ban.instance_id`

* remove unused

* wip: remove person.banned

* fix down migration

* fmt, keep banned status

* fixes

* simplify

* update post removed

* fix api tests

* ban from local instance

* banned() helpers

* cleanup undo_block_user

* remove order by

* cache SiteView::read_local, add instance

* use local instance id for PersonView

* add helper function person_with_instance_actions

* use exists

* comments update removed

* remove method is_mod_or_admin

* fix tests

* no unwrap

* change local_instance_person_join

* remove LocalSite::read

* wip: home_instance_actions

* add home_instance_actions to all structs

* fixes

* fix tests

* fmt

* Starting to work on site person ban fixes.

* Starting to work on comment_view

* Adding a few more views.

* Cleaning up a few more views.

* Finishing up a few more.

* Fixing unit tests.

- Also fixes #5502

* Fixing merge 2.

* Adding a creator_banned field

---------

Co-authored-by: Felix Ableitner <me@nutomic.com>
2025-04-03 12:08:52 +02:00
Richard Schwab
b892f3da59
remove unnecessary pictrs purge calls (#5565)
This commit removes various cases in which Lemmy would purge images from
pictrs, which would in many cases not be what admins intended.

pict-rs provides aliases on upload, which allows deduplicating multiple uploads
of the same file in the backend, while still providing unique URLs for uploads.

As Lemmy used pictrs' purge API, this meant that not only the image alias
referring to removed content was deleted, all other aliases were invalidated as
well.

Additionally, even alias deletion would not appropriate in many of these cases,
as they were lacking validation that they were exclusively used by the content
they were supposed to get removed with.

This implements the following changes:

1. Purging a community no longer purges the community banner or icon from
pict-rs.
2. Purging a community no longer purges all images referenced in post URLs and
post thumbnails within the community from pict-rs.
3. Banning a user with content removal no longer purges their profile avatar or
banner from pict-rs.
4. Banning a user with content removal no longer purges images referenced in
post URLs and post thumbnails for all posts they created from pict-rs.
5. Banning a user with content removal no longer purges the community banners
or icons for all communities they're the top mod of from pict-rs.
6. Banning a user with content removal now deletes all media they uploaded.
7. Purging a user no longer purges their profile avatar, banner, or images
referenced in post URLs and post thumbnails for all posts they created from
pict-rs. All media linked to their user account will still get deleted, which
was already explicitly the case in the past.
8. On an NSFW-disabled instance, receiving a post update via federation, which
changes the post from not NSFW to NSFW no longer purges post URL and thumbnail
from pict-rs.

Some of the mentioned actions will still remove references to image URLs from
the database, such as purging a community will still set its icon and banner to
`NULL` in the db, but the associated images will no longer be purged from
pict-rs.

As this stops erasure of thumbnails, #5564 has been created to ensure tracking
the person that triggered the creation of thumbnails, which will allow removing
them like other images.

The only remaining option to purge images attached to a post is now purging an
individual post, which still erases the post URL and thumbnail from pict-rs
entirely, including any other aliases. Purging and banning users with content
removal will remove all aliases associated with them, which will end up
deleting those images entirely when there are no other alias remaining.

fixes #5560
2025-04-01 10:33:08 +02:00
Nutomic
79f79a4e9a
Send out email after registration denied, email confirmed (fixes #5547) (#5553)
* Send out email after registration denied, email confirmed (fixes #5547)

* wip

* wip2

* all compiling

* cleanup

* move to subfolders

* update

* more fixes

* clippy

* remove line
2025-04-01 10:24:05 +02:00
Richard Schwab
8b7b3ce072
fix removal of post.instance_id (#5562)
this was originally removed in #5546, but #5515 introduced a new usage of it.
due to the order of PR merges this slipped through and broke the build on main.

fixes #5561
2025-03-31 09:44:55 +02:00
Nutomic
192344231c
Donation dialog changes (#5552)
* Remove disable_donation_dialog option

* Option to hide donation dialog permanently

* fix
2025-03-28 09:10:54 -04:00
Nutomic
636811eb8e
Receive and store remote site bans (fixes #3399) (#5515)
* Receive and store remote site bans (fixes #3399)

* db schema changes, handly expiration

* partial federation changes

* add column `mod_ban.instance_id`

* remove unused

* wip: remove person.banned

* fix down migration

* fmt, keep banned status

* fixes

* simplify

* update post removed

* fix api tests

* ban from local instance

* banned() helpers

* cleanup undo_block_user

* remove order by

* cache SiteView::read_local, add instance

* use local instance id for PersonView

* add helper function person_with_instance_actions

* use exists

* comments update removed

* remove method is_mod_or_admin

* fix tests

* no unwrap

* change local_instance_person_join

* remove LocalSite::read

* wip: home_instance_actions

* add home_instance_actions to all structs

* fixes

* fix tests

* fmt

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
2025-03-28 08:47:24 -04:00
Dessalines
0c78332881
Remove duped post.instance_id column. (#5546)
* Remove duped `post.instance_id` column.

- Fixes #5544

* Fix incorrect table ref.

* Fix diff check.

* Fix diff check 2.
2025-03-28 12:27:44 +01:00
Nutomic
4556a94387
Add plugin system (fixes #3562) (#5498)
* Add plugin system (fixes #3562)

* loading changes

* Use golang for default plugin (faster to compile)

* add remaining pre hooks

* Add remaining plugin hooks

* clippy

* Dont crash if plugin folder cant be read

* add metadata to /api/v4/site

* use plugin pool

* fix api common

* move plugin code to separate repo

* remove dbg

* fix api tests

* Add private message hooks

* only load plugin for epsilon test instance

* 1s timeout

* load plugin over http

* no return value for pre hooks

* dont run plugin hook code if no plugins loaded

* make plugin calls async

* clippy

* spawn_blocking

* fix vote hooks, add lemmy_url

* update before hooks, vote hooks

* adjust post hooks

* rename functions

* expose lemmy version to plugins

* fix hooks

* fix again

* update plugin

* not mut

* clippy

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
2025-03-28 10:54:02 +01:00
Nutomic
6aede48c1b
Add columns post.pending, comment.pending (#5499)
* Add columns post.pending, comment.pending

* add comments

* rename migration

* helper method, set not pending on vote received

* rename to federation_pending, add comments

* fix down migration
2025-03-25 11:43:25 +01:00
dullbananas
4c3a52e94c
Remove underscores that are no longer needed in impls/site.rs (#5507) 2025-03-15 13:11:52 -04:00
Nutomic
d78fe5fb1f
Community local removed (#5500)
* Better handling of local and remote bans (fixes #3399, ref #4571)

* rename migration

* basic code changes

* post/community pending

* revert person.local_banned

* ignore local_removed communities in queries

* fix test

* Add column `community.local_removed`

* fmt
2025-03-14 10:37:20 -04:00
Dessalines
5fa6a490d5
Create actions structs (#5482)
* migration

* update code

* tests

* triggers

* fix

* fmt

* clippy

* post aggregate migration

* changes for post aggregate code

* wip: update tests for post aggregate

* format

* fix partialeq

* trigger fix

* fix post insert trigger

* wip

* reorder

* fixes

* community aggregate migration

* update code

* triggers

* person aggregate migration

* person aggregate code

* person triggers

* test fixes

* fix scheduled task

* update api tests

* site_aggregates to local_site migration

* site_aggregates code changes

* triggers, tests

* more fixes

* Rename PersonPostAggregates to PostActions

* Merge local_user_vote_display_mode into local_user

* fix schema

* remove duplicate fields

* remove "aggregates" from index names

* uncomment indices

* if count = 0

* remove commentaggregates

* Fix triggers in remove aggregates tables pr (#5451)

* prevent all db_schema test errors

* fix the delete_comments_before_post problem in a way that doesn't affect the returned number of affected rows

* remove unnecessary recursion checks and add comment to remaining check

* clean up

* Fixing SQL format.

* Update triggers.sql

* Update triggers.sql

* Update triggers.sql

* Update triggers.sql

* remove update of deleted column

---------

Co-authored-by: Dessalines <tyhou13@gmx.com>

* rename migration

* Fix migration errors

* Move community.hidden to visibility (fixes #5458)

* Fixing person_saved_combined. (#5481)

* Remove comment and post specific action structs. #5473

* Doing reports

* fix up migration by dropping index

* also add enum variant `LocalOnlyPublic`, rename `LocalOnly` to `LocalOnlyPrivate`

fixes #5351

* fix column order in down.sql

* wip

* Moving blocks.

* Adding a few more views.

* more wip

* fixes

* migration for modlog

* fix migration

* Working views and schema.

* Fix ts_optionals.

* wip

* db_schema compiling

* make the code compile

* Merging from main.

* lint

* Fixing SQL format.

* fix down migration

* Fixing api tests.

* Adding field comments for the actions tables.

* Refactoring CommunityFollower to include follow_state

* fix test

* make hidden status federate

* ts attr

* fix

* fix api test

* Update crates/api/src/reports/post_report/resolve.rs

Co-authored-by: Nutomic <me@nutomic.com>

* Addressing PR comments

* Fix ts export.

* update api client

* review

* Extracting filter_not_hidden_or_is_subscribed (#5497)

* Extracting filter_not_hidden_or_is_subscribed

* Cleanup.

* Cleanup 2.

* Remove follower_state_helper function.

* Cleaning up some utils functions.

* rename hidden to unlisted

---------

Co-authored-by: Felix Ableitner <me@nutomic.com>
Co-authored-by: dullbananas <dull.bananas0@gmail.com>
2025-03-12 11:51:34 -04:00
Nutomic
8ffeeca52d
Changes to community visibility (#5478)
* Move community.hidden to visibility (fixes #5458)

* fix up migration by dropping index

* also add enum variant `LocalOnlyPublic`, rename `LocalOnly` to `LocalOnlyPrivate`

fixes #5351

* fix column order in down.sql

* wip

* more wip

* fixes

* migration for modlog

* fix migration

* wip

* db_schema compiling

* make the code compile

* lint

* fix down migration

* fix test

* make hidden status federate

* ts attr

* fix

* fix api test

* update api client

* review

* Extracting filter_not_hidden_or_is_subscribed (#5497)

* Extracting filter_not_hidden_or_is_subscribed

* Cleanup.

* Cleanup 2.

* rename hidden to unlisted

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
2025-03-12 09:45:02 -04:00
dullbananas
d93bfdd2fa
Update user count from local_user table instead of person table, and only count users with accepted application (#5495)
* Update user count from local_user instead of person, and only count users with accepted application

* fix

* Update up.sql

* Update down.sql
2025-03-11 16:37:40 +01:00
Dessalines
bb82e5dd43
Register users in a transaction. (#5480)
* Register users in a transaction.

- Fixes #5477

* Removing transactions from language code.

* Replace build_transactions with async transactions.

* Forgot one transaction.
2025-03-11 10:39:48 +01:00
Dessalines
91d10092b6
Adding pagination for GetBannedPersons (#5428)
* Extracting pagination cursor utils into a trait.

- Fixes #5275

* Refactoring to avoid stack overflows.

* Fixing api_common feature.

* Adding pagination for GetBannedPersons.

- Must come after #5424
- Fixes #2847

* Rename the traits and paginationcursor::new

* Using combined trait.

* Removing empty files.

* Merge from main, limit fetch.

* Adding local ban check, and ignore_page_limits.

* Only do page limits if not admin.
2025-03-11 09:41:02 +01:00
Nutomic
96e4621cb8
Dont force enable undetermined language anymore (fixes #5487) (#5491)
* Dont force enable undetermined language anymore (fixes #5487)

* fix test
2025-03-10 11:52:35 -04:00
dullbananas
08defa29fe
Add community reports to API (#5435)
* add routes

* implement some of api

* fix use of check_report_reason

* fix create_community_report

* fix all compile errors

* add field to reportcombined struct

* add CommunityReportView::read test

* import resolve_community_report

* remove references to deleted table

* resolve reports after remove
2025-03-10 09:37:50 -04:00
Nutomic
9a64902ace
Remove aggregate tables (fixes #4869) (#5407)
* migration

* update code

* tests

* triggers

* fix

* fmt

* clippy

* post aggregate migration

* changes for post aggregate code

* wip: update tests for post aggregate

* format

* fix partialeq

* trigger fix

* fix post insert trigger

* wip

* reorder

* fixes

* community aggregate migration

* update code

* triggers

* person aggregate migration

* person aggregate code

* person triggers

* test fixes

* fix scheduled task

* update api tests

* site_aggregates to local_site migration

* site_aggregates code changes

* triggers, tests

* more fixes

* Rename PersonPostAggregates to PostActions

* Merge local_user_vote_display_mode into local_user

* fix schema

* remove duplicate fields

* remove "aggregates" from index names

* uncomment indices

* if count = 0

* remove commentaggregates

* Fix triggers in remove aggregates tables pr (#5451)

* prevent all db_schema test errors

* fix the delete_comments_before_post problem in a way that doesn't affect the returned number of affected rows

* remove unnecessary recursion checks and add comment to remaining check

* clean up

* Fixing SQL format.

* Update triggers.sql

* Update triggers.sql

* Update triggers.sql

* Update triggers.sql

* remove update of deleted column

---------

Co-authored-by: Dessalines <tyhou13@gmx.com>

* rename migration

* Fix migration errors

* Fixing person_saved_combined. (#5481)

---------

Co-authored-by: dullbananas <dull.bananas0@gmail.com>
Co-authored-by: Dessalines <tyhou13@gmx.com>
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
2025-03-06 16:18:41 +01:00
Dessalines
a6507c169d
Extracting pagination cursor utils into a trait. (#5424)
* Extracting pagination cursor utils into a trait.

- Fixes #5275

* Refactoring to avoid stack overflows.

* Fixing api_common feature.

* Rename the traits and paginationcursor::new

* Using combined trait.

* Removing empty files.
2025-03-04 13:00:18 -05:00
flamingos-cant
e7ab5256f7
Add new setting to block NSFW content (#5436)
* Block NSFW content on instances with it disabled

* Make disallow_nsfw_content a local_site setting

* Clippy

* Add comma

* SQL fmt

* Newline

* Use func in apub + update js-client

* Remove extra db queries, add purge_post_images

* Add back local_site to funcs that need it

* Fix tests

* Add delay to api test

* Address comments

* Cleanup

* Return results from db func

* fmt

* Remove unneeded result

* Sync translations
2025-03-03 11:46:39 +01:00
Nutomic
a65d4034d8
Reduce usage of async_trait (#5438)
* Reduce usage of async_trait

* use trait

* move dep
2025-02-19 11:06:22 -05:00
Dessalines
a4bf28e123
Use rust:1.81 for CI. (#5423)
* Use rust:1.81 for CI.

- Should speed up CI jobs a lot, due to the diesel issues with 1.82+.

* Upgrading deps.
2025-02-13 09:51:42 +01:00
Nutomic
0e87900953
Allow sending report only to admins (fixes #2414) (#5350)
* Allow sending report only to admins (fixes #2414)

* fix api test

* Rename `to_local_admins` to `violates_instance_rules`

* Review fixes

* fix api test
2025-02-12 16:34:43 +01:00