mirror of
https://github.com/0ceanSlim/grain.git
synced 2024-11-21 16:17:13 +00:00
handlekind refactored to only handle storing events in database
This commit is contained in:
parent
6f15f3f23a
commit
232b1b8d27
@ -44,6 +44,12 @@ func HandleEvent(ws *websocket.Conn, message []interface{}) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Signature check moved here
|
||||||
|
if !utils.CheckSignature(evt) {
|
||||||
|
response.SendOK(ws, evt.ID, false, "invalid: signature verification failed")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
eventSize := len(eventBytes) // Calculate event size
|
eventSize := len(eventBytes) // Calculate event size
|
||||||
|
|
||||||
if !handleBlacklistAndWhitelist(ws, evt) {
|
if !handleBlacklistAndWhitelist(ws, evt) {
|
||||||
@ -54,7 +60,7 @@ func HandleEvent(ws *websocket.Conn, message []interface{}) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleKind(context.TODO(), evt, ws, eventSize)
|
storeEvent(context.TODO(), evt, ws)
|
||||||
|
|
||||||
fmt.Println("Event processed:", evt.ID)
|
fmt.Println("Event processed:", evt.ID)
|
||||||
})
|
})
|
||||||
@ -110,12 +116,7 @@ func handleRateAndSizeLimits(ws *websocket.Conn, evt relay.Event, eventSize int)
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func HandleKind(ctx context.Context, evt relay.Event, ws *websocket.Conn, eventSize int) {
|
func storeEvent(ctx context.Context, evt relay.Event, ws *websocket.Conn) {
|
||||||
if !utils.CheckSignature(evt) {
|
|
||||||
response.SendOK(ws, evt.ID, false, "invalid: signature verification failed")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
collection := db.GetCollection(evt.Kind)
|
collection := db.GetCollection(evt.Kind)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
Loading…
Reference in New Issue
Block a user