diff --git a/README.md b/README.md index 9cd3f8b..e0d552f 100644 --- a/README.md +++ b/README.md @@ -128,3 +128,13 @@ Fear no more. Using the https://github.com/fiatjaf/eventstore module you get a b relay.CountEvents = append(relay.CountEvents, db.CountEvents) relay.DeleteEvent = append(relay.DeleteEvent, db.DeleteEvent) ``` + +### But I don't want to write a bunch of custom policies! + +Fear no more. We have a bunch of common policies written in the `github.com/fiatjaf/khatru/policies` package and also a handpicked selection of base sane defaults, which you can apply with: + +```go + policies.ApplySaneDefaults(relay) +``` + +Contributions to this are very much welcomed. diff --git a/policies/sane_defaults.go b/policies/sane_defaults.go new file mode 100644 index 0000000..4fd1f2c --- /dev/null +++ b/policies/sane_defaults.go @@ -0,0 +1,14 @@ +package policies + +import "github.com/fiatjaf/khatru" + +func ApplySaneDefaults(relay *khatru.Relay) { + relay.RejectEvent = append(relay.RejectEvent, + RejectEventsWithBase64Media, + ) + + relay.RejectFilter = append(relay.RejectFilter, + NoEmptyFilters, + NoComplexFilters, + ) +}