From 92de8fb396265d057f18aab4de0bc8aff4b90188 Mon Sep 17 00:00:00 2001 From: f0x52 Date: Sat, 19 Aug 2023 14:33:15 +0200 Subject: [feature] Instance rules (#2125) * init instance rules database model, admin api * expose instance rules in public instance api * public /api/v1/instance/rules route * GET ruleById * createRule route * createRule auth check * updateRule * deleteRule * list rules on about page * ruleGet auth * add about page ids for anchors * process and store adding violated rules to reports * admin api models for instance rules * instance rule edit frontend * change rule inputs to textareas * database fixes after rebase (#2124) * remove unused imports * fix db migration column name * fix tests * fix more tests * fix postgres error with wrongly used Ident * add some tests, fiddle with rule model a bit, fix postgres migration * swagger docs --------- Co-authored-by: tsmethurst --- testrig/testmodels.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'testrig/testmodels.go') diff --git a/testrig/testmodels.go b/testrig/testmodels.go index f5f63f6fa..4f0768b45 100644 --- a/testrig/testmodels.go +++ b/testrig/testmodels.go @@ -2021,6 +2021,7 @@ func NewTestReports() map[string]*gtsmodel.Report { Comment: "dark souls sucks, please yeet this nerd", StatusIDs: []string{"01FVW7JHQFSFK166WWKR8CBA6M"}, Forwarded: util.Ptr(true), + RuleIDs: []string{"01GP3AWY4CRDVRNZKW0TEAMB51", "01GP3DFY9XQ1TJMZT5BGAZPXX3"}, }, "remote_account_1_report_local_account_2": { ID: "01GP3DFY9XQ1TJMZT5BGAZPXX7", @@ -2031,6 +2032,7 @@ func NewTestReports() map[string]*gtsmodel.Report { TargetAccountID: "01F8MH5NBDF2MV7CTC4Q5128HF", Comment: "this is a turtle, not a person, therefore should not be a poster", StatusIDs: []string{}, + RuleIDs: []string{}, Forwarded: util.Ptr(true), ActionTaken: "user was warned not to be a turtle anymore", ActionTakenAt: TimeMustParse("2022-05-15T17:01:56+02:00"), @@ -2039,6 +2041,35 @@ func NewTestReports() map[string]*gtsmodel.Report { } } +func NewTestRules() map[string]*gtsmodel.Rule { + return map[string]*gtsmodel.Rule{ + "rule1": { + ID: "01GP3AWY4CRDVRNZKW0TEAMB51", + CreatedAt: TimeMustParse("2022-05-14T12:20:03+02:00"), + UpdatedAt: TimeMustParse("2022-05-14T12:20:03+02:00"), + Text: "Be gay", + Deleted: util.Ptr(false), + Order: util.Ptr(uint(0)), + }, + "deleted_rule": { + ID: "01GP3DFY9XQ1TJMZT5BGAZPXX2", + CreatedAt: TimeMustParse("2022-05-15T16:20:12+02:00"), + UpdatedAt: TimeMustParse("2022-05-15T16:20:12+02:00"), + Text: "Deleted", + Deleted: util.Ptr(true), + Order: util.Ptr(uint(1)), + }, + "rule2": { + ID: "01GP3DFY9XQ1TJMZT5BGAZPXX3", + CreatedAt: TimeMustParse("2022-05-15T16:20:12+02:00"), + UpdatedAt: TimeMustParse("2022-05-15T16:20:12+02:00"), + Text: "Do crime", + Deleted: util.Ptr(false), + Order: util.Ptr(uint(2)), + }, + } +} + // ActivityWithSignature wraps a pub.Activity along with its signature headers, for testing. type ActivityWithSignature struct { Activity pub.Activity -- cgit v1.2.3