Skip to content

Commit

Permalink
chore: bump to v0.0.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
kehiy committed Jan 8, 2025
1 parent db40de8 commit f6ba9e0
Showing 1 changed file with 31 additions and 32 deletions.
63 changes: 31 additions & 32 deletions delivery/websocket/event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package websocket
import (
"context"
"fmt"
"log"
"strconv"
"time"

"github.com/dezh-tech/immortal/pkg/logger"
"github.com/dezh-tech/immortal/pkg/utils"
"github.com/dezh-tech/immortal/types/message"
"github.com/gorilla/websocket"
Expand Down Expand Up @@ -38,7 +38,6 @@ func (s *Server) handleEvent(conn *websocket.Conn, m message.Message) { //nolint
}

eID := msg.Event.GetRawID()
pubkey := msg.Event.PublicKey

if !msg.Event.IsValid(eID) {
okm := message.MakeOK(false,
Expand All @@ -61,12 +60,12 @@ func (s *Server) handleEvent(conn *websocket.Conn, m message.Message) { //nolint
bloomCheckCmd := pipe.BFExists(qCtx, s.redis.BloomFilterName, eID[:])

// todo::: check config to enable/disable filter checks.
whiteListCheckCmd := pipe.CFExists(qCtx, s.redis.WhiteListFilterName, pubkey)
blackListCheckCmd := pipe.CFExists(qCtx, s.redis.BlackListFilterName, pubkey)
// whiteListCheckCmd := pipe.CFExists(qCtx, s.redis.WhiteListFilterName, pubkey)
// blackListCheckCmd := pipe.CFExists(qCtx, s.redis.BlackListFilterName, pubkey)

_, err := pipe.Exec(qCtx)
if err != nil {
log.Printf("error: checking filters: %s", err.Error())
logger.Error("checking bloom filter", "err", err.Error())
}

exists, err := bloomCheckCmd.Result()
Expand All @@ -86,41 +85,41 @@ func (s *Server) handleEvent(conn *websocket.Conn, m message.Message) { //nolint
return
}

notAllowedToWrite, err := blackListCheckCmd.Result()
if err != nil {
okm := message.MakeOK(false, msg.Event.ID, "error: internal error")
_ = conn.WriteMessage(1, okm)
// notAllowedToWrite, err := blackListCheckCmd.Result()
// if err != nil {
// okm := message.MakeOK(false, msg.Event.ID, "error: internal error")
// _ = conn.WriteMessage(1, okm)

status = serverFail
// status = serverFail

Check failure on line 93 in delivery/websocket/event_handler.go

View workflow job for this annotation

GitHub Actions / lint

commentedOutCode: may want to remove commented-out code (gocritic)

return
}
if notAllowedToWrite {
okm := message.MakeOK(false, msg.Event.ID, "blocked: pubkey is blocked, contact support for more details.")
_ = conn.WriteMessage(1, okm)
// return
// }
// if notAllowedToWrite {
// okm := message.MakeOK(false, msg.Event.ID, "blocked: pubkey is blocked, contact support for more details.")
// _ = conn.WriteMessage(1, okm)

status = limitsFail
// status = limitsFail

Check failure on line 101 in delivery/websocket/event_handler.go

View workflow job for this annotation

GitHub Actions / lint

commentedOutCode: may want to remove commented-out code (gocritic)

return
}
// return
// }

allowedToWrite, err := whiteListCheckCmd.Result()
if err != nil {
okm := message.MakeOK(false, msg.Event.ID, "error: internal error")
_ = conn.WriteMessage(1, okm)
// allowedToWrite, err := whiteListCheckCmd.Result()
// if err != nil {
// okm := message.MakeOK(false, msg.Event.ID, "error: internal error")
// _ = conn.WriteMessage(1, okm)

status = serverFail
// status = serverFail

Check failure on line 111 in delivery/websocket/event_handler.go

View workflow job for this annotation

GitHub Actions / lint

commentedOutCode: may want to remove commented-out code (gocritic)

return
}
if !allowedToWrite {
okm := message.MakeOK(false, msg.Event.ID, "restricted: not allowed to write.")
_ = conn.WriteMessage(1, okm)
// return
// }
// if !allowedToWrite {
// okm := message.MakeOK(false, msg.Event.ID, "restricted: not allowed to write.")
// _ = conn.WriteMessage(1, okm)

status = limitsFail
// status = limitsFail

return
}
// return
// }

client, ok := s.conns[conn]
if !ok {
Expand Down Expand Up @@ -287,7 +286,7 @@ func (s *Server) handleEvent(conn *websocket.Conn, m message.Message) { //nolint

_, err = s.redis.Client.BFAdd(qCtx, s.redis.BloomFilterName, eID[:]).Result()
if err != nil {
log.Printf("error: adding event to bloom filter.")
logger.Info("adding event to bloom filter", "err", err.Error(), msg.Event.ID)
}

// todo::: can we run goroutines per client?
Expand Down

0 comments on commit f6ba9e0

Please sign in to comment.