2019-02-09 12:30:49 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2019-02-14 23:42:52 +00:00
|
|
|
"github.com/stashapp/stash/pkg/api/urlbuilders"
|
|
|
|
"github.com/stashapp/stash/pkg/models"
|
2019-02-09 12:30:49 +00:00
|
|
|
)
|
|
|
|
|
2019-03-26 15:35:06 +00:00
|
|
|
func (r *sceneMarkerResolver) Scene(ctx context.Context, obj *models.SceneMarker) (*models.Scene, error) {
|
2019-02-09 12:30:49 +00:00
|
|
|
if !obj.SceneID.Valid {
|
|
|
|
panic("Invalid scene id")
|
|
|
|
}
|
|
|
|
qb := models.NewSceneQueryBuilder()
|
|
|
|
sceneID := int(obj.SceneID.Int64)
|
|
|
|
scene, err := qb.Find(sceneID)
|
2019-03-26 15:35:06 +00:00
|
|
|
return scene, err
|
2019-02-09 12:30:49 +00:00
|
|
|
}
|
|
|
|
|
2019-03-26 15:35:06 +00:00
|
|
|
func (r *sceneMarkerResolver) PrimaryTag(ctx context.Context, obj *models.SceneMarker) (*models.Tag, error) {
|
2019-02-09 12:30:49 +00:00
|
|
|
qb := models.NewTagQueryBuilder()
|
2019-04-20 17:32:01 +00:00
|
|
|
tag, err := qb.Find(obj.PrimaryTagID, nil)
|
2019-03-26 15:35:06 +00:00
|
|
|
return tag, err
|
2019-02-09 12:30:49 +00:00
|
|
|
}
|
|
|
|
|
2019-05-27 19:34:26 +00:00
|
|
|
func (r *sceneMarkerResolver) Tags(ctx context.Context, obj *models.SceneMarker) ([]*models.Tag, error) {
|
2019-02-09 12:30:49 +00:00
|
|
|
qb := models.NewTagQueryBuilder()
|
|
|
|
return qb.FindBySceneMarkerID(obj.ID, nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *sceneMarkerResolver) Stream(ctx context.Context, obj *models.SceneMarker) (string, error) {
|
|
|
|
baseURL, _ := ctx.Value(BaseURLCtxKey).(string)
|
|
|
|
sceneID := int(obj.SceneID.Int64)
|
2019-02-14 22:53:32 +00:00
|
|
|
return urlbuilders.NewSceneURLBuilder(baseURL, sceneID).GetSceneMarkerStreamURL(obj.ID), nil
|
2019-02-09 12:30:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *sceneMarkerResolver) Preview(ctx context.Context, obj *models.SceneMarker) (string, error) {
|
|
|
|
baseURL, _ := ctx.Value(BaseURLCtxKey).(string)
|
|
|
|
sceneID := int(obj.SceneID.Int64)
|
2019-02-14 22:53:32 +00:00
|
|
|
return urlbuilders.NewSceneURLBuilder(baseURL, sceneID).GetSceneMarkerStreamPreviewURL(obj.ID), nil
|
|
|
|
}
|