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
module/schema/static.go*.swp
module/schema/static.go
*.swp

View File

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