Skip to content

Commit

Permalink
Merge pull request #2104 from saithsab877/feature-websocket-ticket-re…
Browse files Browse the repository at this point in the history
…view-notifications

feat: Implement WebSocket Notifications for Ticket Review Updates
  • Loading branch information
humansinstitute authored Dec 5, 2024
2 parents 0bd5e24 + 8184835 commit 83e9b1e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions handlers/ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,29 @@ func (th *ticketHandler) ProcessTicketReview(w http.ResponseWriter, r *http.Requ
return
}

ticketMsg := websocket.TicketMessage{
BroadcastType: "direct",
SourceSessionID: reviewReq.SourceWebsocket,
Message: fmt.Sprintf("Successful update of %s", reviewReq.Value.TicketUUID),
Action: "process",
TicketDetails: websocket.TicketData{
FeatureUUID: reviewReq.Value.FeatureUUID,
PhaseUUID: reviewReq.Value.PhaseUUID,
TicketUUID: reviewReq.Value.TicketUUID,
TicketDescription: reviewReq.Value.TicketDescription,
},
}

if err := websocket.WebsocketPool.SendTicketMessage(ticketMsg); err != nil {
log.Printf("Failed to send websocket message: %v", err)
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(map[string]interface{}{
"ticket": updatedTicket,
"websocket_error": err.Error(),
})
return
}

log.Printf("Successfully updated ticket %s", reviewReq.Value.TicketUUID)
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(updatedTicket)
Expand Down
3 changes: 2 additions & 1 deletion utils/ticket_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ type TicketReviewRequest struct {
TicketUUID string `json:"ticketUUID" validate:"required"`
TicketDescription string `json:"ticketDescription" validate:"required"`
} `json:"value"`
RequestUUID string `json:"requestUUID"`
RequestUUID string `json:"requestUUID"`
SourceWebsocket string `json:"sourceWebsocket"`
}

func ValidateTicketReviewRequest(req *TicketReviewRequest) error {
Expand Down

0 comments on commit 83e9b1e

Please sign in to comment.