An Elixir toolkit for the AT Protocol. hexdocs.pm/atex
elixir bluesky atproto decentralization

fix: use DateTime in XRPC examples

ovyerus.com a71e29f9 51735333

verified
+8 -7
+6 -5
examples/oauth.ex
··· 38 38 end 39 39 end 40 40 41 - post "/create-post" do 41 + get "/create-post" do 42 42 conn = fetch_session(conn) 43 43 44 44 with {:ok, client} <- XRPC.OAuthClient.from_conn(conn), ··· 51 51 record: %{ 52 52 "$type": "app.bsky.feed.post", 53 53 text: "Hello world from atex!", 54 - createdAt: NaiveDateTime.to_iso8601(NaiveDateTime.utc_now()) 54 + createdAt: DateTime.to_iso8601(DateTime.utc_now()) 55 55 } 56 56 } 57 57 }) do 58 58 IO.inspect(response, label: "output") 59 59 60 - conn 61 - |> XRPC.OAuthClient.update_conn(client) 62 - |> send_resp(200, response.uri) 60 + send_resp(conn, 200, response.body.uri) 63 61 else 64 62 :error -> 65 63 send_resp(conn, 401, "Unauthorized") 64 + 65 + {:error, :reauth} -> 66 + send_resp(conn, 401, "session expired but still in your cookie") 66 67 67 68 err -> 68 69 IO.inspect(err, label: "xrpc failed")
+2 -2
lib/atex/xrpc.ex
··· 112 112 rkey: Atex.TID.now() |> to_string(), 113 113 record: %{ 114 114 text: "Hello World", 115 - createdAt: NaiveDateTime.to_iso8601(NaiveDateTime.utc_now()) 115 + createdAt: DateTime.to_iso8601(DateTime.utc_now()) 116 116 } 117 117 } 118 118 ) ··· 126 126 rkey: Atex.TID.now() |> to_string(), 127 127 record: %App.Bsky.Feed.Post{ 128 128 text: "Hello World!", 129 - createdAt: NaiveDateTime.to_iso8601(NaiveDateTime.utc_now()) 129 + createdAt: DateTime.to_iso8601(DateTime.utc_now()) 130 130 } 131 131 } 132 132 })