summaryrefslogtreecommitdiff
path: root/testrig/testmodels.go
diff options
context:
space:
mode:
authorLibravatar f0x52 <f0x@cthu.lu>2023-08-19 14:33:15 +0200
committerLibravatar GitHub <noreply@github.com>2023-08-19 14:33:15 +0200
commit92de8fb396265d057f18aab4de0bc8aff4b90188 (patch)
tree46438b9ff550261f56aa58d038cdf2f1e15493e3 /testrig/testmodels.go
parent[bugfix] fix double firing bun.DB query hooks (#2124) (diff)
downloadgotosocial-92de8fb396265d057f18aab4de0bc8aff4b90188.tar.xz
[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 <tobi.smethurst@protonmail.com>
Diffstat (limited to 'testrig/testmodels.go')
-rw-r--r--testrig/testmodels.go31
1 files changed, 31 insertions, 0 deletions
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