Commit graph

312 commits

Author SHA1 Message Date
Dessalines
644a448aa9
[main] Fixing active counts slow queries. (#5907) (#5917)
* [0.19] Fixing active counts slow queries. (#5907)

* Fixing active counts slow queries.

* Simplify back to str tuple

* Batch site and community updates

* Using update from temp table

* Making aggs temp table use interval name.

* Make dev setup use optimized postgres.

* Addressing PR comments.

* Use ref

* Removing system custom info from customPostgresql.conf

* Forgot to remove old scheduled tasks.

* Making sure migrations aren't missing anything from release/v0.19

Checked using git diff --diff-filter D --stat release/v0.19 migrations

* Rename all migrations to come after release/v0.19 migrations

* Add liked_at is not null check.
2025-08-09 21:57:38 +02:00
Dessalines
5dcf69f0b5
Adding a local_site and local_user setting for default fetch limit (#5887)
* Adding a local_site and local_user setting for default fetch limit

- Currently only used for list_posts and list_comments, like the other
defaults.
- Fixes #5474

* Addressing PR comments.
2025-07-29 10:31:26 -04:00
Dessalines
f1ba2a2dbf
Add ability to block all users of an instance. (#5784)
* Fixing a few optionals.

* Fixing note.

* Starting to work on instance user blocking.

* Finishing up user instance blocking

* SQL fmt

* fmt.

* Fixing search_combined

* Fixing API tests.

* Fixing api-common imports.

* Fixing merge issues.

* Update crates/api/api_utils/src/utils.rs

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

* Making clearer alias names

* Submodules

* Submodules 2

* Format

* Remove api misc.

* Upgrading lemmy js client, fixing merge

* Prettier

* Fixing merge.

* Addressing PR comment.

* Fix some stack overflows.

* Fixing api tests.

* Fixing notification joins.

* Adding alias.

* Fixing api test files.

* Remove some tmp files.

* Change back to localhost.

* Remove instance_person and instance_communities actions from views.

These are only used for internal filtering, blocks and bans anyway.

* Removing a few unused joins.

* Fix API tests.

* Some lints.

* Updating js-client

* Try fixing test.

* Update crates/db_views/site/src/api.rs

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

* Fixing blocked_instances save_user_settings.

---------

Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: dullbananas <dull.bananas0@gmail.com>
2025-07-29 09:52:37 +02:00
Nutomic
398237b02a
Rename modlog items (#5882)
* Rename modlog items

* wip: update schema

* update code

* move
2025-07-28 10:17:17 +02:00
Nutomic
7dfd5ef9e7
Finish adding post tags (#5869)
* add incoming tags federation

* submit activity update on tags change

* community tag federation test

* tag federation tests

* lint

* sql

* remove logs

* add index name, some comments

* fix comments

* clippy

* rename tags for posts

* fix tests

* wip

* cleanup

* simplify Tag::update_many

* separate name, display_name

* update apub examples

* objects have no displayname so remove it again

* add http endpoint

* clippy

* api tests

* federated api test

* simplify comments

* remove old files

* remote mod

* reorder

* change join

* update tags api

* add missing checks for multi-comm

* allow remote mods to edit tags

* helper function

* max tags count

* add description, background_color

* shear

* add mod update post endpoint

* move db read

* handle conflict

* federate as `CommunityPostTag`

* clippy

* remove background color, add display name

* add comments

* working federation

* test fix

* more fix

* fix api tests

---------

Co-authored-by: phiresky <phireskyde+git@gmail.com>
2025-07-24 07:57:01 -04:00
Dessalines
a5b0475436
Fast history no background (#5873)
* Finishing up post and comment actions

* Adding community_actions.

* instance and person actions

* Fixing person_actions.

* Fixing down migrations

* Adding person_content_combined.

* Search combined.

* Aggregates tables.

* Dont rename old tables

* Fixing some constraints.

* Convert bigints to ints

* Forgot a bigint.

* Rest of i64 -> i32

* Adding actions id columns.

* Fixing connection config.

* Formatting smoosh up.sql

* Use current_date instead of now

* Adding history tables for liked_combined

* Upping wal size

* Fix clippy

* Fixing clippy.

* Fixing i64

* Getting rid of let mut conn

* Adding the history status table.

* Adding published indexes to speed up history.

* Adding comment like history scanning.

* Fixing schema options setup.

* post_read history

* person_post_aggregates / read_comments history

* post_like history

* Fixing conflicts.

* Fixing clippy.

* Use constant batch_size.

* person content combined post and comment history.

* Fixing id scanning.

* post/comment_actions -> saved_combined history

* search history

* Post and comment aggregates -> post / comment history.

* Uncommenting full history building.

* Changing DB_BATCH_SIZE to i64

* Fixing clippy.

* Fix index names.

* Fixing diff check by removing indexes.

* Adding the uplete ignore actions::id columns.

* Fixing merge imports.

* Fixing submodule update

* Try trigger disabling.

* Fix clippy

* Remove history table, do faster bulk inserts. Smoosh first.

Comments about how this fast insert is done is within smoosh comments.

* Adding some timings.

* Fast person content combined history

* Adding search_combined

* Fix person saved combined unique names

* person_liked_combined

* Remove-aggregates

* Fixing up.sql issues

* Re-building schema.rs

* Fixing down migrations.

* Removing history updating.

* Format sql.

* Move postgres logging to customPostgresql.conf

* Try using postgres 16-alpine in CI

* Speeding up add_report_count.

* speed up inbox_combined

* Speeding up remove_post_sort_type_enums

* Fixing post_sort_type

* Speeding up person votes

* Fixing wrong conn.

* Fixing broken migrations

* Remove comment.

* Make sure to re-index table after re-enabling indexes.

* Removing id columns from actions tables.

* Fixing down migrations.

* Using create table as for smoosh migration

* create_table as for person_content_combined.

* Fixing person_content_combined uniques

* create table as for search_combined

* create table as for liked_combined

* create table as for inbox_combined.

* Fixing a few score types.

* Fixing id positions.
2025-07-23 17:43:23 -04:00
Nutomic
6e292141cc
Allow remote groups to follow Lemmy communities (fixes #5354) (#5864)
* Allow remote groups to follow Lemmy communities (fixes #5354)

* index

* rename columns

* review changes

* primary key
2025-07-22 15:37:15 -04:00
Nutomic
40c89f99ca
Fix foreign key indexes migration (#5875) 2025-07-21 11:02:51 -04:00
dullbananas
de7d6ef148
Require indexes for all foreign keys (#5872)
* add test

* add migration with missing indexes
2025-07-21 09:56:58 +02:00
Nutomic
72d254b4db
Notifications rewrite and post following (fixes #3069) (#5604)
* Add post_actions.disable_notifications (fixes #3042)

* Split up logic for send_local_notifs()

* refactor

* fmt

* add api endpoint, check

* dont call send_local_notifs from comment delete/remove

* move scrape_text_for_mentions() inside send_local_notifs()

* nullable

* simplify

* handle parent notification first

* cleanup

* remove `CommentResponse.recipient_ids`

* post notifications enum

* Follow posts (fixes #3069)

* use references

* cleanup

* new file

* db migration to merge mention, reply tables

* code adjustments

* adjust test code

* adjust enum case

* wip: get rid of inbox_combined table

* add table local_user_notification

* tests compiling

* get rid of inbox_combined, only use notification table

* rename view

* notify private messages

* clippy

* copy existing data

* wip: tests

* move tests

* clippy

* notify post subscribers

* community subscribe

* test fixes

* migration fix

* rename routes

* separate struct for api

* rename api params

* merge migrations

* separate notification modes for post/community

* fix

* down migration copy data

* test fix

* update api tests

* only single notification table

* clippy

* use local user id for recipient

* fix comments

* rename table

* recipient local user

* add indices

* keep local user id

* renames and cleanup

* NotificationDataType

* change notification response

* fix api tests

* test fix

* remove private_message.read

* fixes

* test fix

* fix
2025-07-17 19:04:09 -04:00
Dessalines
31dd9719b0
Fixing username-instance duplicate migration. (#5867)
Context: #5045 , #5858
2025-07-17 09:32:54 +02:00
Nutomic
cf0e021129
Add unique constraint for person(name, instance) (fixes #5045) (#5858)
* Add unique constraint for person(name, instance) (fixes #5045)

* fix

* not local

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

---------

Co-authored-by: dullbananas <dull.bananas0@gmail.com>
2025-07-14 17:14:05 -04:00
Nutomic
3922f0f325
Revert " Add post_actions.disable_notifications (fixes #3042) (#5826)" (#5843)
This reverts commit 76fbb29079.
2025-07-02 11:29:42 +02:00
Nutomic
76fbb29079
Add post_actions.disable_notifications (fixes #3042) (#5826)
* Add post_actions.disable_notifications (fixes #3042)

* Split up logic for send_local_notifs()

* refactor

* fmt

* add api endpoint, check

* dont call send_local_notifs from comment delete/remove

* move scrape_text_for_mentions() inside send_local_notifs()

* nullable

* simplify

* handle parent notification first

* cleanup

* remove `CommentResponse.recipient_ids`

* post notifications enum

* adjust enum case
2025-06-30 09:52:19 +02:00
Nutomic
d77c9a0544
Drop table person_ban (fixes #5828) (#5831) 2025-06-26 13:13:39 -04:00
Dessalines
a6b03fabdb
Keep totals of upvotes and downvotes given to each user. (#5786)
* Keep totals of upvotes and downvotes given to each user.

- Adds a `voted_at`, `upvotes` and `downvotes` to person_actions.
- Didn't use triggers, because I couldn't figure out how to get the
  voter, and also because it should only be for local users anyway.
- Fixes #2370

* Clippy

* Adding history filling.

* Try to fix postgres alias error 1

* Update crates/db_schema/src/impls/person.rs

Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com>

* Addressing PR comments

* Removing commented line.

* Fixing type errors.

* Fixing test

* Fixing like score 0 and api test errors.

* Some clippy fixes

* Update migrations/2025-06-14-141408_person_votes/up.sql

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

* Update migrations/2025-06-14-141408_person_votes/up.sql

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

* Update migrations/2025-06-14-141408_person_votes/up.sql

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

* Formatting sql

* Fixing migration.

* Cleaning up merge

---------

Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com>
Co-authored-by: dullbananas <dull.bananas0@gmail.com>
2025-06-26 09:58:10 +02:00
Dessalines
78fc703ebd
Optimizing person_content_combined migration. (#5819) 2025-06-26 09:40:21 +02:00
Dessalines
7e55a39677
Optimizing a few more combined migrations (#5821)
* Add indexes after insert to search_combined.

* Add indexes after for inbox_combined.

* Move index after for modlog combined.

* Fixing unique.
2025-06-24 10:22:17 -04:00
Nutomic
99ec0b7116
Rename rate limit columns (fixes #5805) (#5824)
* Rename rate limit columns (fixes #5805)

* update js client
2025-06-24 10:21:50 -04:00
Nutomic
497ec72f26
Optimize migrations (#5800)
* Fix migration local_image_person

* Make constraints deferrable (ref #5798)

* Some more adjustments

* fix down migrations

* set not deferrable once done

* fix

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
2025-06-23 08:05:21 -04:00
Dessalines
e07e251ada
Removing an existing deferrable constraint, and fail test if any constraint is deferrable. (#5806)
* Removing an existing deferrable constraint.

- Also adding a check to make sure the final dump contains no DEFERs.

* Spelling error
2025-06-20 09:49:44 +02:00
Nutomic
9a84180b5a
Fix migration local_image_person (#5799) 2025-06-18 08:56:01 -04:00
Anton Boitsov
070d049c49
Test migrations improvement (#5788)
* some test data in migration tests after initial setup (40 migrations)

* - fixed migration rollbacks creating NOT NULL fields without DEFAULT value
- added couple of checks

* fix sql fmt

* fix sql fmt

* allow indexing and unwrapping in tests
2025-06-18 09:39:08 +02:00
Nutomic
bc23e95f50
Implement multi-community (fixes #818, fixes #5340) (#5601)
* Implement multi-community (fixes #818, fixes #5340)

* db methods

* add api methods

* ts opt

* wip

* sql queries

* cleanup

* wip: federation

* query by name

* add ap_id column

* add read_apub, compiles now

* validate multi-comm name

* disallow removed, deleted, private

* scheduled task

* remove piefed test

* resolve_object with workaround

* review

* avoid db read

* api client

* fix api test fetch

* wip: test cases

* wip

* add max elements, array_remove comments

* simplify post view query

* mvoe structs

* fix api test

* fix api test

* rename to suggested_communities, add api param

* filter removed/deleted

* check_api_elements_count

* filter out removed/deleted during update

* inner join

* add listing type suggested

* db schema changes

* transaction

* address some review comments

* separate methods for create, delete entry

* update js client

* get multi

* remove CommunityOrMulti

* check helper, other stuff

* fix api test

* change get multi comm return type

* Replace MultiCommunityView with GetMultiCommunityResponse

* get rid of todo

* add local column, admins can edit local multi-comm

* implement multi-comm follow (db and api)

* api for multi-comm follow

* move and rename MultiCommunityApub

* move multi-comm to apub-objects

* move multi-comm url to top-level

* list multi-comms followed by user

* add todo

* remove param

* update local follows

* update query

* db functions and tests

* cleanup

* fix api test

* add entry limit

* rewrite links

* federation changes

* wip federation

* simplify generate_activity_id

* more wip

* more wip

* multi-comm follow

* federate changes

* cleanup

* clippy

* test fixes

* fmt

* fix

* wip: update follows after federated multi-comm change

* remove scheduled task

* update follows after multi update

* fmt

* fixes

* review comments

* indexes

* remove MultiCommunityApub

* fix test

* ts fix

* review

* db schema for local_site.multi_comm_follower

* adjust code and tests

* fixes

* cleanup, comment

* fix tests

* fix

* remove more test code

* fix new install

* add index

* fix api tests

* fix

* remove index

* more fix

* Implement multi-community search (fixes #5778) (#5779)

* Implement multi-community search (fixes #5778)

* fixes

* search title and description

* MultiCommunityView

* rename fields

* revert test change
2025-06-17 11:04:47 +02:00
dullbananas
bb63eaa794
Improve migration diff check and fix old migrations (#5204)
* Update schema.rs

* rename

* stuff

* finish new implementation of schema_setup::run (not including revert, test, etc.)

* fmt

* refactor

* fix sql

* migriation run command

* use trigger on migrations table

* add Options with disable_migrations field for test

* rename to enable_forbid_diesel_cli_trigger

* fix

* fix merge

* diff_checker (partial)

* Revert "diff_checker (partial)"

This reverts commit 6709882e14.

* Revert "Revert "diff_checker (partial)""

This reverts commit d4bdda5d11.

* diff check

* improve schema diff

* timestamp replacement

* ignore column order

* remove fedi_name default

* stuff

* improve diff

* stuff

* attempt parallel pg_dump

* attempt 2

* Revert "attempt 2"

This reverts commit a909d2d643.

* Revert "attempt parallel pg_dump"

This reverts commit 592a127954.

* improve diff check

* finish fixing migrations

* stuff

* use advisory lock

* stuff

* Update lib.rs

* fmt

* fmt

* clippy

* Update diff_check.rs

* Update .woodpecker.yml

* Update lib.rs

* Update lib.rs

* Update lib.rs

* Update .woodpecker.yml

* Update .woodpecker.yml

* Update lib.rs

* re-run ci

* fmt

* fmt

* Update .woodpecker.yml

* Update .woodpecker.yml

* create separate database in ci

* Update .woodpecker.yml

* Update .woodpecker.yml

* Update .woodpecker.yml

* Update .woodpecker.yml

* try to fix env var

* Update diff_check.rs

* Remove condition that's not needed anymore

* clippy

* exclude views and fast tables

* revert some migration changes

* fix

* fmt

* re-attempt checking character after skipped trigger name, and make code less confusing

* fmt

* fix

* rerun ci

* rerun ci

* fix strip_prefix order

* fix weird big Cargo.lock change by running `git checkout upstream/main Cargo.lock` then letting it auto update again

* fix

* remove installation commands that were removed in main branch

* Revert "remove installation commands that were removed in main branch"

This reverts commit fd65234a76.

* move create_database_user woodpecker step to make diff less weird

* Fix migration duplication caused by merge

* optimize

* Merge remote-tracking branch 'upstream/main' into new-migration-diff-check

* fmt

* Revert "fmt"

This reverts commit 7d5652945f.

* Revert "Merge remote-tracking branch 'upstream/main' into new-migration-diff-check"

This reverts commit 28bb1c7497.

* fmt

* move diff dependency to db_schema_file

* stuff

* revert some migration changes

* stuff

* refactor pair selection

* fix all migrations

* clippy

* stuff

* remove thing from removed dbg

* remove use of BTreeSet::difference

* trim_matching_chunks_at_beginning_and_end

* use sorted_unstable itertools method

* display_diffs

* use aho-corasick for chunk filtering

* fsync=off

* remove some unimportant optimizations

* Revert "remove some unimportant optimizations"

This reverts commit f8d88ddcce.

* Revert "use aho-corasick for chunk filtering"

This reverts commit 6b1f3e4416.

* remove some unimportant optimizations

* refactor diff_check.rs

* clippers
2025-06-16 11:35:41 -04:00
Dessalines
d9df8335ea
Adding ability to make a note for a given person. (#5765)
* Adding ability to make a note for a given person.

- This comes back with PersonActions.note, already on post and comment
  views.
- Also adds person_actions to PersonView, so that the read person API
  action can return the note.
- Fixes #2353

* Adding unit test for person_view read.

* Fixing bindings check

* Addressing PR comments

* Moving API action to person/note
2025-06-12 16:29:03 +02:00
Dessalines
398c9ec967
Rename timestamp fields to _at (#5761)
* Adding migration for renaming timestamps to at

* Running format.

* Updating code to _at

* Fix replaceable schema

* Fixing scheduled tasks.

* Fixing and cleaning up api tests.

* Fixing cargo shear.
2025-06-11 09:38:24 +02:00
Nutomic
cbb780f79a
Rename upgrade check migration to run first (#5768)
* Rename upgrade check migration to run first

* fix column name
2025-06-10 10:28:51 -04:00
dullbananas
9f425b8f42
Throw error if the removed code_migrations.rs needed to run but didn't (#5723)
* Throw error if the removed code_migrations.rs needed to run but didn't

* support postgresql 15

* improve error message

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
2025-06-03 11:38:50 -04: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
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
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
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
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
matc-pub
4b877c5119
Update mod_ban.instance_id for existing entries (#5627)
* Update mod_ban.instance_id for existing entries

* Update mod_ban.instance_id in site_person_ban migration
2025-04-24 12:15:57 +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
Nutomic
a931a4b289
Increase registration rate limit to 10 per hour (ref #5548) (#5600) 2025-04-07 14:31:20 -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
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
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
matc-pub
3664f987d3
Fix migration problems with initially deferred and not null constraints (#5533)
Executes `SET CONSTRAINTS xyz IMMEDIATE;` before `CREATE INDEX` and
`ALTER COLUMN` that otherwise fail because of "pending trigger events".
2025-03-25 10:24:51 +01: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