mirror of
https://github.com/aljazceru/khatru.git
synced 2026-01-10 08:54:22 +01:00
ApplySaneDefaults()
This commit is contained in:
10
README.md
10
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.
|
||||
|
||||
14
policies/sane_defaults.go
Normal file
14
policies/sane_defaults.go
Normal file
@@ -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,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user