Skip to content

Commit

Permalink
added userID to note dto -> to filter votes
Browse files Browse the repository at this point in the history
  • Loading branch information
mateo-ivc committed Nov 25, 2024
1 parent 01177c3 commit d07bb4a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
32 changes: 16 additions & 16 deletions server/src/api/boards_listen_on_board.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@ import (

"github.com/google/uuid"
"github.com/gorilla/websocket"
dto2 "scrumlr.io/server/common/dto"
"scrumlr.io/server/common/dto"
"scrumlr.io/server/logger"
"scrumlr.io/server/realtime"
)

type BoardSubscription struct {
subscription chan *realtime.BoardEvent
clients map[uuid.UUID]*websocket.Conn
boardParticipants []*dto2.BoardSession
boardSettings *dto2.Board
boardColumns []*dto2.Column
boardNotes []*dto2.Note
boardReactions []*dto2.Reaction
boardParticipants []*dto.BoardSession
boardSettings *dto.Board
boardColumns []*dto.Column
boardNotes []*dto.Note
boardReactions []*dto.Reaction
}

type InitEvent struct {
Type realtime.BoardEventType `json:"type"`
Data dto2.FullBoard `json:"data"`
Data dto.FullBoard `json:"data"`
}

type EventData struct {
Board *dto2.Board `json:"board"`
Columns []*dto2.Column `json:"columns"`
Notes []*dto2.Note `json:"notes"`
Reactions []*dto2.Reaction `json:"reactions"`
Votings []*dto2.Voting `json:"votings"`
Votes []*dto2.Vote `json:"votes"`
Sessions []*dto2.BoardSession `json:"participants"`
Requests []*dto2.BoardSessionRequest `json:"requests"`
Board *dto.Board `json:"board"`
Columns []*dto.Column `json:"columns"`
Notes []*dto.Note `json:"notes"`
Reactions []*dto.Reaction `json:"reactions"`
Votings []*dto.Voting `json:"votings"`
Votes []*dto.Vote `json:"votes"`
Sessions []*dto.BoardSession `json:"participants"`
Requests []*dto.BoardSessionRequest `json:"requests"`
}

func (s *Server) openBoardSocket(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -97,7 +97,7 @@ func (s *Server) openBoardSocket(w http.ResponseWriter, r *http.Request) {
}
}

func (s *Server) listenOnBoard(boardID, userID uuid.UUID, conn *websocket.Conn, initEventData dto2.FullBoard) {
func (s *Server) listenOnBoard(boardID, userID uuid.UUID, conn *websocket.Conn, initEventData dto.FullBoard) {
if _, exist := s.boardSubscriptions[boardID]; !exist {
s.boardSubscriptions[boardID] = &BoardSubscription{
clients: make(map[uuid.UUID]*websocket.Conn),
Expand Down
5 changes: 4 additions & 1 deletion server/src/api/event_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,10 @@ func eventInitFilter(event InitEvent, clientID uuid.UUID) InitEvent {
Voting: v.Voting,
Note: n.ID,
}
visibleVotes = append(visibleVotes, &aVote)
if clientID == v.User {
visibleVotes = append(visibleVotes, &aVote)
}

}
}
}
Expand Down
2 changes: 2 additions & 0 deletions server/src/common/dto/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import (
type Vote struct {
Voting uuid.UUID `json:"voting"`
Note uuid.UUID `json:"note"`
User uuid.UUID `json:"user"`
}

func (v *Vote) From(vote database.Vote) *Vote {
v.Voting = vote.Voting
v.Note = vote.Note
v.User = vote.User
return v
}

Expand Down

0 comments on commit d07bb4a

Please sign in to comment.