Process Like activities for starring repos
parent
8e5621c9c3
commit
c94a891aad
|
@ -6,11 +6,22 @@ package activitypub
|
|||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
|
||||
ap "github.com/go-ap/activitypub"
|
||||
)
|
||||
|
||||
// Star a repo
|
||||
func Star(ctx context.Context, like ap.Like) error {
|
||||
return nil
|
||||
// Process a Like activity to star a repository
|
||||
func ReceiveStar(ctx context.Context, like ap.Like) (err error) {
|
||||
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))
|
||||
}
|
||||
case ap.LikeType:
|
||||
activitypub.Star(ctx, activity)
|
||||
activitypub.ReceiveStar(ctx, activity)
|
||||
default:
|
||||
log.Info("Incoming unsupported ActivityStreams type: %s", activity.Type)
|
||||
ctx.PlainText(http.StatusNotImplemented, "ActivityStreams type not supported")
|
||||
|
|
Loading…
Reference in New Issue