Skip to content

Commit

Permalink
fix: crashes in shopware shop listing
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Jan 17, 2025
1 parent aa1c624 commit d86295e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion account-api/merchant.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type MerchantShop struct {
DocumentComment string `json:"documentComment"`
Activated bool `json:"activated"`
AccountId string `json:"accountId"`
ShopNumber int `json:"shopNumber"`
ShopNumber string `json:"shopNumber"`
CreationDate string `json:"creationDate"`
Branch interface{} `json:"branch"`
SubscriptionModules []struct {
Expand Down
44 changes: 36 additions & 8 deletions cmd/account/account_merchant_shop_composer.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,42 @@ var accountCompanyMerchantShopComposerCmd = &cobra.Command{
composer["repositories"] = make(map[string]interface{})
}

repositories, _ := composer["repositories"].(map[string]interface{})

repositories["shopware-packages"] = struct {
Type string `json:"type"`
Url string `json:"url"`
}{
Type: "composer",
Url: "https://packages.shopware.com",
repositories, ok := composer["repositories"].(map[string]interface{})

if ok {
repositories["shopware-packages"] = struct {
Type string `json:"type"`
Url string `json:"url"`
}{
Type: "composer",
Url: "https://packages.shopware.com",
}
} else {
repositories := composer["repositories"].([]interface{})

repoExists := false

for _, repo := range repositories {
mappedRepo, ok := repo.(map[string]interface{})

if !ok {
continue
}

if mappedRepo["url"] == "https://packages.shopware.com" {
repoExists = true
break
}
}

if !repoExists {
repositories = append(repositories, map[string]interface{}{
"type": "composer",
"url": "https://packages.shopware.com",
})

composer["repositories"] = repositories
}
}

if content, err = json.MarshalIndent(composer, "", " "); err != nil {
Expand Down

0 comments on commit d86295e

Please sign in to comment.