Skip to content

Commit

Permalink
get notification user by token
Browse files Browse the repository at this point in the history
  • Loading branch information
konrad2002 committed Dec 5, 2024
1 parent 74e8a67 commit 3477d4a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions controller/notification_user_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
func notificationUserController() {
router.GET("/notification_users", getNotificationUsers)
router.GET("/notification_user", getNotificationUser)
router.GET("/notification_user/token/:token", getNotificationUserByToken)
router.GET("/notification_user/:id", getNotificationUserById)

router.POST("/notification_user", addNotificationUser)
Expand Down Expand Up @@ -66,6 +67,24 @@ func getNotificationUser(c *gin.Context) {
c.IndentedJSON(http.StatusOK, notificationUser)
}

func getNotificationUserByToken(c *gin.Context) {

token := c.Param("token")

if token == "" {
c.IndentedJSON(http.StatusNotFound, gin.H{"message": "no token given"})
return
}

notificationUser, err2 := service.GetNotificationUserByToken(token)
if err2 != nil {
c.IndentedJSON(http.StatusNotFound, gin.H{"message": err2.Error()})
return
}

c.IndentedJSON(http.StatusOK, notificationUser)
}

func getNotificationUserById(c *gin.Context) {

if failIfNotRoot(c) {
Expand Down

0 comments on commit 3477d4a

Please sign in to comment.