Something went wrong. Try again.
A terminal client for Tangled. forked from aly.codes/tg
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071package cli
import ( "context" "fmt" "time"
"github.com/alyraffauf/tg/atproto" "github.com/bluesky-social/indigo/atproto/syntax")
type issueCommentRecord struct { Type string `json:"$type"` Issue string `json:"issue"` Body string `json:"body"` CreatedAt string `json:"createdAt"`}
type pullCommentRecord struct { Type string `json:"$type"` Pull string `json:"pull"` Body string `json:"body"` CreatedAt string `json:"createdAt"`}
func createIssueComment(ctx context.Context, issueURI, body string) (createdRecordResult, error) { atClient, did, err := authenticatedATProto(ctx) if err != nil { return createdRecordResult{}, err } rkey := string(syntax.NewTIDNow(0)) uri, _, err := atClient.PutRecord(ctx, atproto.PutRecordInput{ Repo: did, Collection: "sh.tangled.repo.issue.comment", Rkey: rkey, Record: issueCommentRecord{ Type: "sh.tangled.repo.issue.comment", Issue: issueURI, Body: body, CreatedAt: time.Now().UTC().Format(time.RFC3339), }, }) if err != nil { return createdRecordResult{}, fmt.Errorf("create issue comment: %w", err) } return createdRecordResult{Rkey: rkey, URI: uri}, nil}
func createPullComment(ctx context.Context, pullURI, body string) (createdRecordResult, error) { atClient, did, err := authenticatedATProto(ctx) if err != nil { return createdRecordResult{}, err } rkey := string(syntax.NewTIDNow(0)) uri, _, err := atClient.PutRecord(ctx, atproto.PutRecordInput{ Repo: did, Collection: "sh.tangled.repo.pull.comment", Rkey: rkey, Record: pullCommentRecord{ Type: "sh.tangled.repo.pull.comment", Pull: pullURI, Body: body, CreatedAt: time.Now().UTC().Format(time.RFC3339), }, }) if err != nil { return createdRecordResult{}, fmt.Errorf("create pull request comment: %w", err) } return createdRecordResult{Rkey: rkey, URI: uri}, nil}