Skip to content

Commit

Permalink
channel for broadcast in path
Browse files Browse the repository at this point in the history
  • Loading branch information
konrad2002 committed Nov 27, 2024
1 parent de9ea13 commit d66f118
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions controller/notification_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func notificationController() {

router.POST("/notification/test/:device", sendTestNotification)
router.POST("/notification/:device", sendNotification)
router.POST("/notification/broadcast", sendBroadcast)
router.POST("/notification/broadcast/:channel", sendBroadcast)

router.OPTIONS("/notification/test/:device", okay)
router.OPTIONS("/notification/:device", okay)
Expand Down Expand Up @@ -66,13 +66,18 @@ func sendBroadcast(c *gin.Context) {
return
}

var request dto.BroadcastRequestDto
if err := c.BindJSON(&request); err != nil {
channel := c.Param("channel")

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

apnsRequestId, apnsUniqueId, body, status, err := service.SendPushBroadcast(request.Channel, request.Content)
print("channel: " + channel)
print("content: " + content)

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

0 comments on commit d66f118

Please sign in to comment.