-
-
Notifications
You must be signed in to change notification settings - Fork 888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding local site settings to reject federated upvotes or downvotes. #5038
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f0adbaa
Adding local site settings to reject federated upvotes or downvotes.
dessalines a3b7a46
Merge remote-tracking branch 'origin/main' into reject_federated_votes
dessalines 4ad1fff
Adding new vote mode types.
dessalines f583041
Merge remote-tracking branch 'origin/main' into reject_federated_votes
dessalines c4e0c24
Simpler activitypub vote check.
dessalines 20d0d8f
Merge remote-tracking branch 'origin/main' into reject_federated_votes
dessalines 35b6e05
Adding undo vote for failed vote mode check.
dessalines 6e9b546
Update crates/api_common/src/utils.rs
Nutomic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,6 +251,27 @@ pub enum CommunityVisibility { | |
LocalOnly, | ||
} | ||
|
||
#[derive( | ||
EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, Hash, | ||
)] | ||
#[cfg_attr(feature = "full", derive(DbEnum, TS))] | ||
#[cfg_attr( | ||
feature = "full", | ||
ExistingTypePath = "crate::schema::sql_types::FederationModeEnum" | ||
)] | ||
#[cfg_attr(feature = "full", DbValueStyle = "verbatim")] | ||
#[cfg_attr(feature = "full", ts(export))] | ||
/// The federation mode for an item | ||
pub enum FederationMode { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I figure this could be used in the future to block things like federated comments, federated posts, etc. |
||
#[default] | ||
/// Allows all | ||
All, | ||
/// Allows only local | ||
Local, | ||
/// Disables | ||
Disable, | ||
} | ||
|
||
/// Wrapper for assert_eq! macro. Checks that vec matches the given length, and prints the | ||
/// vec on failure. | ||
#[macro_export] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nutomic One reason that people gave for rejecting votes, is that they'd like to decrease the DB load, and avoid federated vote inserts entirely. But L89 seems like it inserts, then removes these votes (which would fire plenty of DB triggers also). Wouldn't it be better to just not insert them in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No this logic is used when a user first upvotes and then downvotes a post. So we cant apply the downvote, but leaving it as upvoted doesnt make sense either. Instead we remove the vote entirely. You can clarify the comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that mean I need to add this check elsewhere also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the logic is in mod.rs so it may be easier to make these changes there. For federation this should be all, of course you still need to add api checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding db writes, my assumption is that trying to delete nonexistent row doesnt write anything.