#!/usr/bin/env bash set -euo pipefail python - <<'PY' from pathlib import Path path = Path("/opt/sojorn/go-backend/internal/handlers/post_handler.go") text = path.read_text() if "chain_parent_id" not in text: text = text.replace("\t\tDurationMS *int `json:\"duration_ms\"`\n\t\tIsBeacon", "\t\tDurationMS *int `json:\"duration_ms\"`\n\t\tAllowChain *bool `json:\"allow_chain\"`\n\t\tChainParentID *string `json:\"chain_parent_id\"`\n\t\tIsBeacon") if "allowChain := !req.IsBeacon" not in text: marker = "post := &models.Post{\n" if marker in text: text = text.replace(marker, "allowChain := !req.IsBeacon\n\tif req.AllowChain != nil {\n\t\tallowChain = *req.AllowChain\n\t}\n\n\t" + marker, 1) text = text.replace("\t\tAllowChain: !req.IsBeacon,\n", "\t\tAllowChain: allowChain,\n") marker = "\tif req.CategoryID != nil {\n\t\tcatID, _ := uuid.Parse(*req.CategoryID)\n\t\tpost.CategoryID = &catID\n\t}\n" if marker in text and "post.ChainParentID" not in text: text = text.replace(marker, marker + "\n\tif req.ChainParentID != nil && *req.ChainParentID != \"\" {\n\t\tparentID, err := uuid.Parse(*req.ChainParentID)\n\t\tif err == nil {\n\t\t\tpost.ChainParentID = &parentID\n\t\t}\n\t}\n", 1) path.write_text(text) PY