Save issue IRIs when creating them from AS objects

This commit is contained in:
Anthony Wang 2022-11-27 18:38:20 +00:00
parent 1066cfe785
commit 77896f1a50
No known key found for this signature in database
GPG Key ID: 42A5B952E6DD8D38
3 changed files with 14 additions and 10 deletions

View File

@ -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
}

View File

@ -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)
}

View File

@ -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{