|
@@ -4,6 +4,7 @@ import (
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
|
|
+ "net/http"
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
@@ -112,14 +113,19 @@ func GetUserByID(config APIConfig, userID int) (User, error) {
|
|
client := getClient(rl)
|
|
client := getClient(rl)
|
|
response, _ := client.Do(req)
|
|
response, _ := client.Do(req)
|
|
|
|
|
|
- var result *UserResponse
|
|
|
|
- json.NewDecoder(response.Body).Decode(&result)
|
|
|
|
|
|
+ if response.StatusCode != http.StatusOK {
|
|
|
|
+ var errorResult *UserResponse
|
|
|
|
+ json.NewDecoder(response.Body).Decode(&errorResult)
|
|
|
|
|
|
- if result.ErrorType != "" {
|
|
|
|
- return User{}, fmt.Errorf("Failed to get discourse user. Error: %s", strings.Join(result.Errors, "; "))
|
|
|
|
|
|
+ if errorResult.ErrorType != "" {
|
|
|
|
+ return User{}, fmt.Errorf("failed to get discourse user. Error: %s", strings.Join(errorResult.Errors, "; "))
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- return result.User, nil
|
|
|
|
|
|
+ var result *User
|
|
|
|
+ json.NewDecoder(response.Body).Decode(&result)
|
|
|
|
+
|
|
|
|
+ return *result, nil
|
|
}
|
|
}
|
|
|
|
|
|
func GetUsersByMinTrustLevel(config APIConfig, minTrustLevel int64) ([]User, error) {
|
|
func GetUsersByMinTrustLevel(config APIConfig, minTrustLevel int64) ([]User, error) {
|