Skip to content

Commit

Permalink
fix cosmetic no parent set
Browse files Browse the repository at this point in the history
  • Loading branch information
stelzo committed Oct 21, 2024
1 parent 9ada4dc commit de1e2d1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ func ListItems(itemType string, w http.ResponseWriter, r *http.Request) {

expansionsParam := strings.ToLower(r.URL.Query().Get("fields[item]"))
var expansions *set.Set[string]
if itemType == "equipment" {
if itemType == "equipment" || itemType == "cosmetics" {
expansions = parseFields(expansionsParam)
if !validateFields(expansions, equipmentAllowedExpandFields) {
w.WriteHeader(http.StatusBadRequest)
Expand Down Expand Up @@ -1488,17 +1488,28 @@ func GetSingleQuestItemHandler(w http.ResponseWriter, r *http.Request) {
}

func GetSingleCosmeticHandler(w http.ResponseWriter, r *http.Request) {
GetSingleItemWithOptionalRecipeHandler("cosmetics", w, r)
GetSingleEquipmentLikeHandler(true, w, r)
}

func GetSingleEquipmentHandler(w http.ResponseWriter, r *http.Request) {
GetSingleEquipmentLikeHandler(false, w, r)
}

func GetSingleEquipmentLikeHandler(cosmetic bool, w http.ResponseWriter, r *http.Request) {
lang := r.Context().Value("lang").(string)
ankamaId := r.Context().Value("ankamaId").(int)

txn := Db.Txn(false)
defer txn.Abort()

raw, err := txn.First(fmt.Sprintf("%s-equipment", CurrentRedBlueVersionStr(Version.MemDb)), "id", ankamaId)
dbType := ""
if cosmetic {
dbType = "cosmetics"
} else {
dbType = "equipment"
}

raw, err := txn.First(fmt.Sprintf("%s-%s", CurrentRedBlueVersionStr(Version.MemDb), dbType), "id", ankamaId)
if err != nil || raw == nil {
w.WriteHeader(http.StatusNotFound)
return
Expand Down

0 comments on commit de1e2d1

Please sign in to comment.