From e87bf7dfa822d81a47eb267ccd6bd0e19ec53ed4 Mon Sep 17 00:00:00 2001 From: saithsab877 Date: Thu, 5 Dec 2024 11:58:39 +0500 Subject: [PATCH 1/2] feat: add websocket notifications for ticket reviews --- handlers/ticket.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/handlers/ticket.go b/handlers/ticket.go index 2a5b0fafd..906e59eb5 100644 --- a/handlers/ticket.go +++ b/handlers/ticket.go @@ -484,6 +484,29 @@ func (th *ticketHandler) ProcessTicketReview(w http.ResponseWriter, r *http.Requ return } + ticketMsg := websocket.TicketMessage{ + BroadcastType: "direct", + SourceSessionID: reviewReq.RequestUUID, + 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) From 81848351357db6ef486a311d7cd813314458082b Mon Sep 17 00:00:00 2001 From: saithsab877 Date: Thu, 5 Dec 2024 12:40:48 +0500 Subject: [PATCH 2/2] fix sourceWebsocket --- handlers/ticket.go | 2 +- utils/ticket_processor.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/handlers/ticket.go b/handlers/ticket.go index 906e59eb5..5e08edbc3 100644 --- a/handlers/ticket.go +++ b/handlers/ticket.go @@ -486,7 +486,7 @@ func (th *ticketHandler) ProcessTicketReview(w http.ResponseWriter, r *http.Requ ticketMsg := websocket.TicketMessage{ BroadcastType: "direct", - SourceSessionID: reviewReq.RequestUUID, + SourceSessionID: reviewReq.SourceWebsocket, Message: fmt.Sprintf("Successful update of %s", reviewReq.Value.TicketUUID), Action: "process", TicketDetails: websocket.TicketData{ diff --git a/utils/ticket_processor.go b/utils/ticket_processor.go index 68e907f08..2535fac93 100644 --- a/utils/ticket_processor.go +++ b/utils/ticket_processor.go @@ -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 {