Skip to content

Commit

Permalink
fix: ignore auth when using webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
songquanpeng committed Nov 10, 2024
1 parent 431c0d6 commit 981539b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions controller/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func pushMessageHelper(c *gin.Context, message *model.Message) {
if message.Token == "" {
message.Token = strings.TrimPrefix(c.Request.Header.Get("Authorization"), "Bearer ")
}
processMessage(c, message, &user)
processMessage(c, message, &user, true)
}

func authMessage(messageToken string, userToken string, channelToken *string) bool {
Expand All @@ -133,7 +133,7 @@ func authMessage(messageToken string, userToken string, channelToken *string) bo
return true
}

func processMessage(c *gin.Context, message *model.Message, user *model.User) {
func processMessage(c *gin.Context, message *model.Message, user *model.User, needAuth bool) {
if message.Title == "" {
message.Title = common.SystemName
}
Expand All @@ -151,7 +151,7 @@ func processMessage(c *gin.Context, message *model.Message, user *model.User) {
})
return
}
if !authMessage(message.Token, user.Token, channel_.Token) {
if needAuth && !authMessage(message.Token, user.Token, channel_.Token) {
if message.Token == "" {
c.JSON(http.StatusUnauthorized, gin.H{
"success": false,
Expand Down
2 changes: 1 addition & 1 deletion controller/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,5 @@ func TriggerWebhook(c *gin.Context) {
Content: constructRule.Content,
URL: constructRule.URL,
}
processMessage(c, message, user)
processMessage(c, message, user, false)
}

0 comments on commit 981539b

Please sign in to comment.