Skip to content

Commit

Permalink
REMOVE check base64 method.
Browse files Browse the repository at this point in the history
  • Loading branch information
karminski committed Sep 28, 2023
1 parent f28ad08 commit f8217c4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 43 deletions.
47 changes: 7 additions & 40 deletions src/actionruntime/restapi/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,7 @@ func (r *RESTAPIConnector) Run(resourceOptions map[string]interface{}, actionOpt
if len(res.Rows) == 0 && len(resp.Body()) > 0 {
res.Rows = append(res.Rows, map[string]interface{}{"message": string(resp.Body())})
}
if !isBase64Encoded(string(resp.Body())) {
res.Extra["raw"] = base64Encode(resp.Body())
} else {
res.Extra["raw"] = string(resp.Body())
}
res.Extra["raw"] = base64Encode(resp.Body())
res.Extra["headers"] = resp.Header()
res.Extra["statusCode"] = resp.StatusCode()
res.Extra["statusText"] = resp.Status()
Expand All @@ -270,11 +266,7 @@ func (r *RESTAPIConnector) Run(resourceOptions map[string]interface{}, actionOpt
if len(res.Rows) == 0 && len(resp.Body()) > 0 {
res.Rows = append(res.Rows, map[string]interface{}{"message": string(resp.Body())})
}
if !isBase64Encoded(string(resp.Body())) {
res.Extra["raw"] = base64Encode(resp.Body())
} else {
res.Extra["raw"] = string(resp.Body())
}
res.Extra["raw"] = base64Encode(resp.Body())
res.Extra["headers"] = resp.Header()
res.Extra["statusCode"] = resp.StatusCode()
res.Extra["statusText"] = resp.Status()
Expand All @@ -294,11 +286,7 @@ func (r *RESTAPIConnector) Run(resourceOptions map[string]interface{}, actionOpt
if len(res.Rows) == 0 && len(resp.Body()) > 0 {
res.Rows = append(res.Rows, map[string]interface{}{"message": string(resp.Body())})
}
if !isBase64Encoded(string(resp.Body())) {
res.Extra["raw"] = base64Encode(resp.Body())
} else {
res.Extra["raw"] = string(resp.Body())
}
res.Extra["raw"] = base64Encode(resp.Body())
res.Extra["headers"] = resp.Header()
res.Extra["statusCode"] = resp.StatusCode()
res.Extra["statusText"] = resp.Status()
Expand All @@ -318,11 +306,7 @@ func (r *RESTAPIConnector) Run(resourceOptions map[string]interface{}, actionOpt
if len(res.Rows) == 0 && len(resp.Body()) > 0 {
res.Rows = append(res.Rows, map[string]interface{}{"message": string(resp.Body())})
}
if !isBase64Encoded(string(resp.Body())) {
res.Extra["raw"] = base64Encode(resp.Body())
} else {
res.Extra["raw"] = string(resp.Body())
}
res.Extra["raw"] = base64Encode(resp.Body())
res.Extra["headers"] = resp.Header()
res.Extra["statusCode"] = resp.StatusCode()
res.Extra["statusText"] = resp.Status()
Expand All @@ -342,11 +326,7 @@ func (r *RESTAPIConnector) Run(resourceOptions map[string]interface{}, actionOpt
if len(res.Rows) == 0 && len(resp.Body()) > 0 {
res.Rows = append(res.Rows, map[string]interface{}{"message": string(resp.Body())})
}
if !isBase64Encoded(string(resp.Body())) {
res.Extra["raw"] = base64Encode(resp.Body())
} else {
res.Extra["raw"] = string(resp.Body())
}
res.Extra["raw"] = base64Encode(resp.Body())
res.Extra["headers"] = resp.Header()
res.Extra["statusCode"] = resp.StatusCode()
res.Extra["statusText"] = resp.Status()
Expand All @@ -367,11 +347,7 @@ func (r *RESTAPIConnector) Run(resourceOptions map[string]interface{}, actionOpt
if len(res.Rows) == 0 && len(resp.Body()) > 0 {
res.Rows = append(res.Rows, map[string]interface{}{"message": string(resp.Body())})
}
if !isBase64Encoded(string(resp.Body())) {
res.Extra["raw"] = base64Encode(resp.Body())
} else {
res.Extra["raw"] = string(resp.Body())
}
res.Extra["raw"] = base64Encode(resp.Body())
res.Extra["headers"] = resp.Header()
res.Extra["statusCode"] = resp.StatusCode()
res.Extra["statusText"] = resp.Status()
Expand All @@ -391,11 +367,7 @@ func (r *RESTAPIConnector) Run(resourceOptions map[string]interface{}, actionOpt
if len(res.Rows) == 0 && len(resp.Body()) > 0 {
res.Rows = append(res.Rows, map[string]interface{}{"message": string(resp.Body())})
}
if !isBase64Encoded(string(resp.Body())) {
res.Extra["raw"] = base64Encode(resp.Body())
} else {
res.Extra["raw"] = string(resp.Body())
}
res.Extra["raw"] = base64Encode(resp.Body())
res.Extra["headers"] = resp.Header()
res.Extra["statusCode"] = resp.StatusCode()
res.Extra["statusText"] = resp.Status()
Expand All @@ -405,11 +377,6 @@ func (r *RESTAPIConnector) Run(resourceOptions map[string]interface{}, actionOpt
return res, nil
}

func isBase64Encoded(s string) bool {
_, err := base64.StdEncoding.DecodeString(s)
return err == nil
}

func base64Encode(s []byte) string {
encoded := base64.StdEncoding.EncodeToString(s)
return encoded
Expand Down
12 changes: 9 additions & 3 deletions src/controller/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1235,10 +1235,16 @@ func (controller *Controller) ForkMarketplaceApp(c *gin.Context) {
controller.DuplicateSetStateByVersion(c, app.ExportTeamID(), toTeamID, appID, duplicatedAppID, app.ExportMainlineVersion(), model.APP_EDIT_VERSION, userID)
controller.DuplicateActionByVersion(c, app.ExportTeamID(), toTeamID, appID, duplicatedAppID, app.ExportMainlineVersion(), model.APP_EDIT_VERSION, userID)

// init parallel counter
var wg sync.WaitGroup
wg.Add(1)

// add counter to marketpalce
marketplaceAPI := illamarketplacesdk.NewIllaMarketplaceRestAPI()
errInForkCounter := marketplaceAPI.ForkCounter(illamarketplacesdk.PRODUCT_TYPE_APPS, appID)
log.Printf("errInForkCounter: %+v\n", errInForkCounter)
go func() {
defer wg.Done()
marketplaceAPI := illamarketplacesdk.NewIllaMarketplaceRestAPI()
marketplaceAPI.ForkCounter(illamarketplacesdk.PRODUCT_TYPE_APPS, appID)
}()

// audit log
auditLogger := auditlogger.GetInstance()
Expand Down

0 comments on commit f8217c4

Please sign in to comment.