this repo has no description
1package main
2
3import (
4 "github.com/bluesky-social/indigo/api/atproto"
5 "github.com/bluesky-social/indigo/api/bsky"
6 "github.com/bluesky-social/indigo/atproto/syntax"
7 "github.com/bluesky-social/indigo/lex/util"
8 "github.com/bluesky-social/indigo/xrpc"
9 "github.com/labstack/echo/v4"
10)
11
12func (s *TestServer) handleMakePost(e echo.Context) error {
13 authArgs, authed, err := s.getOauthSessionAuthArgs(e)
14 if err != nil {
15 return err
16 }
17
18 if !authed {
19 return e.Redirect(302, "/login")
20 }
21
22 post := bsky.FeedPost{
23 Text: "hello from atproto golang oauth client",
24 CreatedAt: syntax.DatetimeNow().String(),
25 }
26
27 input := atproto.RepoCreateRecord_Input{
28 Collection: "app.bsky.feed.post",
29 Repo: authArgs.Did,
30 Record: &util.LexiconTypeDecoder{Val: &post},
31 }
32
33 var out atproto.RepoCreateRecord_Output
34 if err := s.xrpcCli.Do(e.Request().Context(), authArgs, xrpc.Procedure, "application/json", "com.atproto.repo.createRecord", nil, input, &out); err != nil {
35 return err
36 }
37
38 return e.File(getFilePath("make-post.html"))
39}