stash/pkg/plugin/hooks.go

126 lines
2.9 KiB
Go
Raw Normal View History

package plugin
import (
"github.com/stashapp/stash/pkg/plugin/common"
)
type HookTriggerEnum string
// Scan-related hooks are current disabled until post-hook execution is
// integrated.
const (
SceneMarkerCreatePost HookTriggerEnum = "SceneMarker.Create.Post"
SceneMarkerUpdatePost HookTriggerEnum = "SceneMarker.Update.Post"
SceneMarkerDestroyPost HookTriggerEnum = "SceneMarker.Destroy.Post"
SceneCreatePost HookTriggerEnum = "Scene.Create.Post"
SceneUpdatePost HookTriggerEnum = "Scene.Update.Post"
SceneDestroyPost HookTriggerEnum = "Scene.Destroy.Post"
ImageCreatePost HookTriggerEnum = "Image.Create.Post"
ImageUpdatePost HookTriggerEnum = "Image.Update.Post"
ImageDestroyPost HookTriggerEnum = "Image.Destroy.Post"
GalleryCreatePost HookTriggerEnum = "Gallery.Create.Post"
GalleryUpdatePost HookTriggerEnum = "Gallery.Update.Post"
GalleryDestroyPost HookTriggerEnum = "Gallery.Destroy.Post"
MovieCreatePost HookTriggerEnum = "Movie.Create.Post"
MovieUpdatePost HookTriggerEnum = "Movie.Update.Post"
MovieDestroyPost HookTriggerEnum = "Movie.Destroy.Post"
PerformerCreatePost HookTriggerEnum = "Performer.Create.Post"
PerformerUpdatePost HookTriggerEnum = "Performer.Update.Post"
PerformerDestroyPost HookTriggerEnum = "Performer.Destroy.Post"
StudioCreatePost HookTriggerEnum = "Studio.Create.Post"
StudioUpdatePost HookTriggerEnum = "Studio.Update.Post"
StudioDestroyPost HookTriggerEnum = "Studio.Destroy.Post"
TagCreatePost HookTriggerEnum = "Tag.Create.Post"
TagUpdatePost HookTriggerEnum = "Tag.Update.Post"
TagDestroyPost HookTriggerEnum = "Tag.Destroy.Post"
)
var AllHookTriggerEnum = []HookTriggerEnum{
SceneMarkerCreatePost,
SceneMarkerUpdatePost,
SceneMarkerDestroyPost,
SceneCreatePost,
SceneUpdatePost,
SceneDestroyPost,
ImageCreatePost,
ImageUpdatePost,
ImageDestroyPost,
GalleryCreatePost,
GalleryUpdatePost,
GalleryDestroyPost,
MovieCreatePost,
MovieUpdatePost,
MovieDestroyPost,
PerformerCreatePost,
PerformerUpdatePost,
PerformerDestroyPost,
StudioCreatePost,
StudioUpdatePost,
StudioDestroyPost,
TagCreatePost,
TagUpdatePost,
TagDestroyPost,
}
func (e HookTriggerEnum) IsValid() bool {
switch e {
case SceneMarkerCreatePost,
SceneMarkerUpdatePost,
SceneMarkerDestroyPost,
SceneCreatePost,
SceneUpdatePost,
SceneDestroyPost,
ImageCreatePost,
ImageUpdatePost,
ImageDestroyPost,
GalleryCreatePost,
GalleryUpdatePost,
GalleryDestroyPost,
MovieCreatePost,
MovieUpdatePost,
MovieDestroyPost,
PerformerCreatePost,
PerformerUpdatePost,
PerformerDestroyPost,
StudioCreatePost,
StudioUpdatePost,
StudioDestroyPost,
TagCreatePost,
TagUpdatePost,
TagDestroyPost:
return true
}
return false
}
func (e HookTriggerEnum) String() string {
return string(e)
}
func addHookContext(argsMap common.ArgsMap, hookContext common.HookContext) {
argsMap[common.HookContextKey] = hookContext
}