Skip to content

Commit 2caeee2

Browse files
authored
Merge pull request #21 from AssemblyAI/refactor
Refactor
2 parents cc49bb1 + fc57487 commit 2caeee2

15 files changed

Lines changed: 625 additions & 234 deletions

File tree

cmd/config.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
var configFolderPath = ".config/assemblyai"
1818
var configFileName = "config.toml"
1919
var Token string
20+
var distinctId string
2021

2122
// configCmd represents the config command
2223
var configCmd = &cobra.Command{
@@ -43,7 +44,6 @@ var configCmd = &cobra.Command{
4344
fmt.Println("Invalid token. Try again, and if the problem persists, contact support at support@assemblyai.com")
4445
return
4546
}
46-
distinctId := uuid.New().String()
4747

4848
createConfigFile()
4949
setConfigFileValue("features.telemetry", "true")
@@ -61,20 +61,23 @@ func init() {
6161
}
6262

6363
func CheckIfTokenValid(token string) bool {
64-
6564
response := QueryApi("/account", "GET", nil)
66-
6765
if response == nil {
6866
return false
6967
}
70-
7168
var result Account
7269
if err := json.Unmarshal(response, &result); err != nil {
7370
fmt.Println("Can not unmarshal JSON")
7471
}
7572
if result.Error != nil {
7673
return false
7774
}
75+
if result.Id != nil && *result.Id != "" {
76+
distinctId = *result.Id
77+
} else {
78+
distinctId = uuid.New().String()
79+
}
80+
7881
return true
7982
}
8083

0 commit comments

Comments
 (0)