forgejo/modules/forgefed/star.go

54 lines
1.1 KiB
Go
Raw Normal View History

2023-11-07 08:30:32 +00:00
// Copyright 2023 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package forgefed
import (
2023-11-09 14:38:55 +00:00
"code.gitea.io/gitea/modules/context"
2023-11-07 08:30:32 +00:00
ap "github.com/go-ap/activitypub"
)
type (
SourceType string
)
type SourceTypes []SourceType
const (
StarType ap.ActivityVocabularyType = "Star"
)
const (
ForgejoSourceType SourceType = "frogejo"
)
var KnownSourceTypes = SourceTypes{
ForgejoSourceType,
}
2023-11-09 13:24:19 +00:00
// Star activity data type
2023-11-07 08:30:32 +00:00
type Star struct {
2023-11-09 20:54:17 +00:00
// swagger:ignore
2023-11-07 08:30:32 +00:00
ap.Activity
2023-11-09 13:24:19 +00:00
// Source identifies the system which generated this activity. Exactly one value has to be specified.
2023-11-07 08:30:32 +00:00
Source SourceType `jsonld:"source,omitempty"`
}
2023-11-09 14:38:55 +00:00
// Infos needed to star a repo
type StarRepo struct {
StargazerID int `json:"Stargazer"`
RepoID int `json:"RepoToStar"`
}
// StarNew initializes a Star type activity
// Guess: no return value needed, we may need to add the star to the context
2023-11-07 08:30:32 +00:00
func StarNew(id ap.ID, ob ap.ID) *Star {
a := ap.ActivityNew(id, StarType, ob)
2023-11-09 14:38:55 +00:00
o := Star{Activity: *a, Source: ForgejoSourceType}
2023-11-07 08:30:32 +00:00
return &o
}
2023-11-09 14:38:55 +00:00
func AddStar(ctx *context.APIContext) {
}