spaceapi update to 0.13 as OpenSpaceLint understands 0.13
authorBernhard Tittelbach <xro@realraum.at>
Wed, 27 Mar 2013 17:15:40 +0000 (17:15 +0000)
committerBernhard Tittelbach <xro@realraum.at>
Wed, 27 Mar 2013 17:15:40 +0000 (17:15 +0000)
r3-webstatus-spaceapi/main.go
r3-webstatus-spaceapi/spaceapi/spaceapi.go

index 28c094b..07bb194 100644 (file)
@@ -118,7 +118,7 @@ ReOpenSocket:
 func main() {
        spaceapidata.AddSpaceFeed("calendar", "application/rss+xml", "http://grical.realraum.at/s/?query=!realraum&view=rss")
        spaceapidata.AddSpaceFeed("google+", "text/html", "https://plus.google.com/113737596421797426873")
-       spaceapidata.AddSpaceContactInfo("+43780700888524", "irc://irc.oftc.net/#realraum", "realraum@realraum.at", "realraum@realraum.at", "realraum@realraum.at")
+       spaceapidata.AddSpaceContactInfo("+43780700888524", "irc://irc.oftc.net/#realraum", "realraum@realraum.at", "realraum@realraum.at", "realraum@realraum.at", "vorstand@realraum.at")
        eventqueue := make(chan string)
        ticker := time.NewTicker(time.Duration(15) * time.Minute)
        go readFromUSocket("/var/run/tuer/presence.socket", eventqueue)
index 3a0f828..9455e84 100644 (file)
@@ -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
 }
 
@@ -98,6 +100,12 @@ 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, lat float64, lon float64) SpaceInfo {
@@ -108,13 +116,22 @@ func NewSpaceInfo(space string, url string, logo string, open_icon string, close
                "logo":       logo,
                "open":       false,
                "lastchange": time.Now().Unix(),
-               "icon": SpaceInfo{
-                       "open":   open_icon,
-                       "closed": closed_icon},
-        "location": SpaceInfo{
-            "lat": lat,
-            "lon": lon},
-        "contact" : SpaceInfo {}           }
+               "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
 }