Skip to content

Commit

Permalink
Add arfleet enabled flag
Browse files Browse the repository at this point in the history
  • Loading branch information
anbsky committed Nov 5, 2024
1 parent c6b3c35 commit 8e2ff36
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
6 changes: 4 additions & 2 deletions app/query/caller.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ func (c *Caller) addDefaultHooks() {
c.AddPreflightHook(MethodGet, preflightHookGet, builtinHookName)
c.AddPreflightHook(MethodClaimSearch, preflightHookClaimSearch, builtinHookName)

c.AddPostflightHook(MethodClaimSearch, postClaimSearchArfleetThumbs, builtinHookName)
c.AddPostflightHook(MethodResolve, postResolveArfleetThumbs, builtinHookName)
if config.GetArfleetEnabled() {
c.AddPostflightHook(MethodClaimSearch, postClaimSearchArfleetThumbs, builtinHookName)
c.AddPostflightHook(MethodResolve, postResolveArfleetThumbs, builtinHookName)
}
}

func (c *Caller) CloneWithoutHook(endpoint, method, name string) *Caller {
Expand Down
15 changes: 8 additions & 7 deletions app/query/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,15 @@ func preflightHookGet(caller *Caller, ctx context.Context) (*jsonrpc.RPCResponse
contentURL = "https://" + stConfig["host"] + fmt.Sprintf(stConfig["startpath"], claim.ClaimID, sdHash)
}

// Inject Arfleet URL
arUrl, err := arweave.GetClaimUrl(config.GetArfleetCDN(), claim.ClaimID)
if err != nil || arUrl == "" {
responseResult[ParamStreamingUrl] = contentURL
} else {
responseResult[ParamStreamingUrl] = arUrl
if config.GetArfleetEnabled() {
// Inject Arfleet URL
arUrl, err := arweave.GetClaimUrl(config.GetArfleetCDN(), claim.ClaimID)
if err != nil || arUrl == "" {
responseResult[ParamStreamingUrl] = contentURL
} else {
responseResult[ParamStreamingUrl] = arUrl
}
}

response.Result = responseResult
return response, nil
}
Expand Down
4 changes: 4 additions & 0 deletions apps/lbrytv/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ func GetArfleetCDN() string {
return Config.Viper.GetString("ArfleetCDN")
}

func GetArfleetEnabled() bool {
return Config.Viper.GetBool("ArfleetEnabled")
}

// GetReflectorUpstream returns config map for publish reflector server.
func GetReflectorUpstream() map[string]string {
return Config.Viper.GetStringMapString("ReflectorUpstream")
Expand Down

0 comments on commit 8e2ff36

Please sign in to comment.