refac
parent
003388c847
commit
c1cdc6dc0c
|
|
@ -188,8 +188,18 @@ func (ntg NTGVision) Search(states []config.State) ([]Job, error) {
|
|||
return jobs, err
|
||||
}
|
||||
|
||||
func getNTGToken() string {
|
||||
return config.Get().Brokers.NTG.Token
|
||||
}
|
||||
|
||||
func setNTGToken(token string) {
|
||||
conf := config.Get()
|
||||
conf.Brokers.NTG.Token = token
|
||||
config.Set(*conf)
|
||||
}
|
||||
|
||||
func (ntg NTGVision) search(states []config.State) (io.ReadCloser, error) {
|
||||
if config.Get().Brokers.NTG.Token == "" {
|
||||
if getNTGToken() == "" {
|
||||
if err := ntg.refreshAuth(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -232,9 +242,7 @@ func (ntg NTGVision) refreshAuth() error {
|
|||
if len(v.Token) == 0 {
|
||||
return errors.New("failed to get token from login call")
|
||||
}
|
||||
conf := config.Get()
|
||||
conf.Brokers.NTG.Token = v.Token
|
||||
config.Set(*conf)
|
||||
setNTGToken(v.Token)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -283,7 +291,7 @@ func (ntg NTGVision) newRequest(states []config.State) (*http.Request, error) {
|
|||
return nil, err
|
||||
}
|
||||
setNTGHeaders(request)
|
||||
request.Header.Set("Authorization", "Bearer "+config.Get().Brokers.NTG.Token)
|
||||
request.Header.Set("Authorization", "Bearer "+getNTGToken())
|
||||
|
||||
return request, nil
|
||||
}
|
||||
|
|
@ -294,7 +302,7 @@ func setNTGHeaders(request *http.Request) {
|
|||
request.Header.Set("Accept-Language", "en-US,en;q=0.5")
|
||||
request.Header.Set("Accept-Encoding", "gzip, deflate, br")
|
||||
request.Header.Set("Content-Type", "application/json;charset=utf-8")
|
||||
//request.Header.Set("Authorization", "Bearer "+config.Get().Brokers.NTG.Token)
|
||||
//request.Header.Set("Authorization", "Bearer "+getNTGToken())
|
||||
request.Header.Set("Origin", "https://ntgvision.com")
|
||||
request.Header.Set("DNT", "1")
|
||||
request.Header.Set("Connection", "keep-alive")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
todo:
|
||||
- cache on disk jobinfo
|
||||
- tokens in db, not in config
|
||||
- mark jobs no longer avail by modifying
|
||||
- write-as for clients so ma can write to pa by default
|
||||
|
|
@ -24,6 +23,7 @@ todo:
|
|||
- banlist criteria like vendors, brokers, metadata
|
||||
- set up copy for caleb, broc
|
||||
done:
|
||||
- cache on disk jobinfo
|
||||
- link to view more
|
||||
- map with to-from line
|
||||
- TO CONFLUENT.RS OR W/E
|
||||
|
|
|
|||
Loading…
Reference in New Issue