1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-29 09:31:11 -05:00
forgejo/models/forgefed/activity.go

39 lines
1.1 KiB
Go
Raw Normal View History

2024-01-03 12:29:12 -05:00
// Copyright 2023 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package forgefed
import (
"code.gitea.io/gitea/modules/validation"
ap "github.com/go-ap/activitypub"
)
// ForgeLike activity data type
// swagger:model
type ForgeLike struct {
// swagger:ignore
ap.Activity
}
func (s ForgeLike) MarshalJSON() ([]byte, error) {
return s.Activity.MarshalJSON()
}
func (s *ForgeLike) UnmarshalJSON(data []byte) error {
return s.Activity.UnmarshalJSON(data)
}
func (s ForgeLike) Validate() []string {
var result []string
result = append(result, validation.ValidateNotEmpty(string(s.Type), "type")...)
2024-01-03 12:52:41 -05:00
result = append(result, validation.ValidateOneOf(string(s.Type), []any{"Like"})...)
2024-01-03 12:29:12 -05:00
result = append(result, validation.ValidateNotEmpty(s.Actor.GetID().String(), "actor")...)
result = append(result, validation.ValidateNotEmpty(s.Object.GetID().String(), "object")...)
result = append(result, validation.ValidateNotEmpty(s.StartTime.String(), "startTime")...)
2024-01-03 12:52:41 -05:00
if s.StartTime.IsZero() {
result = append(result, "StartTime was invalid.")
}
2024-01-03 12:29:12 -05:00
return result
}