From db213233daaa987a3254512c2860be783ec46421 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 12 Jul 2023 12:48:37 +0330 Subject: [PATCH] fix: correct some issues --- internal/webhook-proxy/handler/proxy.go | 13 ++++++++++--- internal/webhook-proxy/request/request.go | 5 +++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/internal/webhook-proxy/handler/proxy.go b/internal/webhook-proxy/handler/proxy.go index 941a150..732f11a 100644 --- a/internal/webhook-proxy/handler/proxy.go +++ b/internal/webhook-proxy/handler/proxy.go @@ -35,16 +35,16 @@ func (p *Proxy) ProxyToElement(c echo.Context) error { return c.NoContent(http.StatusBadRequest) } - if p.proxyRequest(req, p.ElementURL) { + if p.proxyRequest(generateElementText(req), p.ElementURL) { return c.NoContent(http.StatusOK) } return c.NoContent(http.StatusInternalServerError) } -func (p *Proxy) proxyRequest(req *request.Jira, url string) bool { +func (p *Proxy) proxyRequest(txt string, url string) bool { body, err := json.Marshal(ElementBody{ - Text: fmt.Sprintf("Issuer: %s\nURL: %s", req.User.Name, req.Issue.Fields.CustomField11401.Links.Web), + Text: txt, DisplayName: DisplayName, }) if err != nil { @@ -80,3 +80,10 @@ func (p *Proxy) proxyRequest(req *request.Jira, url string) bool { logrus.Errorf("element response body read error: %s", responseBody) return false } + +func generateElementText(req *request.Jira) string { + return fmt.Sprintf( + "Request Type: %s\nRequest Summary: %s\nIssuer: %s\nURL: %s", + req.Issue.Fields.IssueType.Name, req.Issue.Fields.Summary, req.User.Name, + req.Issue.Fields.CustomField11401.Links.Web) +} diff --git a/internal/webhook-proxy/request/request.go b/internal/webhook-proxy/request/request.go index eca180f..462cc3a 100644 --- a/internal/webhook-proxy/request/request.go +++ b/internal/webhook-proxy/request/request.go @@ -29,6 +29,11 @@ type Jira struct { Web string `json:"web"` } `json:"_links"` } `json:"customfield_11401"` + Summary string `json:"summary"` + IssueType struct { + Description string `json:"description"` + Name string `json:"name"` + } `json:"issuetype"` } `json:"fields"` } `json:"issue"` }