2021-05-20 06:58:43 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
2022-03-17 00:33:59 +00:00
|
|
|
"github.com/stashapp/stash/internal/manager"
|
2021-05-20 06:58:43 +00:00
|
|
|
)
|
|
|
|
|
2022-04-25 05:55:05 +00:00
|
|
|
func (r *mutationResolver) EnableDlna(ctx context.Context, input EnableDLNAInput) (bool, error) {
|
2021-05-20 06:58:43 +00:00
|
|
|
err := manager.GetInstance().DLNAService.Start(parseMinutes(input.Duration))
|
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
|
2022-04-25 05:55:05 +00:00
|
|
|
func (r *mutationResolver) DisableDlna(ctx context.Context, input DisableDLNAInput) (bool, error) {
|
2021-05-20 06:58:43 +00:00
|
|
|
manager.GetInstance().DLNAService.Stop(parseMinutes(input.Duration))
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
|
2022-04-25 05:55:05 +00:00
|
|
|
func (r *mutationResolver) AddTempDlnaip(ctx context.Context, input AddTempDLNAIPInput) (bool, error) {
|
2021-05-20 06:58:43 +00:00
|
|
|
manager.GetInstance().DLNAService.AddTempDLNAIP(input.Address, parseMinutes(input.Duration))
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
|
2022-04-25 05:55:05 +00:00
|
|
|
func (r *mutationResolver) RemoveTempDlnaip(ctx context.Context, input RemoveTempDLNAIPInput) (bool, error) {
|
2021-05-20 06:58:43 +00:00
|
|
|
ret := manager.GetInstance().DLNAService.RemoveTempDLNAIP(input.Address)
|
|
|
|
return ret, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func parseMinutes(minutes *int) *time.Duration {
|
|
|
|
var ret *time.Duration
|
|
|
|
if minutes != nil {
|
|
|
|
d := time.Duration(*minutes) * time.Minute
|
|
|
|
ret = &d
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret
|
|
|
|
}
|