Commit Graph

49 Commits (e84e25d8fa43fc57d590000cec3cd556ba129be2)

Author SHA1 Message Date
Dessalines 95069d7648
Fixing some clippy and woodpecker lints. (#4565)
* Fixing some clippy and woodpecker lints.

* Try fixing woodpecker 1.

* Revert "Try fixing woodpecker 1."

This reverts commit 7c2020a08d.
2 months ago
Nutomic 846848c4f6
On registration, automatically set content languages from `accept-language` header (#4550)
* On registration, automatically set content languages from accept header

* no need to set site language or default language for new user anymore

* fix test

* fix langs

* avoid duplicate writing of new user languages
2 months ago
Dessalines 255e695633
Adding extra fields to PostReport and CommentReport views. (#4520)
- Fixes #4200
2 months ago
Dessalines 15f02f00a9
Add a vote_display_mode local_user setting. (#4450)
* Add a vote_display_mode local_user setting.

- Fixes #4449

* Changing HideDownvotes to Score.

* Adding ScoreAndDownvote display mode.

* Adding upvote and downvote mode.

* Extracting vote_display_mode to another table.

* Fixing fmt.

* Remove published and updated columns.

---------

Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com>
2 months ago
Dessalines 52155c74cb
View report history for a post or comment. Fixes #4190 (#4492) 3 months ago
Dessalines a3bf2f1cf1
Auto resolve reports on removing a comment or post. Fixes #4390 (#4402)
* Automatically resolve report when post/comment is removed (#3850)

* Automatically resolve report when post/comment is removed

* also handle apub removes

* Removing auto-resolve report triggers.

* Dont allow creating reports for deleted / removed items.

* Running pgformat.

* Fixing test.

* Addressing PR comments.

* Forgot comment report.

---------

Co-authored-by: Nutomic <me@nutomic.com>
3 months ago
Nutomic 38e64825e6
Add macro assert_length!() for tests (#4348)
* Add macro assert_length!() for tests

* fix

* number
5 months ago
ALEX11BR a5289dd4cf
Use `pretty_assertions` for assertions (#4347)
* Use `pretty_assertions` for assertions

* fixed ordering of `use`s

* ci

---------

Co-authored-by: Felix Ableitner <me@nutomic.com>
5 months ago
Dessalines 86990d5138
Registrations and Reports should sort by New when viewing unresolved / unread. (#4207)
- Fixes #4206
6 months ago
dullbananas 8e2cbc9a0f
Remove id column and use different primary key on some tables (#4093)
* post_saved

* fmt

* remove unique and not null

* put person_id first in primary key and remove index

* use post_saved.find

* change captcha_answer

* remove removal of not null

* comment_aggregates

* comment_like

* comment_saved

* aggregates

* remove "\"

* deduplicate site_aggregates

* person_post_aggregates

* community_moderator

* community_block

* community_person_ban

* custom_emoji_keyword

* federation allow/block list

* federation_queue_state

* instance_block

* local_site_rate_limit, local_user_language, login_token

* person_ban, person_block, person_follower, post_like, post_read, received_activity

* community_follower, community_language, site_language

* fmt

* image_upload

* remove unused newtypes

* remove more indexes

* use .find

* merge

* fix site_aggregates_site function

* fmt

* Primary keys dess (#17)

* Also order reports by oldest first (ref #4123) (#4129)

* Support signed fetch for federation (fixes #868) (#4125)

* Support signed fetch for federation (fixes #868)

* taplo

* add federation queue state to get_federated_instances api (#4104)

* add federation queue state to get_federated_instances api

* feature gate

* move retry sleep function

* move stuff around

* Add UI setting for collapsing bot comments. Fixes #3838 (#4098)

* Add UI setting for collapsing bot comments. Fixes #3838

* Fixing clippy check.

* Only keep sent and received activities for 7 days (fixes #4113, fixes #4110) (#4131)

* Only check auth secure on release mode. (#4127)

* Only check auth secure on release mode.

* Fixing wrong js-client.

* Adding is_debug_mode var.

* Fixing the desktop image on the README. (#4135)

* Delete dupes and add possibly missing unique constraint on person_aggregates.

* Fixing clippy lints.

---------

Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: phiresky <phireskyde+git@gmail.com>

* fmt

* Update community_block.rs

* Update instance_block.rs

* Update person_block.rs

* Update person_block.rs

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: phiresky <phireskyde+git@gmail.com>
6 months ago
Nutomic cf788334aa
Also order reports by oldest first (ref #4123) (#4129) 7 months ago
Nutomic a0ea8dbc00
Auto resolve reports trigger (#3871)
* Revert "Automatically resolve report when post/comment is removed (#3850)"

This reverts commit f7f6766650.

* Automatically resolve reports using db trigger

* lint

* use mod log tables

* fix migration

* fix ci

* fix clippy
9 months ago
dullbananas 15930cbf4d
Use Queryable instead of JoinView (#3917)
* Update utils.rs

* Update traits.rs

* Update comment_report_view.rs

* Update comment_view.rs

* Update local_user_view.rs

* Update post_report_view.rs

* Update post_view.rs

* Update private_message_report_view.rs

* Update private_message_view.rs

* Update registration_application_view.rs

* Update site_view.rs

* Update structs.rs

* Update comment_reply_view.rs

* Update community_block_view.rs

* Update community_follower_view.rs

* Update community_moderator_view.rs

* Update community_person_ban_view.rs

* Update community_person_ban_view.rs

* Update community_view.rs

* Update person_block_view.rs

* Update person_mention_view.rs

* Update person_view.rs

* Update structs.rs

* Update admin_purge_comment_view.rs

* Update admin_purge_community_view.rs

* Update admin_purge_person_view.rs

* Update admin_purge_post_view.rs

* Update mod_add_community_view.rs

* Update mod_add_view.rs

* Update mod_ban_from_community_view.rs

* Update mod_ban_view.rs

* Update mod_feature_post_view.rs

* Update mod_hide_community_view.rs

* Update mod_lock_post_view.rs

* Update mod_remove_comment_view.rs

* Update mod_remove_community_view.rs

* Update mod_remove_post_view.rs

* Update mod_transfer_community_view.rs

* Update structs.rs

* Update utils.rs

* Update private_message_view.rs

* Update comment_report_view.rs

* Update registration_application_view.rs

* Update utils.rs

* fix

* fix db_views

* fix

* Update comment_view.rs
9 months ago
Nutomic 6047257bfc
Move admin flag from person to local_user (fixes #3060) (#3403)
* Move admin flag from person to local_user (fixes #3060)

The person table is for federated data, but admin flag can only
apply to local users. Thats why it really belongs in the local_user
table. This will also prevent the federation code from accidentally
overwriting the admin flag

* fmt

* try to fix api tests

* lint

* fix person view

* ci

* ci

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
9 months ago
Freakazoid182 c8063f3267
Replace Option<bool> with bool for PostQuery and CommentQuery (#3819) (#3857)
* Replace Option<bool> with bool for PostQuery and CommentQuery (#3819)

* Replace Option<bool> from all list queries (#3819)

---------

Co-authored-by: Freek van Zee <freek.van.zee@mediamonks.com>
9 months ago
dullbananas a47b12bbde
Reduce amount of columns selected (#3755)
* PostAggregatesNotInPost

* CommentAggregatesNotInComment

* CommunityPersonBanAdditionalInfo (partial)

* Revert "CommunityPersonBanAdditionalInfo (partial)"

This reverts commit 158f7f0cd9.

* Replace some nullable parts of selection with id::nullable().is_not_null()

* CommunityFollower::select_subscribed_type

* WithoutId

* Add WithoutId derives

* Update Cargo.toml

* rerun ci

* Fix syntatx errors

* rerun ci

* Add missing "|" in private_message_report_view.rs

* rerun ci

* cargo fmt

* rerun ci

* Only derive WithoutId for Community with "full" feature

* rerun ci

* Fix attribute filtering in WithoutId macro

* rerun ci

* Update without_id.rs

* rerun ci

* Update without_id.rs

* rerun ci

* Fix errors

* rerun ci

* cargo fmt

* Fix errors

* rerun ci

* Move WithoutId to lib.rs

* rerun ci

* Remove macro_use for paste

* rerun ci

* Update comment_reply_view.rs

* rerun ci

* Update registration_application_view.rs

* rerun ci

* Revert "Update registration_application_view.rs"

This reverts commit 2e98e4bb83.

* Revert "Update comment_reply_view.rs"

This reverts commit 857bf9f5a2.

* Revert "Remove macro_use for paste"

This reverts commit 13247279ed.

* Revert "Move WithoutId to lib.rs"

This reverts commit 0c23e5213b.

* Revert "Fix errors"

This reverts commit a283d155e5.

* Revert "cargo fmt"

This reverts commit 36a5210352.

* Revert "Fix errors"

This reverts commit c9102c14f4.

* Revert "Update without_id.rs"

This reverts commit 19adb2fcc8.

* Revert "Update without_id.rs"

This reverts commit e26107a2fe.

* Revert "Fix attribute filtering in WithoutId macro"

This reverts commit acaa4902b0.

* Revert "Only derive WithoutId for Community with "full" feature"

This reverts commit de0e9c6fdc.

* Revert "cargo fmt"

This reverts commit 5e1bd1ce58.

* Revert "Add missing "|" in private_message_report_view.rs"

This reverts commit c7ae9f1cd5.

* Revert "Fix syntatx errors"

This reverts commit d942f099de.

* Revert "Update Cargo.toml"

This reverts commit 23cdb6f6d3.

* Revert "Add WithoutId derives"

This reverts commit 06006d6ad3.

* Revert "WithoutId"

This reverts commit 5e86922b0f.

* Revert "CommentAggregatesNotInComment"

This reverts commit 603aede7ce.

* Revert "PostAggregatesNotInPost"

This reverts commit 1ee3fcaeab.

* Restore original position of options.saved_only filter

* rerun ci

* Update post_view.rs

* rerun ci
10 months ago
dullbananas 9a5a13c734
Use same table join code for both read and list functions (#3663)
* Try stuff

* Revert "Try stuff"

This reverts commit 3da5f83a8b.

* Revert "Revert "Try stuff""

This reverts commit 178bd43cac.

* Revert "Revert "Revert "Try stuff"""

This reverts commit b9f9a2316e.

* Revert "Revert "Revert "Revert "Try stuff""""

This reverts commit ccd498dd72.

* Try more stuff

* Add queries function

* Simplify queries function

* Move aliases to db_schema

* Revert "Move aliases to db_schema"

This reverts commit 69afed05c1.

* Add ReadFuture and ListFuture

* Refactor queries function and add Queries struct

* Box futures in Queries::new

* Use from_tuple

* Add comment_view::queries and improve comment_report_view::queries

* Add local_user_view::queries

* Add post_report_view::queries

* Ad post_view::queries

* Add private_message_report_view::queries

* private_message_view, registration_application_view

* Use 'a in BoxedQuery

* comment_reply_view, community_view

* Change aliases to inline module

* person_mention_view

* person_view

* Use separate community_person_ban joins instead of including boolean literal in join-on clause

* Fix comment_view

* rerun ci
10 months ago
Pavlos Smith c890797b37
Add controversial ranking (#3205)
* Added controversy rank property to posts and comments, and ability to sort by it

* Triggers instead of schedules tasks, integer -> double, TODO: comments don't seem to get updated with floats, divide SortTypes

* Created PersonSortType

* PersonSortType::MostComments case

* Removed unused PartialOrd trait

* Added new person sort type mappings

* SortType -> PersonSortType

* fixes

* cargo fmt

* fixes after merge with main

* Fixed bug in controversy rank trigger, removed TopX sorts from PersonSortType and added CommentScore instead

* Uncovered enum case

* clippy

* reset translation changes

* translations

* translations

* Added additional hot ordering on controversial posts and comments

* featured local and featured community added to controversy rank index, additional order_by removed (?), added post_score and post_count to PersonSortType

* Woodpecker rerun

* cargo fmt

* woodpecker rerun

* fixed controversy_rank order

* fix

* Readded migration as latest, removed second update statement for setting controversy rank
10 months ago
Sander Saarend b511c2e6cb
Denormalize community_id into post_aggregates for a 1000x speed-up when loading posts (#3653)
* Denormalize community_id into post_aggregates for a 1000x speed-up when loading posts

* Remove unused index

* Add creator_id to post_aggregates

* Use post_aggregates as main table for PostQuery

* Make post_aggregates the main table for PostView

* Reformat SQL
10 months ago
cetra3 9256895635
Cache & Optimize Woodpecker CI (#3450)
* Try using drone cache plugin

* Try another path

* Include volume

* Fix formatting

* Include fmt

* Exclude cargo dir from prettier

* Don't override cargo

* Just do check

* Add cache key

* Use different cache plugin

* Add clippy

* Try minio

* Add quotes

* Try adding secrets

* Try again

* Again

* Use correct secret formation

* Add back clippy

* Use secret for the root bucket name

* Try drone cache instead

* Add region

* Add path-style option

* Include cargo clippy

* Include everything again

* Fix formatting

* Don't run clippy twice

* Add `allow` statements for tests to pass

* Adjust endpoint to be a secret

* Fix prettier

* Merge & fix tests

* Try to restart the woodpecker test

* Change the ENV var name

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
10 months ago
dullbananas 88215bfbc9
Remove TypedBuilder from db_views and db_views_actor (#3637)
* change pool fields to parameters for list

* remove my_person_id and admin fields

* Change recipient id to list param

* Remove TypedBuilder from db_views and db_views_actor
10 months ago
dullbananas 1d38aad9d3
Make functions work with both connection and pool (#3420)
* a lot

* merge

* Fix stuff broken by merge

* Get rid of repetitive `&mut *context.conn().await?`

* Add blank lines under each line with `conn =`

* Fix style mistakes (partial)

* Revert "Fix style mistakes (partial)"

This reverts commit 48a033b87f.

* Revert "Add blank lines under each line with `conn =`"

This reverts commit 773a6d3beb.

* Revert "Get rid of repetitive `&mut *context.conn().await?`"

This reverts commit d2c6263ea1.

* Use DbConn for CaptchaAnswer methods

* DbConn trait

* Remove more `&mut *`

* Fix stuff

* Re-run CI

* try to make ci start

* fix

* fix

* Fix api_common::utils

* Fix apub::activities::block

* Fix apub::api::resolve_object

* Fix some things

* Revert "Fix some things"

This reverts commit 2bf8574bc8.

* Revert "Fix apub::api::resolve_object"

This reverts commit 3e4059aabb.

* Revert "Fix apub::activities::block"

This reverts commit 3b02389abd.

* Revert "Fix api_common::utils"

This reverts commit 7dc73de613.

* Revert "Revert "Fix api_common::utils""

This reverts commit f740f115e5.

* Revert "Revert "Fix apub::activities::block""

This reverts commit 2ee206af7c.

* Revert "Revert "Fix apub::api::resolve_object""

This reverts commit 96ed8bf2e9.

* Fix fetch_local_site_data

* Fix get_comment_parent_creator

* Remove unused perma deleted text

* Fix routes::feeds

* Fix lib.rs

* Update lib.rs

* rerun ci

* Attempt to create custom GetConn and RunQueryDsl traits

* Start over

* Add GetConn trait

* aaaa

* Revert "aaaa"

This reverts commit acc9ca1aed.

* Revert "Revert "aaaa""

This reverts commit 443a2a00a5.

* still aaaaaaaaaaaaa

* Return to earlier thing

Revert "Add GetConn trait"

This reverts commit ab4e94aea5.

* Try to use DbPool enum

* Revert "Try to use DbPool enum"

This reverts commit e4d1712646.

* DbConn and DbPool enums (db_schema only fails to compile for tests)

* fmt

* Make functions take `&mut DbPool<'_>` and make db_schema tests compile

* Add try_join_with_pool macro and run fix-clippy on more crates

* Fix some errors

* I did it

* Remove function variants that take connection

* rerun ci

* rerun ci

* rerun ci
10 months ago
Dessalines 8cb5939f50
Adding hot_rank columns in place of function sorting. (#2952)
* Adding hot_rank columns in place of function sorting.

- Creates hot_rank columns for post, comment, and community.
- Fixes #2932

* Updating all hot ranks on startup.

* Fixing post.url migration.

* Removing update_instance_software from startup.

* Adding post_rank query
12 months ago
Dessalines bb625c3671
Fix *All* reports not showing. Fixes #2902 (#2903)
* Fix *All* reports not showing. Fixes #2902

* Fix *All* reports not showing. Fixes #2902

* Fixing tests.
12 months ago
Dessalines 1b5437cbe3
Addressing slow profile queries. #2777 (#2830)
* Addressing slow profile queries. #2777

* Addressing PR comments.
1 year ago
Dessalines 985fe24669
Get rid of Safe Views, use serde_skip (#2767)
* Get rid of Safe Views, use serde_skip

- Also change the ViewToVec, to work with non-vector cases. Might be
  necessary in preparation for #2763
- Fixes #2712

* Forgot one safe

---------

Co-authored-by: Nutomic <me@nutomic.com>
1 year ago
Nutomic d9e7f0100a
Dont upsert Instance row every apub fetch (#2771)
This is not necessary because the domain cant change, so we only
need to insert if no row exists for this domain.

Also fetch instance actor when parsing person, not only community

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
1 year ago
Anon 9dfd819691
Add support for Featured Posts (#2585)
* Add support for Featured Posts

* Fix rebase

* More fixes
1 year ago
Nutomic 6f3bf4634b
Various pedantic clippy fixes (#2568)
* Various pedantic clippy fixes

* more clippy pedantic fixes

* try to fix ci

* add fix clippy script, use rust 1.65

* fix clippy
2 years ago
Dessalines 5d837780f5
Add diesel_async, get rid of blocking function (#2510)
* Moving settings to Database.

- Moves many settings into the database. Fixes #2285
- Adds a local_site and instance table. Fixes #2365 . Fixes #2368
- Separates SQL update an insert forms, to avoid runtime errors.
- Adds TypedBuilder to all the SQL forms, instead of default.

* Fix weird clippy issue.

* Removing extra lines.

* Some fixes from suggestions.

* Fixing apub tests.

* Using instance creation helper function.

* Move forms to their own line.

* Trying to fix local_site_data, still broken.

* Testing out async

* Testing out async 2

* Fixing federation tests.

* Trying to fix check features 1.

* Starting on adding diesel async. 1/4th done.

* Added async to views and schema.

* Adding some more async

* Compiling now.

* Added diesel async. Fixes #2465

* Running clippy --fix

* Trying to fix cargo test on drone.

* Trying new muslrust.

* Trying a custom dns

* Trying a custom dns 2

* Trying a custom dns 3

* Trying a custom dns 4

* Trying a custom dns 5

* Trying a custom dns 6

* Trying a custom dns 7

* Addressing PR comments.

* Adding check_apub to all verify functions.

* Reverting back drone.

* Fixing merge

* Fix docker images.

* Adding missing discussion_languages.

* Trying to fix federation tests.

* Fix site setup user creation.

* Fix clippy

* Fix clippy 2

* Test api faster

* Try to fix 1

* Try to fix 2

* What are these lines about

* Trying to fix 3

* Moving federation test back to top.

* Remove logging cat.
2 years ago
Dessalines 235cc8b228
Moving settings to Database. (#2492)
* Moving settings to Database.

- Moves many settings into the database. Fixes #2285
- Adds a local_site and instance table. Fixes #2365 . Fixes #2368
- Separates SQL update an insert forms, to avoid runtime errors.
- Adds TypedBuilder to all the SQL forms, instead of default.

* Fix weird clippy issue.

* Removing extra lines.

* Some fixes from suggestions.

* Fixing apub tests.

* Using instance creation helper function.

* Move forms to their own line.

* Trying to fix local_site_data, still broken.

* Fixing federation tests.

* Trying to fix check features 1.

* Addressing PR comments.

* Adding check_apub to all verify functions.
2 years ago
Dessalines c9f1407429
Diesel 2.0.0 upgrade (#2452)
* Initial commit to bump diesel to 2.0.0-rc.0 and see what happens

* Add chrono feature from diesel

* db_schema crate is close to building?

* Upgrade diesel-derive-newtype

* Mostly modifying references to connections to be mutable ones; also used
new way to do migrations as suggested by the migration guide; a lot more
compiles now, though I can't figure out this tricky ToSql issue at the
moment

* Running clippy --fix

* Trying to fix drone clippy 1

* Fix clippy

* Upgrade clux-musl

* Trying to fix drone clippy 2

* Trying to fix drone clippy 3

* Trying to fix drone clippy 5

* Adding diesel table aliases, removing sql view hack. Fixes #2101

Co-authored-by: Steven Chu <stevenc1@gmail.com>
Co-authored-by: Nutomic <me@nutomic.com>
2 years ago
Nutomic 8a4d9cc1ba
Use typed-builder crate for queries (#2379)
* Use typed-builder crate for PrivateMessageQuery

* derive builder for all queries

* remove unnecessary clones

* fix tests
2 years ago
Nutomic 63fff96275
Fix problem where actors can have empty public key (fixes #2347) (#2348) 2 years ago
Dessalines ff026dc3ff
Adding check for requests with no id or name, adding max limit. (#2265)
* Adding check for requests with no id or name, adding max limit.

* Consolidating a few functions.

* Fix page min

* Adding more websocket rate limits.

* Add check to GetCommunity

* Use a default message rate limit check.

* Adding a page and limit checker

* Fix clippy

* Fix clippy again

* Adding check for requests with no id or name, adding max limit.

* Consolidating a few functions.

* Fix page min

* Adding more websocket rate limits.

* Add check to GetCommunity

* Use a default message rate limit check.

* Adding a page and limit checker

* Fix clippy

* Fix clippy again

* Fix limit request.

* Move checks to inside limit_and_offset

* Fixing API tests.

* Change NotFound diesel errors to QueryBuilderError
2 years ago
Nutomic 3aa3d75a1e
Add cargo feature for building lemmy_api_common with mininum deps (#2243) 2 years ago
Nutomic 7058cfa1cf
Implement restricted community (only mods can post) (fixes #187) (#2235)
* Implement restricted community (only mods can post) (fixes #187)

* review fixes

* fix tests
2 years ago
Dessalines 4cf0da7b60 Clippy fixes. 2 years ago
dayinjing 7f9b55e793
Hide community v2 (#2055)
* Initial working of hiding communities and adding a db entry for mod log

* Return mod log for hidden communities

* Clean up hidding communities PR

* use lower case like other migration files

* Formatting fix

* pass in admin id to list, make match logic the same in post_view as community_view. Dont force non null for reason

* Clean PR review stuff

* Change person_id to mod_person_id on hide community table

* Make bools optional, add a space for formating

Co-authored-by: Thor Odinson <odinson@asgard.com>
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
2 years ago
Dessalines e65c45f152
Adding temporary bans. Fixes #1423 (#1999)
* Adding temporary bans. Fixes #1423

* Adding ban_expires to person

* Fix clippy

* Removing ban_expires from federated fields.

* Trying to add expires to blockcommunity apub.
2 years ago
Dessalines 46c7429429
Fixing duped report view for admins. Fixes #1933 (#1945)
* Fixing duped report view for admins. Fixes #1933

* Fixing tests.
3 years ago
Felix Ableitner f24999027e Merge crates db_schema and db_queries 3 years ago
Tmpod aef9786fa7
Add both (De)Serialize to all models (#1851) 3 years ago
Dessalines 864598908d
Admins can view all reports. Fixes #1810 (#1825) 3 years ago
Dessalines b18c744f63
Clean up reporting (#1776)
* First untested pass at reporting.

* Adding unit tests for post and comment report views

* Fix clippy

* Adding counts, creator_banned, and unresolved_only

* Adding my_vote to report views

* Fixing unit tests.
3 years ago
Dessalines c3efb9f7cf Strictly typing DB id fields. Fixes #1498 3 years ago
Dessalines 9cb4dad4b4 A first pass. 3 years ago
Dessalines ddf4a667b1 ~80% done 3 years ago
Felix Ableitner 3b64c58198 Move most code into crates/ subfolder 3 years ago