mirror of
https://github.com/0ceanSlim/grain.git
synced 2024-11-21 16:17:13 +00:00
sendNotice moved to own file
This commit is contained in:
parent
0dd29c5bcb
commit
bde60b7046
@ -2,7 +2,6 @@ package kinds
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
relay "grain/relay/types"
|
||||
|
||||
@ -50,10 +49,4 @@ func HandleKind0(ctx context.Context, evt relay.Event, collection *mongo.Collect
|
||||
|
||||
fmt.Println("Upserted event kind 0 into MongoDB:", evt.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func sendNotice(ws *websocket.Conn, pubKey, message string) {
|
||||
notice := []interface{}{"NOTICE", pubKey, message}
|
||||
noticeBytes, _ := json.Marshal(notice)
|
||||
websocket.Message.Send(ws, string(noticeBytes))
|
||||
}
|
||||
}
|
13
relay/handlers/kinds/notice.go
Normal file
13
relay/handlers/kinds/notice.go
Normal file
@ -0,0 +1,13 @@
|
||||
package kinds
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"golang.org/x/net/websocket"
|
||||
)
|
||||
|
||||
func sendNotice(ws *websocket.Conn, pubKey, message string) {
|
||||
notice := []interface{}{"NOTICE", pubKey, message}
|
||||
noticeBytes, _ := json.Marshal(notice)
|
||||
websocket.Message.Send(ws, string(noticeBytes))
|
||||
}
|
Loading…
Reference in New Issue
Block a user