From 77896f1a504e3b78d342f2493ca46ec8b9b4f5b2 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Sun, 27 Nov 2022 18:38:20 +0000 Subject: [PATCH] Save issue IRIs when creating them from AS objects --- models/issues/issue.go | 5 ++++- routers/api/v1/activitypub/create.go | 17 +++++++++-------- services/comments/comments.go | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/models/issues/issue.go b/models/issues/issue.go index decfdf697e..7ae0494a3a 100644 --- a/models/issues/issue.go +++ b/models/issues/issue.go @@ -2474,7 +2474,10 @@ func DeleteOrphanedIssues() error { } func (issue *Issue) GetIRI() string { - _ = issue.LoadRepo(db.DefaultContext) + err := issue.LoadRepo(db.DefaultContext) + if err != nil { + log.Error(fmt.Sprintf("loadRepo: %v", err)) + } if strings.Contains(issue.Repo.OwnerName, "@") { return issue.OriginalAuthor } diff --git a/routers/api/v1/activitypub/create.go b/routers/api/v1/activitypub/create.go index c077ad91ef..eb4f86d59f 100644 --- a/routers/api/v1/activitypub/create.go +++ b/routers/api/v1/activitypub/create.go @@ -213,14 +213,15 @@ func createIssue(ctx context.Context, ticket *forgefed.Ticket) error { return err } issue := &issues_model.Issue{ - Index: idx, // This doesn't seem to work? - RepoID: repo.ID, - Repo: repo, - Title: ticket.Summary.String(), - PosterID: user.ID, - Poster: user, - Content: ticket.Content.String(), - IsClosed: ticket.IsResolved, + Index: idx, // This doesn't seem to work? + RepoID: repo.ID, + Repo: repo, + Title: ticket.Summary.String(), + PosterID: user.ID, + Poster: user, + Content: ticket.Content.String(), + OriginalAuthor: ticket.GetLink().String(), // Create new database field to store IRI? + IsClosed: ticket.IsResolved, } return issue_service.NewIssue(repo, issue, nil, nil, nil) } diff --git a/services/comments/comments.go b/services/comments/comments.go index 5d42490ffc..145e117df2 100644 --- a/services/comments/comments.go +++ b/services/comments/comments.go @@ -32,7 +32,7 @@ func CreateIssueComment(doer *user_model.User, repo *repo_model.Repository, issu return nil, err } - if strings.Contains(repo.Owner.Name, "@") { + if strings.Contains(repo.OwnerName, "@") { // Federated comment // Refactor this to its own function in services/activitypub create := ap.Create{