check status on upload, query escape cities for formatting maps uri format
parent
5170e96f7e
commit
1cc082083c
5
main.go
5
main.go
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"local/truckstop/config"
|
"local/truckstop/config"
|
||||||
"local/truckstop/message"
|
"local/truckstop/message"
|
||||||
"log"
|
"log"
|
||||||
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -311,7 +312,7 @@ func sendJob(job broker.Job) error {
|
||||||
}
|
}
|
||||||
maps := config.Get().Maps
|
maps := config.Get().Maps
|
||||||
if maps.Pickup {
|
if maps.Pickup {
|
||||||
pickup := fmt.Sprintf("%s,%s", job.Pickup.City, job.Pickup.State)
|
pickup := fmt.Sprintf("%s,%s", url.QueryEscape(job.Pickup.City), job.Pickup.State)
|
||||||
uri := fmt.Sprintf(maps.URIFormat, pickup, pickup)
|
uri := fmt.Sprintf(maps.URIFormat, pickup, pickup)
|
||||||
log.Printf("sending pickup image: %s", uri)
|
log.Printf("sending pickup image: %s", uri)
|
||||||
if err := sender.SendImage(uri); err != nil {
|
if err := sender.SendImage(uri); err != nil {
|
||||||
|
|
@ -319,7 +320,7 @@ func sendJob(job broker.Job) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if maps.Dropoff {
|
if maps.Dropoff {
|
||||||
dropoff := fmt.Sprintf("%s,%s", job.Dropoff.City, job.Dropoff.State)
|
dropoff := fmt.Sprintf("%s,%s", url.QueryEscape(job.Dropoff.City), job.Dropoff.State)
|
||||||
uri := fmt.Sprintf(maps.URIFormat, dropoff, dropoff)
|
uri := fmt.Sprintf(maps.URIFormat, dropoff, dropoff)
|
||||||
log.Printf("sending dropoff image: %s", uri)
|
log.Printf("sending dropoff image: %s", uri)
|
||||||
if err := sender.SendImage(uri); err != nil {
|
if err := sender.SendImage(uri); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,11 @@ func (m Matrix) SendImage(uri string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if response.StatusCode != http.StatusOK {
|
||||||
|
b, _ := ioutil.ReadAll(response.Body)
|
||||||
|
response.Body.Close()
|
||||||
|
return fmt.Errorf("failed to get %s: (%d) %s", uri, response.StatusCode, b)
|
||||||
|
}
|
||||||
b, err := ioutil.ReadAll(response.Body)
|
b, err := ioutil.ReadAll(response.Body)
|
||||||
response.Body.Close()
|
response.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue