Fixed bugs around sending channel cert and enabling local testing with docker.

This commit is contained in:
Mark Beamer Jr 2019-07-30 23:32:02 -04:00 committed by Niko Storni
parent f26712b022
commit c84e1e6fb9
8 changed files with 211 additions and 49 deletions

View file

@ -11,8 +11,6 @@ import (
"strings"
"time"
"github.com/lbryio/lbry.go/extras/api"
"github.com/lbryio/lbry.go/extras/errors"
"github.com/lbryio/lbry.go/extras/null"
@ -103,24 +101,30 @@ func sanitizeFailureReason(s *string) {
func (a *APIConfig) SetChannelCert(certHex string, channelID string) error {
type apiSetChannelCertResponse struct {
Success bool `json:"success"`
Error null.String `json:"error"`
Data string `json:"data"`
}
endpoint := a.ApiURL + "/yt/channel_cert"
res, _ := http.PostForm(endpoint, url.Values{
"channel_id": {channelID},
"channel_cert": {certHex},
"auth_token": {a.ApiToken},
"channel_claim_id": {channelID},
"channel_cert": {certHex},
"auth_token": {a.ApiToken},
})
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
var response api.Response
var response apiSetChannelCertResponse
err := json.Unmarshal(body, &response)
if err != nil {
return errors.Err(err)
}
if response.Error != nil {
return errors.Err(response.Error)
if !response.Error.IsNull() {
return errors.Err(response.Error.String)
}
return nil