(midjRequest *dto.MidjourneyRequest)
| 74 | } |
| 75 | |
| 76 | func CoverPlusActionToNormalAction(midjRequest *dto.MidjourneyRequest) *dto.MidjourneyResponse { |
| 77 | // "customId": "MJ::JOB::upsample::2::3dbbd469-36af-4a0f-8f02-df6c579e7011" |
| 78 | customId := midjRequest.CustomId |
| 79 | if customId == "" { |
| 80 | return MidjourneyErrorWrapper(constant.MjRequestError, "custom_id_is_required") |
| 81 | } |
| 82 | splits := strings.Split(customId, "::") |
| 83 | var action string |
| 84 | if splits[1] == "JOB" { |
| 85 | action = splits[2] |
| 86 | } else { |
| 87 | action = splits[1] |
| 88 | } |
| 89 | |
| 90 | if action == "" { |
| 91 | return MidjourneyErrorWrapper(constant.MjRequestError, "unknown_action") |
| 92 | } |
| 93 | if strings.Contains(action, "upsample") { |
| 94 | index, err := strconv.Atoi(splits[3]) |
| 95 | if err != nil { |
| 96 | return MidjourneyErrorWrapper(constant.MjRequestError, "index_parse_failed") |
| 97 | } |
| 98 | midjRequest.Index = index |
| 99 | midjRequest.Action = constant.MjActionUpscale |
| 100 | } else if strings.Contains(action, "variation") { |
| 101 | midjRequest.Index = 1 |
| 102 | if action == "variation" { |
| 103 | index, err := strconv.Atoi(splits[3]) |
| 104 | if err != nil { |
| 105 | return MidjourneyErrorWrapper(constant.MjRequestError, "index_parse_failed") |
| 106 | } |
| 107 | midjRequest.Index = index |
| 108 | midjRequest.Action = constant.MjActionVariation |
| 109 | } else if action == "low_variation" { |
| 110 | midjRequest.Action = constant.MjActionLowVariation |
| 111 | } else if action == "high_variation" { |
| 112 | midjRequest.Action = constant.MjActionHighVariation |
| 113 | } |
| 114 | } else if strings.Contains(action, "pan") { |
| 115 | midjRequest.Action = constant.MjActionPan |
| 116 | midjRequest.Index = 1 |
| 117 | } else if strings.Contains(action, "reroll") { |
| 118 | midjRequest.Action = constant.MjActionReRoll |
| 119 | midjRequest.Index = 1 |
| 120 | } else if action == "Outpaint" { |
| 121 | midjRequest.Action = constant.MjActionZoom |
| 122 | midjRequest.Index = 1 |
| 123 | } else if action == "CustomZoom" { |
| 124 | midjRequest.Action = constant.MjActionCustomZoom |
| 125 | midjRequest.Index = 1 |
| 126 | } else if action == "Inpaint" { |
| 127 | midjRequest.Action = constant.MjActionInPaint |
| 128 | midjRequest.Index = 1 |
| 129 | } else { |
| 130 | return MidjourneyErrorWrapper(constant.MjRequestError, "unknown_action:"+customId) |
| 131 | } |
| 132 | return nil |
| 133 | } |
no test coverage detected