api/graph: Set resolution = UNRESOLVED for open tickets
Set resolution = UNRESOLVED for ticket statuses other than RESOLVED in UpdateTicketStatus.
This commit is contained in:
parent
037e2bf9fe
commit
4c2e2792fa
|
@ -1049,11 +1049,19 @@ func (r *mutationResolver) UpdateTicketStatus(ctx context.Context, trackerID int
|
||||||
"old_resolution", "new_resolution")
|
"old_resolution", "new_resolution")
|
||||||
|
|
||||||
resolution := ticket.Resolution()
|
resolution := ticket.Resolution()
|
||||||
if input.Resolution != nil {
|
if input.Status.ToInt() == model.STATUS_RESOLVED {
|
||||||
|
if input.Resolution == nil {
|
||||||
|
return nil, errors.New("Resolution is required when setting status to RESOLVED")
|
||||||
|
}
|
||||||
resolution = *input.Resolution
|
resolution = *input.Resolution
|
||||||
update = update.Set("resolution", resolution.ToInt())
|
update = update.Set("resolution", resolution.ToInt())
|
||||||
} else if input.Status.ToInt() == model.STATUS_RESOLVED {
|
} else {
|
||||||
return nil, fmt.Errorf("resolution is required when status is RESOLVED")
|
if input.Resolution != nil {
|
||||||
|
return nil, errors.New("Resolution may only be provided when status is set to RESOLVED")
|
||||||
|
}
|
||||||
|
// Other statuses should have resolution = UNRESOLVED
|
||||||
|
resolution = model.TicketResolutionUnresolved
|
||||||
|
update = update.Set("resolution", resolution.ToInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
var event model.Event
|
var event model.Event
|
||||||
|
@ -1162,6 +1170,7 @@ func (r *mutationResolver) SubmitComment(ctx context.Context, trackerID int, tic
|
||||||
_newResolution int
|
_newResolution int
|
||||||
eventType uint = model.EVENT_COMMENT
|
eventType uint = model.EVENT_COMMENT
|
||||||
)
|
)
|
||||||
|
|
||||||
if input.Status != nil {
|
if input.Status != nil {
|
||||||
eventType |= model.EVENT_STATUS_CHANGE
|
eventType |= model.EVENT_STATUS_CHANGE
|
||||||
oldStatus = &_oldStatus
|
oldStatus = &_oldStatus
|
||||||
|
@ -1173,11 +1182,20 @@ func (r *mutationResolver) SubmitComment(ctx context.Context, trackerID int, tic
|
||||||
*newStatus = input.Status.ToInt()
|
*newStatus = input.Status.ToInt()
|
||||||
*newResolution = ticket.Resolution().ToInt()
|
*newResolution = ticket.Resolution().ToInt()
|
||||||
updateTicket = updateTicket.Set("status", *newStatus)
|
updateTicket = updateTicket.Set("status", *newStatus)
|
||||||
if input.Resolution != nil {
|
|
||||||
|
if input.Status.ToInt() == model.STATUS_RESOLVED {
|
||||||
|
if input.Resolution == nil {
|
||||||
|
return nil, errors.New("Resolution is required when setting status to RESOLVED")
|
||||||
|
}
|
||||||
*newResolution = input.Resolution.ToInt()
|
*newResolution = input.Resolution.ToInt()
|
||||||
updateTicket = updateTicket.Set("resolution", *newResolution)
|
updateTicket = updateTicket.Set("resolution", *newResolution)
|
||||||
} else if input.Status.ToInt() == model.STATUS_RESOLVED {
|
} else {
|
||||||
return nil, fmt.Errorf("resolution is required when status is RESOLVED")
|
if input.Resolution != nil {
|
||||||
|
return nil, errors.New("Resolution may only be provided when status is set to RESOLVED")
|
||||||
|
}
|
||||||
|
// Other statuses should have resolution = UNRESOLVED
|
||||||
|
*newResolution = model.RESOLVED_UNRESOLVED
|
||||||
|
updateTicket = updateTicket.Set("resolution", *newResolution)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue