modify youtube webhook

This commit is contained in:
Jay 2018-12-06 10:19:28 +08:00
parent 99c61b5af1
commit 9bbd17a39b
2 changed files with 13 additions and 0 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ config.yml
.idea .idea
module/schema/static.go*.swp module/schema/static.go*.swp
module/schema/static.go module/schema/static.go
*.swp

View File

@ -4,12 +4,14 @@ import (
"encoding/xml" "encoding/xml"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log"
"strings" "strings"
"time" "time"
"git.trj.tw/golang/mtfosbot/model" "git.trj.tw/golang/mtfosbot/model"
lineapi "git.trj.tw/golang/mtfosbot/module/apis/line" lineapi "git.trj.tw/golang/mtfosbot/module/apis/line"
"git.trj.tw/golang/mtfosbot/module/context" "git.trj.tw/golang/mtfosbot/module/context"
"git.trj.tw/golang/mtfosbot/module/utils"
) )
type feed struct { type feed struct {
@ -91,12 +93,15 @@ func GetNotifyWebhook(c *context.Context) {
return return
} }
log.Println("hook data", utils.ToMap(hook))
if len(hook.Entry) == 0 { if len(hook.Entry) == 0 {
c.Success(nil) c.Success(nil)
return return
} }
yt, err := model.GetYoutubeChannelWithID(id) yt, err := model.GetYoutubeChannelWithID(id)
log.Println("youtube and error", yt, err)
if err != nil || yt == nil { if err != nil || yt == nil {
c.ServerError(nil) c.ServerError(nil)
return return
@ -113,6 +118,13 @@ func GetNotifyWebhook(c *context.Context) {
return return
} }
err = yt.GetGroups()
if err != nil {
log.Println("get groups error ::::", err)
c.ServerError(nil)
return
}
for _, v := range yt.Groups { for _, v := range yt.Groups {
if v.Notify { if v.Notify {
str := v.Tmpl str := v.Tmpl