Process Like activities for starring repos
This commit is contained in:
parent
8e5621c9c3
commit
c94a891aad
2 changed files with 15 additions and 4 deletions
|
@ -6,11 +6,22 @@ package activitypub
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
|
|
||||||
ap "github.com/go-ap/activitypub"
|
ap "github.com/go-ap/activitypub"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Star a repo
|
// Process a Like activity to star a repository
|
||||||
func Star(ctx context.Context, like ap.Like) error {
|
func ReceiveStar(ctx context.Context, like ap.Like) (err error) {
|
||||||
return nil
|
user, err := personIRIToUser(ctx, like.Actor.GetLink())
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
repo, err := repositoryIRIToRepository(ctx, like.Object.GetLink())
|
||||||
|
if err != nil || strings.Contains(repo.Name, "@") || repo.IsPrivate {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return repo_model.StarRepo(user.ID, repo.ID, true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ func RepoInbox(ctx *context.APIContext) {
|
||||||
activitypub.Comment(ctx, activity.Object.(ap.Note))
|
activitypub.Comment(ctx, activity.Object.(ap.Note))
|
||||||
}
|
}
|
||||||
case ap.LikeType:
|
case ap.LikeType:
|
||||||
activitypub.Star(ctx, activity)
|
activitypub.ReceiveStar(ctx, activity)
|
||||||
default:
|
default:
|
||||||
log.Info("Incoming unsupported ActivityStreams type: %s", activity.Type)
|
log.Info("Incoming unsupported ActivityStreams type: %s", activity.Type)
|
||||||
ctx.PlainText(http.StatusNotImplemented, "ActivityStreams type not supported")
|
ctx.PlainText(http.StatusNotImplemented, "ActivityStreams type not supported")
|
||||||
|
|
Loading…
Add table
Reference in a new issue