This repository has been archived on 2024-01-11. You can view files and clone it, but cannot push or open issues or pull requests.
gitea/modules/activitypub/star.go

28 lines
706 B
Go

// Copyright 2022 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package activitypub
import (
"context"
"strings"
repo_model "code.gitea.io/gitea/models/repo"
ap "github.com/go-ap/activitypub"
)
// 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)
}