mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 06:03:51 +03:00
Check if federation enabled in StarRepo
This commit is contained in:
parent
e9bbdc678b
commit
436466dcad
1 changed files with 38 additions and 39 deletions
|
@ -32,7 +32,7 @@ func StarRepo(ctx context.Context, userID, repoID int64, star bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if star {
|
||||
if star && setting.Federation.Enabled {
|
||||
if err := sendLikeActivities(ctx, userID, repoID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -85,8 +85,7 @@ func starLocalRepo(ctx context.Context, userID, repoID int64, star bool) error {
|
|||
|
||||
// ToDo: Move to federation service or simillar
|
||||
func sendLikeActivities(ctx context.Context, userID int64, repoID int64) error {
|
||||
// TODO: should this be checked somewhere else/outside?
|
||||
if setting.Federation.Enabled {
|
||||
|
||||
// TODO: is user loading necessary here?
|
||||
log.Info("User ID: %v, Repo ID: %v", userID, repoID)
|
||||
user, err := user_model.GetUserByID(ctx, userID)
|
||||
|
@ -107,7 +106,7 @@ func sendLikeActivities(ctx context.Context, userID int64, repoID int64) error {
|
|||
}
|
||||
|
||||
for _, federatedRepo := range federatedRepos {
|
||||
target := federatedRepo.Uri
|
||||
target := federatedRepo.Uri + "/inbox/" // A like goes to the inbox of the federated repo
|
||||
log.Info("Federated Repo URI is: %v", target)
|
||||
likeActivity, err := forgefed.NewForgeLike(user.APAPIURL(), target)
|
||||
if err != nil {
|
||||
|
@ -124,7 +123,7 @@ func sendLikeActivities(ctx context.Context, userID int64, repoID int64) error {
|
|||
// ToDo: Change this to the standalone table of FederatedRepos
|
||||
apclient.Post([]byte(json), target)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue