Skip to content

Commit

Permalink
!33 Change infoType to the same as in EventRulerHandler module.
Browse files Browse the repository at this point in the history
Merge pull request !33 from Guoqiang QI/unmatch_error
  • Loading branch information
li-clement authored and gitee-org committed Jan 8, 2022
2 parents d7ee04f + 971a66e commit d433b81
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
28 changes: 1 addition & 27 deletions src/gitee-utils/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"io/ioutil"
"log"
"os"
"strings"
"time"

amqp "github.com/rabbitmq/amqp091-go"
Expand Down Expand Up @@ -225,7 +224,6 @@ func getToken() []byte {

func eventHandler(msg amqp.Delivery) error {
var msgInfo Issue
lineBreaker := "\n"

err := json.Unmarshal(msg.Body, &msgInfo)
if err != nil {
Expand All @@ -239,37 +237,13 @@ func eventHandler(msg amqp.Delivery) error {
orgInfo := msgInfo.RepoInfo.Org
repoNameInfo := msgInfo.RepoInfo.Repo
generalContent := msgInfo.TargetInfo.InfoContent.GeneralContent
chineseContent := msgInfo.TargetInfo.InfoContent.ChineseContent
englishContent := msgInfo.TargetInfo.InfoContent.EnglishContent
infoType := msgInfo.TargetInfo.InfoType
targetUser := msgInfo.TargetInfo.TargetUser
c := NewClient(getToken)

switch eventType {
case "info":
switch infoType {
case "AssigneeReminder":
infoTemp := strings.Replace(generalContent, "{"+"mainCaller1"+"}", fmt.Sprintf("%v", targetUser[0]), -1)
infoTemp = strings.Replace(infoTemp, "{"+"mainCaller2"+"}", fmt.Sprintf("%v", targetUser[1]), -1)
strInfo := englishContent + lineBreaker + chineseContent + lineBreaker + infoTemp
res := c.CreateGiteeIssueComment(orgInfo, repoNameInfo, issueID, strInfo)
fmt.Println(strInfo)
if res != nil {
fmt.Println(res.Error())
LogInstance.WithFields(logrus.Fields{
"context": "AssigneeReminder CreateGiteeIssueComment error",
"orgInfo": orgInfo,
"repoNameInfo": repoNameInfo,
"issueID": issueID,
}).Info("info log")
return res
}
LogInstance.WithFields(logrus.Fields{
"context": "AssigneeReminder CreateGiteeIssueComment success",
"body": strInfo,
"msg": string(msg.Body),
}).Info("info log")
case "LabelReminder":
case "issueComment":
strInfo := generalContent
res := c.CreateGiteeIssueComment(orgInfo, repoNameInfo, issueID, strInfo)
if res != nil {
Expand Down
3 changes: 3 additions & 0 deletions src/log/executor.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"context":"Rabbitmq connect error","level":"info","msg":"info log","time":"2022-01-08T16:50:02+08:00"}
{"context":"Consumer setup error","level":"info","msg":"info log","time":"2022-01-08T16:50:02+08:00"}
{"context":"Consumer action success","level":"info","msg":"info log","time":"2022-01-08T16:50:02+08:00"}

0 comments on commit d433b81

Please sign in to comment.