Changes
7 changed files (+34/-7)
-
-
@@ -26,6 +26,7 @@ import ("code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/references" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util"
-
@@ -1549,3 +1550,18 @@ func FixCommentTypeLabelWithOutsideLabels() (int64, error) {return res.RowsAffected() } func (c *Comment) GetIRI() string { err := c.LoadIssue() if err != nil { return "" } err = c.Issue.LoadRepo(db.DefaultContext) if err != nil { return "" } if strings.Contains(c.Issue.Repo.OwnerName, "@") { return c.OldTitle } return setting.AppURL + "api/v1/activitypub/note/" + c.Issue.Repo.OwnerName + "/" + c.Issue.Repo.Name + "/" + strconv.FormatInt(c.Issue.Index, 10) + "/" + strconv.FormatInt(c.ID, 10) }
-
-
-
@@ -308,10 +308,11 @@ func createComment(ctx context.Context, note *ap.Note) error {return err } _, err = issues_model.CreateCommentCtx(ctx, &issues_model.CreateCommentOptions{ Doer: user, Repo: repo, Issue: issue, Content: note.Content.String(), Doer: user, Repo: repo, Issue: issue, OldTitle: note.GetLink().String(), Content: note.Content.String(), }) return err }
-
-
-
@@ -134,6 +134,14 @@ func PersonInbox(ctx *context.APIContext) {err = follow(ctx, activity) case ap.UndoType: err = unfollow(ctx, activity) case ap.CreateType: // TODO: this is kinda a hack err = ap.OnObject(activity.Object, func(n *ap.Note) error { noteIRI := n.InReplyTo.GetLink().String() noteIRISplit := strings.Split(noteIRI, "/") n.Context = ap.IRI(strings.TrimSuffix(noteIRI, "/"+noteIRISplit[len(noteIRISplit)-1])) return createComment(ctx, n) }) default: log.Info("Incoming unsupported ActivityStreams type: %s", activity.GetType()) ctx.PlainText(http.StatusNotImplemented, "ActivityStreams type not supported")
-
-
-
@@ -140,7 +140,7 @@ func RepoInbox(ctx *context.APIContext) {return createComment(ctx, n) }) default: log.Info("Incoming unsupported ActivityStreams object type: %s", activity.Object.GetType()) log.Info("Incoming unsupported ActivityStreams object type: %s", activity.Object.GetType()) ctx.PlainText(http.StatusNotImplemented, "ActivityStreams object type not supported") return }
-
-
-
@@ -26,8 +26,10 @@ func Note(comment *issues_model.Comment) (*ap.Note, error) {} note := ap.Note{ Type: ap.NoteType, ID: ap.IRI(comment.GetIRI()), AttributedTo: ap.IRI(comment.Poster.GetIRI()), Context: ap.IRI(comment.Issue.GetIRI()), To: ap.ItemCollection{ap.IRI("https://www.w3.org/ns/activitystreams#Public")}, } note.Content = ap.NaturalLanguageValuesNew() err = note.Content.Set("en", ap.Content(comment.Content))
-
-
-
@@ -36,7 +36,7 @@ func CreateIssueComment(doer *user_model.User, repo *repo_model.Repository, issuif err != nil { return nil, err } create := activitypub.Create(repo.OriginalURL + "/inbox", note) create := activitypub.Create(repo.OriginalURL+"/inbox", note) err = activitypub.Send(doer, create) if err != nil { return nil, err
-
-
-
@@ -35,7 +35,7 @@ func NewIssue(repo *repo_model.Repository, issue *issues_model.Issue, labelIDs [if err != nil { return err } create := activitypub.Create(repo.OriginalURL + "/inbox", ticket) create := activitypub.Create(repo.OriginalURL+"/inbox", ticket) err = activitypub.Send(issue.Poster, create) if err != nil { return err
-