From a71e29f9115e845bc1fe5b098f726f257ba56fa6 Mon Sep 17 00:00:00 2001 From: Ashlynne Mitchell Date: Sun, 28 Dec 2025 02:12:40 +1100 Subject: [PATCH] fix: use DateTime in XRPC examples --- examples/oauth.ex | 11 ++++++----- lib/atex/xrpc.ex | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/oauth.ex b/examples/oauth.ex index 21fe373..b62e2a3 100644 --- a/examples/oauth.ex +++ b/examples/oauth.ex @@ -38,7 +38,7 @@ defmodule ExampleOAuthPlug do end end - post "/create-post" do + get "/create-post" do conn = fetch_session(conn) with {:ok, client} <- XRPC.OAuthClient.from_conn(conn), @@ -51,19 +51,20 @@ defmodule ExampleOAuthPlug do record: %{ "$type": "app.bsky.feed.post", text: "Hello world from atex!", - createdAt: NaiveDateTime.to_iso8601(NaiveDateTime.utc_now()) + createdAt: DateTime.to_iso8601(DateTime.utc_now()) } } }) do IO.inspect(response, label: "output") - conn - |> XRPC.OAuthClient.update_conn(client) - |> send_resp(200, response.uri) + send_resp(conn, 200, response.body.uri) else :error -> send_resp(conn, 401, "Unauthorized") + {:error, :reauth} -> + send_resp(conn, 401, "session expired but still in your cookie") + err -> IO.inspect(err, label: "xrpc failed") send_resp(conn, 500, "xrpc failed") diff --git a/lib/atex/xrpc.ex b/lib/atex/xrpc.ex index fe4d92b..1646821 100644 --- a/lib/atex/xrpc.ex +++ b/lib/atex/xrpc.ex @@ -112,7 +112,7 @@ defmodule Atex.XRPC do rkey: Atex.TID.now() |> to_string(), record: %{ text: "Hello World", - createdAt: NaiveDateTime.to_iso8601(NaiveDateTime.utc_now()) + createdAt: DateTime.to_iso8601(DateTime.utc_now()) } } ) @@ -126,7 +126,7 @@ defmodule Atex.XRPC do rkey: Atex.TID.now() |> to_string(), record: %App.Bsky.Feed.Post{ text: "Hello World!", - createdAt: NaiveDateTime.to_iso8601(NaiveDateTime.utc_now()) + createdAt: DateTime.to_iso8601(DateTime.utc_now()) } } }) -- 2.51.2