diff --git a/models/activities/action.go b/models/activities/action.go index a849b093f6..4baedbfe12 100644 --- a/models/activities/action.go +++ b/models/activities/action.go @@ -328,15 +328,14 @@ func (a *Action) GetIssueContent() string { // GetFeedsOptions options for retrieving feeds type GetFeedsOptions struct { db.ListOptions - RequestedUser *user_model.User // the user we want activity for - RequestedTeam *organization.Team // the team we want activity for - RequestedRepo *repo_model.Repository // the repo we want activity for - RequestedActionType ActionType // the type of activity we want - Actor *user_model.User // the user viewing the activity - IncludePrivate bool // include private actions - OnlyPerformedBy bool // only actions performed by requested user - IncludeDeleted bool // include deleted actions - Date string // the day we want activity for: YYYY-MM-DD + RequestedUser *user_model.User // the user we want activity for + RequestedTeam *organization.Team // the team we want activity for + RequestedRepo *repo_model.Repository // the repo we want activity for + Actor *user_model.User // the user viewing the activity + IncludePrivate bool // include private actions + OnlyPerformedBy bool // only actions performed by requested user + IncludeDeleted bool // include deleted actions + Date string // the day we want activity for: YYYY-MM-DD } // GetFeeds returns actions according to the provided options @@ -448,10 +447,6 @@ func activityQueryCondition(opts GetFeedsOptions) (builder.Cond, error) { } } - if opts.RequestedActionType != 0 { - cond = cond.And(builder.Eq{"`action`.op_type": opts.RequestedActionType}) - } - return cond, nil } diff --git a/routers/api/v1/activitypub/person.go b/routers/api/v1/activitypub/person.go index 28a3a60ba8..630dd6f5d1 100644 --- a/routers/api/v1/activitypub/person.go +++ b/routers/api/v1/activitypub/person.go @@ -9,8 +9,6 @@ import ( "net/http" "strings" - "code.gitea.io/gitea/models/activities" - "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" @@ -18,7 +16,6 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/routers/api/v1/utils" "code.gitea.io/gitea/services/activitypub" - "code.gitea.io/gitea/services/convert" ap "github.com/go-ap/activitypub" ) @@ -168,75 +165,10 @@ func PersonOutbox(ctx *context.APIContext) { // type: string // required: true // responses: - // "200": + // "501": // "$ref": "#/responses/ActivityPub" - iri := ctx.ContextUser.GetIRI() - - orderedCollection := ap.OrderedCollectionNew(ap.IRI(iri + "/outbox")) - orderedCollection.First = ap.IRI(iri + "/outbox?page=1") - - outbox := ap.OrderedCollectionPageNew(orderedCollection) - outbox.First = ap.IRI(iri + "/outbox?page=1") - - feed, err := activities.GetFeeds(ctx, activities.GetFeedsOptions{ - RequestedUser: ctx.ContextUser, - RequestedActionType: activities.ActionCreateRepo, - Actor: ctx.Doer, - IncludePrivate: false, - IncludeDeleted: false, - ListOptions: utils.GetListOptions(ctx), - }) - - // Only specify next if this amount of feed corresponds to the calculated limit. - if len(feed) == convert.ToCorrectPageSize(ctx.FormInt("limit")) { - outbox.Next = ap.IRI(fmt.Sprintf("%s/outbox?page=%d", iri, ctx.FormInt("page")+1)) - } - - // Only specify previous page when there is one. - if ctx.FormInt("page") > 1 { - outbox.Prev = ap.IRI(fmt.Sprintf("%s/outbox?page=%d", iri, ctx.FormInt("page")-1)) - } - - if err != nil { - ctx.ServerError("Couldn't fetch feed", err) - return - } - - for _, action := range feed { - // Created a repo - object := ap.Note{Type: ap.NoteType, Content: ap.NaturalLanguageValuesNew()} - _ = object.Content.Set("en", ap.Content(action.GetRepoName())) - create := ap.Create{Type: ap.CreateType, Object: object} - err := outbox.OrderedItems.Append(create) - if err != nil { - ctx.ServerError("OrderedItems.Append", err) - return - } - } - - // TODO: Remove this code and implement an ActionStarRepo type, so `GetFeeds` - // can handle this with correct pagination and ordering. - stars, err := repo_model.GetStarredRepos(ctx, ctx.ContextUser.ID, false, db.ListOptions{Page: 1, PageSize: 1000000}) - if err != nil { - ctx.ServerError("Couldn't fetch stars", err) - return - } - - for _, star := range stars { - object := ap.Note{Type: ap.NoteType, Content: ap.NaturalLanguageValuesNew()} - _ = object.Content.Set("en", ap.Content("Starred "+star.Name)) - create := ap.Create{Type: ap.CreateType, Object: object} - err := outbox.OrderedItems.Append(create) - if err != nil { - ctx.ServerError("OrderedItems.Append", err) - return - } - } - - outbox.TotalItems = uint(len(outbox.OrderedItems)) - - response(ctx, outbox) + ctx.Status(http.StatusNotImplemented) } // PersonFollowing function returns the user's Following Collection diff --git a/routers/api/v1/activitypub/repo.go b/routers/api/v1/activitypub/repo.go index 5d66dd5a9f..50324e9ec5 100644 --- a/routers/api/v1/activitypub/repo.go +++ b/routers/api/v1/activitypub/repo.go @@ -168,10 +168,9 @@ func RepoOutbox(ctx *context.APIContext) { // type: string // required: true // responses: - // "200": + // "501": // "$ref": "#/responses/ActivityPub" - // TODO ctx.Status(http.StatusNotImplemented) }