@@ -3,7 +3,9 @@ package jira
33import (
44 "context"
55 "encoding/json"
6+ "maps"
67 "net/http"
8+ "slices"
79 "strconv"
810 "strings"
911)
@@ -31,6 +33,7 @@ type EditRequest struct {
3133 // CustomFields holds all custom fields passed
3234 // while editing the issue.
3335 CustomFields map [string ]string
36+ SkipNotify bool
3437
3538 configuredCustomFields []IssueTypeField
3639}
@@ -49,7 +52,12 @@ func (c *Client) Edit(key string, req *EditRequest) error {
4952 return err
5053 }
5154
52- res , err := c .PutV2 (context .Background (), "/issue/" + key , body , Header {
55+ endpoint := "/issue/" + key
56+ if req .SkipNotify {
57+ endpoint += "?notifyUsers=false"
58+ }
59+
60+ res , err := c .PutV2 (context .Background (), endpoint , body , Header {
5361 "Accept" : "application/json" ,
5462 "Content-Type" : "application/json" ,
5563 })
@@ -78,7 +86,7 @@ type editFields struct {
7886 Priority []struct {
7987 Set struct {
8088 Name string `json:"name,omitempty"`
81- } `json:"set,omitempty "`
89+ } `json:"set"`
8290 } `json:"priority,omitempty"`
8391 Labels []struct {
8492 Add string `json:"add,omitempty"`
@@ -139,16 +147,13 @@ func (cfm *editFieldsMarshaler) MarshalJSON() ([]byte, error) {
139147 return m , err
140148 }
141149
142- var temp interface {}
150+ var temp any
143151 if err := json .Unmarshal (m , & temp ); err != nil {
144152 return nil , err
145153 }
146- dm := temp .(map [string ]interface {})
147-
148- for key , val := range cfm .M .customFields {
149- dm [key ] = val
150- }
154+ dm := temp .(map [string ]any )
151155
156+ maps .Copy (dm , cfm .M .customFields )
152157 return json .Marshal (dm )
153158}
154159
@@ -177,7 +182,7 @@ func getRequestDataForEdit(req *EditRequest) *editRequest {
177182 Priority : []struct {
178183 Set struct {
179184 Name string `json:"name,omitempty"`
180- } `json:"set,omitempty "`
185+ } `json:"set"`
181186 }{{Set : struct {
182187 Name string `json:"name,omitempty"`
183188 }{Name : req .Priority }}},
@@ -412,19 +417,10 @@ func splitAddAndRemove(input []string) ([]string, []string) {
412417 }
413418 }
414419 for _ , inp := range input {
415- if ! strings .HasPrefix (inp , separatorMinus ) && ! inArray (sub , inp ) {
420+ if ! strings .HasPrefix (inp , separatorMinus ) && ! slices . Contains (sub , inp ) {
416421 add = append (add , inp )
417422 }
418423 }
419424
420425 return add , sub
421426}
422-
423- func inArray (array []string , item string ) bool {
424- for _ , i := range array {
425- if i == item {
426- return true
427- }
428- }
429- return false
430- }
0 commit comments