X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=r3-webstatus-spaceapi%2Fspaceapi%2Fspaceapi.go;h=9455e8404d65b0e3f147001c1ebec36af4dc847d;hb=7e8e5a5ba8dd7940ba01c14c218fd9dd36bb4774;hp=7e088198d16de5969215f3516508cc1d87dd72c2;hpb=7aa8d6094a6e2e98a5e2ee1e9e69a58e42678ad6;p=svn42.git diff --git a/r3-webstatus-spaceapi/spaceapi/spaceapi.go b/r3-webstatus-spaceapi/spaceapi/spaceapi.go index 7e08819..9455e84 100644 --- a/r3-webstatus-spaceapi/spaceapi/spaceapi.go +++ b/r3-webstatus-spaceapi/spaceapi/spaceapi.go @@ -37,12 +37,14 @@ func (nsi SpaceInfo) UpdateSensorData(what, where, value string) { } } -func (nsi SpaceInfo) AddSpaceContactInfo(phone, irc, email, ml, jabber string) SpaceInfo { +func (nsi SpaceInfo) AddSpaceContactInfo(phone, irc, email, ml, jabber, issuemail string) SpaceInfo { nsi["contact"] = SpaceInfo{ "phone": phone, "email": email, "ml": ml, - "jabber": jabber} + "jabber": jabber, + "issue-mail": issuemail} + nsi["issue-report-channels"] = [3]string{"issue-mail","email","ml"} return nsi } @@ -64,7 +66,7 @@ func (nsi SpaceInfo) AddSpaceFeed(name, mimetype, url string) SpaceInfo { } func (nsi SpaceInfo) AddSpaceEvent(name, eventtype, extra string) SpaceInfo { - newevent := SpaceInfo{"name": name, "type": eventtype, "t": time.Now().Unix(), "extra": extra} + newevent := SpaceInfo{"name": name, "type": eventtype, "timestamp": time.Now().Unix(), "extra": extra} if nsi["events"] == nil { eventlist := make([]SpaceInfo, 1) eventlist[0] = newevent @@ -85,12 +87,12 @@ func (nsi SpaceInfo) AddSpaceEvent(name, eventtype, extra string) SpaceInfo { func (nsi SpaceInfo) AddSpaceAddress(address string) SpaceInfo { nsi["address"] = address - return nsi -} - -func (nsi SpaceInfo) AddSpaceLatLon(lat float64, lon float64) SpaceInfo { - nsi["lat"] = lat - nsi["lon"] = lon + if nsi["location"] != nil { + location, ok := nsi["location"].(SpaceInfo) + if ok { + location["address"] = address + } + } return nsi } @@ -98,9 +100,15 @@ func (nsi SpaceInfo) SetStatus(open bool, status string) { nsi["status"] = status nsi["open"] = open nsi["lastchange"] = time.Now().Unix() + state, ok := nsi["state"].(SpaceInfo) + if ok { + state["message"] = status + state["open"] = open + state["lastchange"] = nsi["lastchange"] + } } -func NewSpaceInfo(space string, url string, logo string, open_icon string, closed_icon string) SpaceInfo { +func NewSpaceInfo(space string, url string, logo string, open_icon string, closed_icon string, lat float64, lon float64) SpaceInfo { nsi := map[string]interface{}{ "api": "0.13", "space": space, @@ -108,9 +116,22 @@ func NewSpaceInfo(space string, url string, logo string, open_icon string, close "logo": logo, "open": false, "lastchange": time.Now().Unix(), - "icon": map[string]interface{}{ - "open": open_icon, - "closed": closed_icon}} + "icon": SpaceInfo{ + "open": open_icon, + "closed": closed_icon, + }, + "state": SpaceInfo{ + "open": false, + "lastchange":time.Now().Unix(), + "icon": SpaceInfo{ + "open": open_icon, + "closed": closed_icon}, + }, + "location": SpaceInfo{ + "lat": lat, + "lon": lon}, + "contact" : SpaceInfo {}, + } return nsi }