diff --git a/CHANGELOG.md b/CHANGELOG.md index 081845d..f3e3746 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- `mastodon`, `telegram` and `discord` in `PLATFORMS` and the `Platform` type, + matching the `/v1` spec's `Channel.platform` enum. + ### Changed - The PyPI distribution name is now `postify-sdk` (was `postify`), matching the diff --git a/scripts/sync-spec.sh b/scripts/sync-spec.sh index 4b82bde..18d19c3 100644 --- a/scripts/sync-spec.sh +++ b/scripts/sync-spec.sh @@ -18,14 +18,26 @@ url="${POSTIFY_SPEC_URL:-https://app.usepostify.com/v1/openapi.json}" if [[ -n "${POSTIFY_SPEC_SOURCE:-}" ]]; then echo "Vendoring spec from ${POSTIFY_SPEC_SOURCE}" - cp "${POSTIFY_SPEC_SOURCE}" "${dest}" + cp "${POSTIFY_SPEC_SOURCE}" "${dest}.tmp" else echo "Fetching spec from ${url}" curl -fsSL "${url}" -o "${dest}.tmp" - python -c "import json,sys; json.load(open(sys.argv[1]))" "${dest}.tmp" - mv "${dest}.tmp" "${dest}" fi +# Production serves the spec minified. Re-serialise it the way spec/v1.json is +# committed (2-space indent, UTF-8, trailing newline) so a drift PR shows only +# the real change instead of rewriting all 5,000+ lines onto one. +python - "${dest}.tmp" "${dest}" <<'PY' +import json, sys + +with open(sys.argv[1], encoding="utf-8") as src: + doc = json.load(src) +with open(sys.argv[2], "w", encoding="utf-8", newline="\n") as out: + json.dump(doc, out, indent=2, ensure_ascii=False) + out.write("\n") +PY +rm -f "${dest}.tmp" + ops=$(python - "$dest" <<'PY' import json, sys diff --git a/spec/v1.json b/spec/v1.json index 0b4f866..414cf61 100644 --- a/spec/v1.json +++ b/spec/v1.json @@ -4277,7 +4277,10 @@ "pinterest", "youtube", "bluesky", - "reddit" + "reddit", + "mastodon", + "telegram", + "discord" ], "description": "Social platform this channel publishes to." }, @@ -4766,7 +4769,7 @@ "type": "null" } ], - "description": "Most recent delivery error, if any." + "description": "Why the latest delivery failed, as a sentence you can show your users. Present only when `stage` is `failed` or `dlq`; otherwise null." } }, "required": [ diff --git a/src/postify/models.py b/src/postify/models.py index da682d7..fcc212d 100644 --- a/src/postify/models.py +++ b/src/postify/models.py @@ -83,6 +83,9 @@ "youtube", "bluesky", "reddit", + "mastodon", + "telegram", + "discord", ) Platform = Union[ Literal[ @@ -96,6 +99,9 @@ "youtube", "bluesky", "reddit", + "mastodon", + "telegram", + "discord", ], str, ] diff --git a/tests/unit/test_models.py b/tests/unit/test_models.py index 896fccf..f69b711 100644 --- a/tests/unit/test_models.py +++ b/tests/unit/test_models.py @@ -147,7 +147,7 @@ def test_an_unknown_platform_or_status_does_not_raise() -> None: channel = models.Channel.model_validate( { "id": "chn_1", - "platform": "mastodon", # not in this SDK's PLATFORMS tuple + "platform": "friendster", # not in this SDK's PLATFORMS tuple "handle": "@acme", "avatar_url": None, "followers": None, @@ -157,7 +157,7 @@ def test_an_unknown_platform_or_status_does_not_raise() -> None: "created_at": "2026-08-05T12:00:00.000Z", } ) - assert channel.platform == "mastodon" + assert channel.platform == "friendster" assert channel.status == "quarantined"