hardcoded user-agent as tusky + added a DoTries()

This commit is contained in:
farhan 2021-01-25 21:06:47 -05:00
parent 1bebd9064c
commit 4706bce7e3
4 changed files with 8 additions and 2 deletions

View File

@ -66,8 +66,9 @@ func GetNodeInfo(endpoint string, o RunningInstance) RunningInstance {
pleromastodon_nodeinfo_uri := "https://" + endpoint + "/nodeinfo/2.0.json"
req, _ := http.NewRequest("GET", pleromastodon_nodeinfo_uri, nil)
req.Header.Set("User-Agent", "Tusky")
pleromastodon_api_resp, err := o.client.Do(req)
pleromastodon_api_resp, err := DoTries(&o, req)
if err != nil {
return o
} else {
@ -88,6 +89,7 @@ func GetNodeInfo(endpoint string, o RunningInstance) RunningInstance {
// Check the front page
index_uri := "https://" + endpoint + "/"
req, _ = http.NewRequest("GET", index_uri, nil)
req.Header.Set("User-Agent", "Tusky")
resp_index, err := DoTries(&o, req)
o.LastRun = time.Now().Format(time.RFC3339)
if err != nil {

View File

@ -87,6 +87,7 @@ func PollMastodonPleroma(endpoint string, o *RunningInstance) {
api_timeline := "https://" + endpoint + "/api/v1/timelines/public?limit=40&since_id=" + min_id
req, err := http.NewRequest("GET", api_timeline, nil)
req.Header.Set("User-Agent", "Tusky")
if err != nil {
logFatal.Fatal("Unable to create new request for " + endpoint + ": ", err)
return

View File

@ -109,9 +109,10 @@ func check_post(uri string) (PostJson, error) {
o := GetHTTPSession(postjson.instance)
req, _ := http.NewRequest("GET", uri, nil)
req.Header.Set("User-Agent", "Tusky")
req.Header.Add("Accept", "application/ld+json")
resp, err := o.client.Do(req)
resp, err := DoTries(&o, req)
if err != nil {
return postjson, errors.New("Connection error to " + uri)
}
@ -189,6 +190,7 @@ func check_user(uri string) (UserJson, error) {
o := GetHTTPSession(userjson.instance)
req, _ := http.NewRequest("GET", uri, nil)
req.Header.Set("User-Agent", "Tusky")
req.Header.Add("Accept", "application/ld+json")
var resp *http.Response

View File

@ -29,6 +29,7 @@ func StreamMastodon(endpoint string, o *RunningInstance) {
api_timeline := "https://" + endpoint + "/api/v1/streaming/public"
req, err := http.NewRequest("GET", api_timeline, nil)
req.Header.Set("User-Agent", "Tusky")
if err != nil {
logFatal.Fatal("Unable to create new request for " + endpoint + ", exiting.")
return