Removing GetHTTPSession for GetRunner
This commit is contained in:
parent
4706bce7e3
commit
96e47f0373
@ -26,7 +26,7 @@ func DoTries(o *RunningInstance, req *http.Request) (*http.Response, error) {
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRunner(endpoint string) RunningInstance {
|
func GetRunner(endpoint string) (RunningInstance, bool) {
|
||||||
ri_mutex.Lock()
|
ri_mutex.Lock()
|
||||||
o, exists := runninginstances[endpoint]
|
o, exists := runninginstances[endpoint]
|
||||||
if exists == false {
|
if exists == false {
|
||||||
@ -48,7 +48,7 @@ func GetRunner(endpoint string) RunningInstance {
|
|||||||
}
|
}
|
||||||
ri_mutex.Unlock()
|
ri_mutex.Unlock()
|
||||||
|
|
||||||
return o
|
return o, exists
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateRunner(endpoint string, o RunningInstance) {
|
func UpdateRunner(endpoint string, o RunningInstance) {
|
||||||
@ -162,7 +162,7 @@ func CheckInstance(newinstance string, callerEndpoint string) {
|
|||||||
|
|
||||||
func StartInstance(endpoint string) {
|
func StartInstance(endpoint string) {
|
||||||
// Check if exists. If so, get the object. If not, create it
|
// Check if exists. If so, get the object. If not, create it
|
||||||
o := GetRunner(endpoint)
|
o, _ := GetRunner(endpoint)
|
||||||
|
|
||||||
o = GetNodeInfo(endpoint, o)
|
o = GetNodeInfo(endpoint, o)
|
||||||
UpdateRunner(endpoint, o)
|
UpdateRunner(endpoint, o)
|
||||||
|
2
poll.go
2
poll.go
@ -63,7 +63,7 @@ func PollMastodonPleroma(endpoint string, o *RunningInstance) {
|
|||||||
for _, extaccount := range settings.Externalaccounts {
|
for _, extaccount := range settings.Externalaccounts {
|
||||||
if extaccount.Endpoint == endpoint {
|
if extaccount.Endpoint == endpoint {
|
||||||
use_auth = true
|
use_auth = true
|
||||||
o := GetRunner(endpoint)
|
o, _ := GetRunner(endpoint)
|
||||||
err = get_client(endpoint, &o)
|
err = get_client(endpoint, &o)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logErr.Print("Unable to register client for " + endpoint + ": ", err)
|
logErr.Print("Unable to register client for " + endpoint + ": ", err)
|
||||||
|
@ -70,6 +70,7 @@ type PostJson struct {
|
|||||||
instance string
|
instance string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func GetHTTPSession(endpoint string) RunningInstance {
|
func GetHTTPSession(endpoint string) RunningInstance {
|
||||||
ri_mutex.Lock()
|
ri_mutex.Lock()
|
||||||
o, exist := runninginstances[endpoint]
|
o, exist := runninginstances[endpoint]
|
||||||
@ -86,6 +87,7 @@ func GetHTTPSession(endpoint string) RunningInstance {
|
|||||||
|
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func check_post(uri string) (PostJson, error) {
|
func check_post(uri string) (PostJson, error) {
|
||||||
var postjson PostJson
|
var postjson PostJson
|
||||||
@ -107,7 +109,7 @@ func check_post(uri string) (PostJson, error) {
|
|||||||
}
|
}
|
||||||
postjson.instance = uri[8 : endslash+8]
|
postjson.instance = uri[8 : endslash+8]
|
||||||
|
|
||||||
o := GetHTTPSession(postjson.instance)
|
o, _ := GetRunner(postjson.instance)
|
||||||
req, _ := http.NewRequest("GET", uri, nil)
|
req, _ := http.NewRequest("GET", uri, nil)
|
||||||
req.Header.Set("User-Agent", "Tusky")
|
req.Header.Set("User-Agent", "Tusky")
|
||||||
req.Header.Add("Accept", "application/ld+json")
|
req.Header.Add("Accept", "application/ld+json")
|
||||||
@ -188,7 +190,7 @@ func check_user(uri string) (UserJson, error) {
|
|||||||
}
|
}
|
||||||
userjson.instance = uri[8 : endslash+8]
|
userjson.instance = uri[8 : endslash+8]
|
||||||
|
|
||||||
o := GetHTTPSession(userjson.instance)
|
o, _ := GetRunner(userjson.instance)
|
||||||
req, _ := http.NewRequest("GET", uri, nil)
|
req, _ := http.NewRequest("GET", uri, nil)
|
||||||
req.Header.Set("User-Agent", "Tusky")
|
req.Header.Set("User-Agent", "Tusky")
|
||||||
req.Header.Add("Accept", "application/ld+json")
|
req.Header.Add("Accept", "application/ld+json")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user