fix basic relay AcceptEvent interface implementation
This commit is contained in:
@@ -40,21 +40,26 @@ func (r *Relay) Init() error {
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
time.Sleep(60 * time.Minute)
|
time.Sleep(60 * time.Minute)
|
||||||
db.DB.Exec(`DELETE FROM event WHERE created_at < $1`, time.Now().AddDate(0, -3, 0).Unix()) // 3 months
|
db.DB.Exec(
|
||||||
|
`DELETE FROM event WHERE created_at < $1`,
|
||||||
|
time.Now().AddDate(0, -3, 0).Unix(),
|
||||||
|
) // 3 months
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Relay) AcceptEvent(ctx context.Context, evt *nostr.Event) bool {
|
func (r *Relay) AcceptEvent(ctx context.Context, evt *nostr.Event) (
|
||||||
|
bool, string,
|
||||||
|
) {
|
||||||
// block events that are too large
|
// block events that are too large
|
||||||
jsonb, _ := json.Marshal(evt)
|
jsonb, _ := json.Marshal(evt)
|
||||||
if len(jsonb) > 10000 {
|
if len(jsonb) > 10000 {
|
||||||
return false
|
return false, "event is too large"
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
Reference in New Issue
Block a user