Skip to content

Commit

Permalink
fix reading json body as string in broadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
konrad2002 committed Nov 27, 2024
1 parent d66f118 commit 8639f6e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions controller/notification_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/swimresults/user-service/dto"
"github.com/swimresults/user-service/service"
"io"
"net/http"
)

Expand Down Expand Up @@ -68,16 +69,16 @@ func sendBroadcast(c *gin.Context) {

channel := c.Param("channel")

var content string
if err := c.Bind(&content); err != nil {
content, err := io.ReadAll(c.Request.Body)
if err != nil {
c.IndentedJSON(http.StatusInternalServerError, gin.H{"message": err.Error()})
return
}

print("channel: " + channel)
print("content: " + content)
print("content: " + string(content))

apnsRequestId, apnsUniqueId, body, status, err := service.SendPushBroadcast(channel, content)
apnsRequestId, apnsUniqueId, body, status, err := service.SendPushBroadcast(channel, string(content))
if err != nil {
c.IndentedJSON(http.StatusInternalServerError, gin.H{"message": err.Error()})
return
Expand Down

0 comments on commit 8639f6e

Please sign in to comment.