|
|
|
@ -26,8 +26,8 @@ import (
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
// APIEndpoint = "https://hodlhodl.com/api/v1"
|
|
|
|
|
TestAPIEndpoint = "https://hhtestnet.com/api/v1"
|
|
|
|
|
APIkey = "***REMOVED***"
|
|
|
|
|
//TestAPIEndpoint = "https://hhtestnet.com/api/v1"
|
|
|
|
|
//APIkey = "***REMOVED***"
|
|
|
|
|
|
|
|
|
|
// Config
|
|
|
|
|
infoFormat = "====== "
|
|
|
|
@ -42,6 +42,8 @@ const (
|
|
|
|
|
clientJid = "jid"
|
|
|
|
|
clientPass = "pass"
|
|
|
|
|
configContactSep = ";"
|
|
|
|
|
APIEndPoint = "testapiendpoint"
|
|
|
|
|
APIKey = "apikey"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
@ -71,6 +73,7 @@ type config struct {
|
|
|
|
|
Server map[string]string `mapstructure:"server"`
|
|
|
|
|
Client map[string]string `mapstructure:"client"`
|
|
|
|
|
Contacts string `string:"contact"`
|
|
|
|
|
Hodlhodl map[string]string `mapstructure:"hodlhodl"`
|
|
|
|
|
LogStanzas map[string]string `mapstructure:"logstanzas"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -166,7 +169,8 @@ func startClient(config *config) {
|
|
|
|
|
fmt.Println(infoFormat+"Now sending messages to "+currentContact+" in a private conversation\n")
|
|
|
|
|
CorrespChan <- currentContact
|
|
|
|
|
fmt.Println("currentContacts", currentContact)
|
|
|
|
|
notifications := gethdlNotif()
|
|
|
|
|
// fmt.Println("CONFIG.HODLHDOL :", config.Hodlhodl[APIKey])
|
|
|
|
|
notifications := gethdlNotif(config.Hodlhodl[APIKey], config.Hodlhodl[APIEndPoint])
|
|
|
|
|
startMessaging(client, config, notifications)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -245,14 +249,14 @@ func (n Notification ) IsEmpty() bool {
|
|
|
|
|
return reflect.DeepEqual(Notification{}, n)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func gethdlNotif() string {
|
|
|
|
|
func gethdlNotif(APIKey string, APIEndPoint string ) string {
|
|
|
|
|
fmt.Println("get notif")
|
|
|
|
|
|
|
|
|
|
req, err := http.NewRequest("POST", TestAPIEndpoint + "/notifications/read", nil)
|
|
|
|
|
req, err := http.NewRequest("POST", APIEndPoint + "/notifications/read", nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
}
|
|
|
|
|
req.Header.Add("Authorization", "Bearer " + APIkey)
|
|
|
|
|
req.Header.Add("Authorization", "Bearer " + APIKey)
|
|
|
|
|
req.Header.Set("Content-Type", "application/json")
|
|
|
|
|
|
|
|
|
|
resp, err := http.DefaultClient.Do(req)
|
|
|
|
@ -329,7 +333,7 @@ func readConfig() *config {
|
|
|
|
|
if d, e := isDirectory(config.LogStanzas[logFilePath]); (e != nil || !d) && on {
|
|
|
|
|
log.Panicln("The log file path could not be found or is not a directory.")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Println("config in ReadConfig :", &config)
|
|
|
|
|
return &config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|