Fix build errors and start working on constructing outbox activities for the various action types

pull/20391/head
Anthony Wang 2022-07-07 13:11:59 -05:00
parent 721b734049
commit fa72294f64
No known key found for this signature in database
GPG Key ID: BC96B00AEC5F2D76
3 changed files with 14 additions and 9 deletions

View File

@ -14,7 +14,7 @@ import (
func FederatedUserNew(name string, IRI ap.IRI) error {
user := &user_model.User{
Name: name,
Email: name,
Email: name, // TODO: change this to something else to prevent collisions with normal users
LoginType: auth.Federated,
Website: IRI.String(),
}

View File

@ -152,12 +152,17 @@ func PersonOutbox(ctx *context.APIContext) {
outbox := ap.OrderedCollectionNew(ap.IRI(link + "/outbox"))
for _, action := range feed {
if action.OpType == models.ActionCommentIssue {
log.Debug("action", action)
activity := ap.Note{Type: ap.NoteType, Content: ap.NaturalLanguageValuesNew()}
activity.Content.Set("en", ap.Content(action.Content))
outbox.OrderedItems.Append(activity)
// TODO: There are 26 action types! This is going to take quite a while to implement...
log.Debug("action", action)
var activity ap.ObjectOrLink
switch action.OpType {
case models.ActionCreateRepo:
activity = ap.Create{Type: ap.CreateType}//, Object: forgefed.RepositoryNew()}
case models.ActionRenameRepo:
activity = ap.Move{Type: ap.MoveType}//, Object: forgefed.RepositoryNew()}
// etc
}
outbox.OrderedItems.Append(activity)
}
outbox.TotalItems = uint(len(outbox.OrderedItems))
@ -183,7 +188,7 @@ func PersonFollowing(ctx *context.APIContext) {
link := strings.TrimSuffix(setting.AppURL, "/") + "/api/v1/activitypub/user/" + ctx.ContextUser.Name
users, err := user_model.GetUserFollowing(ctx.ContextUser, utils.GetListOptions(ctx))
users, _, err := user_model.GetUserFollowing(ctx, ctx.ContextUser, ctx.Doer, utils.GetListOptions(ctx))
if err != nil {
ctx.ServerError("GetUserFollowing", err)
return
@ -220,7 +225,7 @@ func PersonFollowers(ctx *context.APIContext) {
link := strings.TrimSuffix(setting.AppURL, "/") + "/api/v1/activitypub/user/" + ctx.ContextUser.Name
users, err := user_model.GetUserFollowers(ctx.ContextUser, utils.GetListOptions(ctx))
users, _, err := user_model.GetUserFollowers(ctx, ctx.ContextUser, ctx.Doer, utils.GetListOptions(ctx))
if err != nil {
ctx.ServerError("GetUserFollowers", err)
return

View File

@ -180,7 +180,7 @@ func RepoFollowers(ctx *context.APIContext) {
link := strings.TrimSuffix(setting.AppURL, "/") + "/api/v1/activitypub/repo/" + ctx.ContextUser.Name + "/" + ctx.Repo.Repository.Name
users, err := user_model.GetUserFollowers(ctx.ContextUser, utils.GetListOptions(ctx))
users, _, err := user_model.GetUserFollowers(ctx, ctx.ContextUser, ctx.Doer, utils.GetListOptions(ctx))
if err != nil {
ctx.ServerError("GetUserFollowers", err)
return