From 703954d997852df984bcfab6ed1359d607cb4502 Mon Sep 17 00:00:00 2001 From: mrz1836 Date: Thu, 2 Jul 2020 13:57:22 -0400 Subject: [PATCH] Fixes for Roundesk api changes --- cmd/common.go | 6 +----- integrations/roundesk/roundesk.go | 34 ++++++++++++++++--------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/cmd/common.go b/cmd/common.go index c8a7871..74aadc1 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -479,7 +479,7 @@ func getRoundeskProfile(alias, domain string, allowCache bool) (profile *roundes } // Success or failure - if profile != nil && profile.Profile != nil && len(profile.Profile.ID) > 0 { + if profile != nil && profile.Profile != nil && len(profile.Profile.Paymail) > 0 { chalker.Log(chalker.SUCCESS, "Roundesk profile was found") // Store in db? @@ -860,9 +860,5 @@ func (p *PaymailDetails) Display() { } chalker.Log(chalker.DEFAULT, fmt.Sprintf("URL : %s", chalk.Cyan.Color("https://roundesk.co/u/"+displayPaymail))) - - if len(p.Roundesk.Profile.Nonce) > 0 { - chalker.Log(chalker.DEFAULT, fmt.Sprintf("Nonce : %s", chalk.Cyan.Color(p.Roundesk.Profile.Nonce))) - } } } diff --git a/integrations/roundesk/roundesk.go b/integrations/roundesk/roundesk.go index 8520865..1c739a0 100644 --- a/integrations/roundesk/roundesk.go +++ b/integrations/roundesk/roundesk.go @@ -17,7 +17,7 @@ import ( const ( defaultGetTimeout = 15 // In seconds defaultUserAgent = "go:roundesk" // Default user agent - roundeskURL = "https://roundesk.co:4443" // Network to use + roundeskURL = "https://roundesk.co/api/" // Network to use ) // Override the package defaults @@ -35,19 +35,16 @@ type Response struct { // Profile is the roundesk public profile type Profile struct { - Bio string `json:"bio"` - Dev float64 `json:"dev"` - Ent float64 `json:"ent"` - Headline string `json:"headline"` - ID string `json:"_id"` - Int float64 `json:"inv"` - LastUpdate int64 `json:"lastUpdate"` - Mar float64 `json:"mar"` - Name string `json:"name"` - Nonce string `json:"nonce"` - Paymail string `json:"paymail"` - Twetch string `json:"twetch"` - Uxd float64 `json:"uxd"` + Bio string `json:"bio"` + Dev float64 `json:"dev"` + Ent float64 `json:"ent"` + Headline string `json:"headline"` + Inv float64 `json:"inv"` + Mar float64 `json:"mar"` + Name string `json:"name"` + Paymail string `json:"paymail"` + Twetch string `json:"twetch"` + Uxd float64 `json:"uxd"` } // GetProfile will get a roundesk profile if it exists for the given paymail address @@ -55,7 +52,7 @@ type Profile struct { func GetProfile(alias, domain string, tracing bool) (response *Response, err error) { // Set the url for the request - reqURL := fmt.Sprintf("%s/api/profile/%s@%s", Network, alias, domain) + reqURL := fmt.Sprintf("%su/%s@%s", Network, alias, domain) // Create a Client and start the request client := resty.New().SetTimeout(defaultGetTimeout * time.Second) @@ -92,7 +89,12 @@ func GetProfile(alias, domain string, tracing bool) (response *Response, err err } // Decode the body of the response - err = json.Unmarshal(resp.Body(), &response) + err = json.Unmarshal(resp.Body(), &response.Profile) + + // Handle new way of detecting user is not known (Clear out the user data) + if response.Profile.Name == "Unknown" { + response.Profile.Paymail = "" + } return }