mirror of
https://github.com/bitmagnet-io/bitmagnet.git
synced 2026-08-02 01:13:44 -04:00
48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package target
|
|
|
|
import (
|
|
"github.com/bitmagnet-io/bitmagnet/internal/plugin/builder"
|
|
plugin_search "github.com/bitmagnet-io/bitmagnet/internal/plugin/core/search"
|
|
"github.com/bitmagnet-io/bitmagnet/internal/ref"
|
|
"github.com/bitmagnet-io/bitmagnet/internal/search"
|
|
"github.com/bitmagnet-io/bitmagnet/internal/slice"
|
|
"github.com/bitmagnet-io/bitmagnet/internal/target"
|
|
"github.com/bitmagnet-io/bitmagnet/pkg/plugin"
|
|
"go.uber.org/fx"
|
|
)
|
|
|
|
type deps struct {
|
|
fx.In
|
|
}
|
|
|
|
var (
|
|
Ref = ref.Root.MustSub("target")
|
|
|
|
Plugin = builder.NewPlugin(
|
|
Ref,
|
|
builder.WithDescription[deps]("Allows torrents to be sent to external targets"),
|
|
builder.WithActivation[deps](plugin.ActivationAlways),
|
|
builder.WithDependencies[deps](
|
|
plugin_search.Ref,
|
|
),
|
|
builder.WithFxOption[deps](
|
|
fx.Provide(
|
|
fx.Annotate(
|
|
func(targets [][]target.TorrentContentTarget, search search.TorrentContent) target.Registry {
|
|
return target.NewRegistry(
|
|
slice.FlatMap(
|
|
targets,
|
|
func(targets []target.TorrentContentTarget) []target.TorrentContentTarget {
|
|
return targets
|
|
},
|
|
),
|
|
search,
|
|
)
|
|
},
|
|
fx.ParamTags(`group:"torrent_targets"`),
|
|
),
|
|
),
|
|
),
|
|
)
|
|
)
|