Skip to content

Commit

Permalink
chore: remove broken alby http request for get_info
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Dec 12, 2023
1 parent db1d1aa commit 56fc1bb
Showing 1 changed file with 48 additions and 53 deletions.
101 changes: 48 additions & 53 deletions alby.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,60 +281,55 @@ func (svc *AlbyOAuthService) GetInfo(ctx context.Context, senderPubkey string) (
}).Errorf("App not found: %v", err)
return nil, err
}
tok, err := svc.FetchUserToken(ctx, app)
if err != nil {
return nil, err
}
client := svc.oauthConf.Client(ctx, tok)

req, err := http.NewRequest("GET", fmt.Sprintf("%s/getinfo", svc.cfg.AlbyAPIURL), nil)
if err != nil {
svc.Logger.WithError(err).Error("Error creating request /getinfo")
return nil, err
}

req.Header.Set("User-Agent", "NWC")

resp, err := client.Do(req)
if err != nil {
svc.Logger.WithFields(logrus.Fields{
"senderPubkey": senderPubkey,
"appId": app.ID,
"userId": app.User.ID,
}).Errorf("Failed to fetch node info: %v", err)
return nil, err
}

if resp.StatusCode < 300 {
// TODO: decode fetched node info
// err = json.NewDecoder(resp.Body).Decode(&nodeInfo)
if err != nil {
return nil, err
}
svc.Logger.WithFields(logrus.Fields{
"senderPubkey": senderPubkey,
"appId": app.ID,
"userId": app.User.ID,
}).Info("Info fetch successful")
return &NodeInfo{
Alias: alias,
Color: "color",
Pubkey: "pubkey",
Network: "mainnet",
BlockHeight: 0,
BlockHash: "blockhash",
}, err
}

errorPayload := &ErrorResponse{}
err = json.NewDecoder(resp.Body).Decode(errorPayload)
// tok, err := svc.FetchUserToken(ctx, app)
// if err != nil {
// return nil, err
// }
//client := svc.oauthConf.Client(ctx, tok)

// req, err := http.NewRequest("GET", fmt.Sprintf("%s/getinfo", svc.cfg.AlbyAPIURL), nil)
// if err != nil {
// svc.Logger.WithError(err).Error("Error creating request /getinfo")
// return nil, err
// }

// req.Header.Set("User-Agent", "NWC")

// resp, err := client.Do(req)
// if err != nil {
// svc.Logger.WithFields(logrus.Fields{
// "senderPubkey": senderPubkey,
// "appId": app.ID,
// "userId": app.User.ID,
// }).Errorf("Failed to fetch node info: %v", err)
// return nil, err
// }

// if resp.StatusCode < 300 {
svc.Logger.WithFields(logrus.Fields{
"senderPubkey": senderPubkey,
"appId": app.ID,
"userId": app.User.ID,
"APIHttpStatus": resp.StatusCode,
}).Errorf("Invoices listing failed %s", string(errorPayload.Message))
return nil, errors.New(errorPayload.Message)
"senderPubkey": senderPubkey,
"appId": app.ID,
"userId": app.User.ID,
}).Info("Info fetch successful")
return &NodeInfo{
Alias: alias,
Color: "",
Pubkey: "",
Network: "mainnet",
BlockHeight: 0,
BlockHash: "",
}, err
// }

// errorPayload := &ErrorResponse{}
// err = json.NewDecoder(resp.Body).Decode(errorPayload)
// svc.Logger.WithFields(logrus.Fields{
// "senderPubkey": senderPubkey,
// "appId": app.ID,
// "userId": app.User.ID,
// // "APIHttpStatus": resp.StatusCode,
// }).Errorf("Invoices listing failed %s", string(errorPayload.Message))
// return nil, errors.New(errorPayload.Message)
}

func (svc *AlbyOAuthService) GetBalance(ctx context.Context, senderPubkey string) (balance int64, err error) {
Expand Down

0 comments on commit 56fc1bb

Please sign in to comment.