···
return syntax.ATURI(fmt.Sprintf("at://%s/%s/%s", i.OwnerDid, tangled.RepoIssueNSID, i.Rkey))
52
+
func IssueFromRecord(did, rkey string, record tangled.RepoIssue) Issue {
53
+
created, err := time.Parse(time.RFC3339, record.CreatedAt)
55
+
created = time.Now()
59
+
if record.Body != nil {
64
+
RepoAt: syntax.ATURI(record.Repo),
65
+
OwnerDid: record.Owner,
68
+
Title: record.Title,
70
+
Open: true, // new issues are open by default
74
+
func ResolveIssueFromAtUri(e Execer, issueUri syntax.ATURI) (syntax.ATURI, int, error) {
75
+
ownerDid := issueUri.Authority().String()
76
+
issueRkey := issueUri.RecordKey().String()
81
+
query := `select repo_at, issue_id from issues where owner_did = ? and rkey = ?`
82
+
err := e.QueryRow(query, ownerDid, issueRkey).Scan(&repoAt, &issueId)
87
+
return syntax.ATURI(repoAt), issueId, nil
90
+
func IssueCommentFromRecord(e Execer, did, rkey string, record tangled.RepoIssueComment) (Comment, error) {
91
+
created, err := time.Parse(time.RFC3339, record.CreatedAt)
93
+
created = time.Now()
97
+
if record.Owner != nil {
98
+
ownerDid = *record.Owner
101
+
issueUri, err := syntax.ParseATURI(record.Issue)
103
+
return Comment{}, err
106
+
repoAt, issueId, err := ResolveIssueFromAtUri(e, issueUri)
108
+
return Comment{}, err
111
+
comment := Comment{
112
+
OwnerDid: ownerDid,
120
+
return comment, nil
func NewIssue(tx *sql.Tx, issue *Issue) error {