mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-17 09:54:01 +00:00
ffb94fde85
* Adding local site settings to reject federated upvotes or downvotes. - Should help defend against downvote spamming instances. - Fixes #4086 * Adding new vote mode types. * Simpler activitypub vote check. * Adding undo vote for failed vote mode check. * Update crates/api_common/src/utils.rs --------- Co-authored-by: Nutomic <me@nutomic.com>
39 lines
1.2 KiB
SQL
39 lines
1.2 KiB
SQL
-- This removes the simple enable_downvotes setting, in favor of an
|
|
-- expanded federation mode type for post/comment up/downvotes.
|
|
-- Create the federation mode enum
|
|
CREATE TYPE federation_mode_enum AS ENUM (
|
|
'All',
|
|
'Local',
|
|
'Disable'
|
|
);
|
|
|
|
-- Add the new columns
|
|
ALTER TABLE local_site
|
|
ADD COLUMN post_upvotes federation_mode_enum DEFAULT 'All'::federation_mode_enum NOT NULL,
|
|
ADD COLUMN post_downvotes federation_mode_enum DEFAULT 'All'::federation_mode_enum NOT NULL,
|
|
ADD COLUMN comment_upvotes federation_mode_enum DEFAULT 'All'::federation_mode_enum NOT NULL,
|
|
ADD COLUMN comment_downvotes federation_mode_enum DEFAULT 'All'::federation_mode_enum NOT NULL;
|
|
|
|
-- Copy over the enable_downvotes into the post and comment downvote settings
|
|
WITH subquery AS (
|
|
SELECT
|
|
enable_downvotes,
|
|
CASE WHEN enable_downvotes = TRUE THEN
|
|
'All'::federation_mode_enum
|
|
ELSE
|
|
'Disable'::federation_mode_enum
|
|
END
|
|
FROM
|
|
local_site)
|
|
UPDATE
|
|
local_site
|
|
SET
|
|
post_downvotes = subquery.case,
|
|
comment_downvotes = subquery.case
|
|
FROM
|
|
subquery;
|
|
|
|
-- Drop the enable_downvotes column
|
|
ALTER TABLE local_site
|
|
DROP COLUMN enable_downvotes;
|
|
|