tangled
alpha
login
or
join now
comet.sh
/
atex
23
fork
atom
An Elixir toolkit for the AT Protocol.
hexdocs.pm/atex
elixir
bluesky
atproto
decentralization
23
fork
atom
overview
issues
pulls
pipelines
fix: use DateTime in XRPC examples
ovyerus.com
2 months ago
a71e29f9
51735333
verified
This commit was signed with the committer's
known signature
.
ovyerus.com
SSH Key Fingerprint:
SHA256:mXbp9WNBIT0nRNe28t2hrxfSwnSX7UBeW2DVlIyf0uw=
+8
-7
2 changed files
expand all
collapse all
unified
split
examples
oauth.ex
lib
atex
xrpc.ex
+6
-5
examples/oauth.ex
···
38
38
end
39
39
end
40
40
41
41
-
post "/create-post" do
41
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
54
-
createdAt: NaiveDateTime.to_iso8601(NaiveDateTime.utc_now())
54
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
60
-
conn
61
61
-
|> XRPC.OAuthClient.update_conn(client)
62
62
-
|> send_resp(200, response.uri)
60
60
+
send_resp(conn, 200, response.body.uri)
63
61
else
64
62
:error ->
65
63
send_resp(conn, 401, "Unauthorized")
64
64
+
65
65
+
{:error, :reauth} ->
66
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
115
-
createdAt: NaiveDateTime.to_iso8601(NaiveDateTime.utc_now())
115
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
129
-
createdAt: NaiveDateTime.to_iso8601(NaiveDateTime.utc_now())
129
129
+
createdAt: DateTime.to_iso8601(DateTime.utc_now())
130
130
}
131
131
}
132
132
})