Fix #4568: Send appealed posts back to the mod queue

* Include appealed posts in the modqueue.

* Add `status` field to appeals. Appeals start out as `pending`, then
  become `rejected` if the post isn't approved within three days. If the
  post is approved, the appeal's status becomes `succeeded`.

* Add `status` field to flags. Flags start out as `pending` then become
  `rejected` if the post is approved within three days. If the post
  isn't approved, the flag's status becomes `succeeded`.

* Leave behind a "Unapproved in three days" dummy flag when an appeal
  goes unapproved, just like when a pending post is unapproved.

* Only allow deleted posts to be appealed. Don't allow flagged posts to be appealed.

* Add `status:appealed` metatag. `status:appealed` is separate from `status:pending`.

* Include appealed posts in `status:modqueue`. Search `status:modqueue order:modqueue`
  to view the modqueue as a normal search.

* Retroactively set old flags and appeals as succeeded or rejected. This
  may not be correct for posts that were appealed or flagged multiple
  times. This is difficult to set correctly because we don't have
  approval records for old posts, so we can't tell the actual outcome of
  old flags and appeals.

* Deprecate the `is_resolved` field on post flags. A resolved flag is a
  flag that isn't pending.

* Known bug: appealed posts have a black border instead of a blue
  border. Checking whether a post has been appealed would require either
  an extra query on the posts/index page, or an is_appealed flag on
  posts, neither of which are very desirable.

* Known bug: you can't use `status:appealed` in blacklists, for the same
  reason as above.
This commit is contained in:
evazion
2020-08-03 14:40:04 -05:00
parent e31afd0827
commit 0a0a85ee70
31 changed files with 372 additions and 118 deletions

View File

@@ -2584,7 +2584,8 @@ CREATE TABLE public.post_appeals (
creator_id integer NOT NULL,
reason text,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
updated_at timestamp without time zone NOT NULL,
status integer DEFAULT 0 NOT NULL
);
@@ -2684,7 +2685,8 @@ CREATE TABLE public.post_flags (
reason text,
is_resolved boolean DEFAULT false NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
updated_at timestamp without time zone NOT NULL,
status integer DEFAULT 0 NOT NULL
);
@@ -6622,6 +6624,13 @@ CREATE INDEX index_post_appeals_on_post_id ON public.post_appeals USING btree (p
CREATE INDEX index_post_appeals_on_reason_tsvector ON public.post_appeals USING gin (to_tsvector('english'::regconfig, reason));
--
-- Name: index_post_appeals_on_status; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_post_appeals_on_status ON public.post_appeals USING btree (status);
--
-- Name: index_post_approvals_on_post_id; Type: INDEX; Schema: public; Owner: -
--
@@ -6671,6 +6680,13 @@ CREATE INDEX index_post_flags_on_post_id ON public.post_flags USING btree (post_
CREATE INDEX index_post_flags_on_reason_tsvector ON public.post_flags USING gin (to_tsvector('english'::regconfig, reason));
--
-- Name: index_post_flags_on_status; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_post_flags_on_status ON public.post_flags USING btree (status);
--
-- Name: index_post_replacements_on_creator_id; Type: INDEX; Schema: public; Owner: -
--
@@ -7393,6 +7409,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200325074859'),
('20200403210353'),
('20200406054838'),
('20200427190519');
('20200427190519'),
('20200803022359');