diff --git a/src/gitee-utils/client.go b/src/gitee-utils/client.go index 54d1ee22fff9bbbf1b59920cea69dba2eb113723..ea20a0b65ecb84af10b6a640743ee5ba502a0df4 100644 --- a/src/gitee-utils/client.go +++ b/src/gitee-utils/client.go @@ -24,6 +24,7 @@ type client struct { type RepoInfo struct { Org string `json:"org"` Repo string `json:"repo"` + Ent string `json:"ent"` } type TargetInfo struct { @@ -45,6 +46,7 @@ type Issue struct { TargetLabel string `json:"targetLabel"` TargetAssigneeID string `json:"targetAssigneeID"` PushTime string `json:"pushTime"` + RepoInfo RepoInfo `json:"repoInfo"` } func NewClient(getToken func() []byte) Client { diff --git a/src/gitee-utils/message.go b/src/gitee-utils/message.go index 794408fc627c7472d8f908b0e3a8fa529153b533..e5bc1062bad7ba759092dfb22539f55e6b1e4c3c 100644 --- a/src/gitee-utils/message.go +++ b/src/gitee-utils/message.go @@ -224,39 +224,20 @@ func getToken() []byte { } func eventHandler(msg amqp.Delivery) error { - var repoInfo RepoInfo var msgInfo Issue - var orgInfo string - var repoNameInfo string lineBreaker := "\n" - err := json.Unmarshal(repo, &repoInfo) - if err != nil { - LogInstance.WithFields(logrus.Fields{ - "context": "wrong repo", - }).Info("info log") - return err - } - err = json.Unmarshal(msg.Body, &msgInfo) + err := json.Unmarshal(msg.Body, &msgInfo) if err != nil { LogInstance.WithFields(logrus.Fields{ "context": "wrong msgbody", }).Info("info log") return err } - if os.Getenv("Org") != "" { - orgInfo = os.Getenv("Org") - } else { - orgInfo = repoInfo.Org - } - - if os.Getenv("Repo") != "" { - repoNameInfo = os.Getenv("Repo") - } else { - repoNameInfo = repoInfo.Repo - } issueID := msgInfo.IssueID eventType := msgInfo.EventType + orgInfo := msgInfo.RepoInfo.Org + repoNameInfo := msgInfo.RepoInfo.Repo generalContent := msgInfo.TargetInfo.InfoContent.GeneralContent chineseContent := msgInfo.TargetInfo.InfoContent.ChineseContent englishContent := msgInfo.TargetInfo.InfoContent.EnglishContent @@ -277,6 +258,9 @@ func eventHandler(msg amqp.Delivery) error { fmt.Println(res.Error()) LogInstance.WithFields(logrus.Fields{ "context": "AssigneeReminder CreateGiteeIssueComment error", + "orgInfo": orgInfo, + "repoNameInfo": repoNameInfo, + "issueID": issueID, }).Info("info log") return res }