2022-06-20 15:38:57 -05:00
|
|
|
// 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 forgefed
|
|
|
|
|
|
|
|
import (
|
2022-07-11 12:45:00 -05:00
|
|
|
ap "gitea.com/Ta180m/activitypub"
|
2022-06-20 15:38:57 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// GetItemByType instantiates a new ForgeFed object if the type matches
|
|
|
|
// otherwise it defaults to existing activitypub package typer function.
|
|
|
|
func GetItemByType(typ ap.ActivityVocabularyType) (ap.Item, error) {
|
|
|
|
if typ == CommitType {
|
|
|
|
return CommitNew(), nil
|
|
|
|
} else if typ == BranchType {
|
|
|
|
return BranchNew(), nil
|
|
|
|
} else if typ == RepositoryType {
|
|
|
|
return RepositoryNew(""), nil
|
|
|
|
} else if typ == PushType {
|
|
|
|
return PushNew(), nil
|
|
|
|
} else if typ == TicketType {
|
|
|
|
return TicketNew(), nil
|
|
|
|
}
|
|
|
|
return ap.GetItemByType(typ)
|
|
|
|
}
|