Delete buggy and unneeded GET outbox

This commit is contained in:
Anthony Wang 2023-01-23 20:47:31 +00:00
parent 5a9fe9adc4
commit 90afd4f329
No known key found for this signature in database
GPG Key ID: 42A5B952E6DD8D38
3 changed files with 11 additions and 85 deletions

View File

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

View File

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

View File

@ -168,10 +168,9 @@ func RepoOutbox(ctx *context.APIContext) {
// type: string
// required: true
// responses:
// "200":
// "501":
// "$ref": "#/responses/ActivityPub"
// TODO
ctx.Status(http.StatusNotImplemented)
}