mirror of
https://github.com/0ceanSlim/grain.git
synced 2024-11-22 08:37:13 +00:00
sendNotice moved to own file
This commit is contained in:
parent
0dd29c5bcb
commit
bde60b7046
@ -2,7 +2,6 @@ package kinds
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
relay "grain/relay/types"
|
relay "grain/relay/types"
|
||||||
|
|
||||||
@ -51,9 +50,3 @@ func HandleKind0(ctx context.Context, evt relay.Event, collection *mongo.Collect
|
|||||||
fmt.Println("Upserted event kind 0 into MongoDB:", evt.ID)
|
fmt.Println("Upserted event kind 0 into MongoDB:", evt.ID)
|
||||||
return nil
|
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