finish chores
This commit is contained in:
parent
64ad60a8e2
commit
1cc4af9c1b
24 changed files with 542 additions and 224 deletions
|
|
@ -7,7 +7,7 @@ RUN go install ./...
|
|||
|
||||
|
||||
FROM alpine:latest
|
||||
RUN apk --no-cache add ca-certificates
|
||||
RUN apk --no-cache add ca-certificates tzdata
|
||||
WORKDIR /app
|
||||
COPY --from=builder /go/bin/app .
|
||||
COPY config.yaml config.yaml
|
||||
|
|
|
|||
|
|
@ -13,3 +13,5 @@ SpaceAPI extensions
|
|||
===================
|
||||
|
||||
* Key `ext_ccc` describes Chaos Computer Club relation status (Example values: `"chaostreff"` or `"erfa"`)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ func getCalendars() {
|
|||
outputChan := parser.GetOutputChan()
|
||||
calendar := Calendar{}
|
||||
calendar.Space = spaceData.Space
|
||||
events := []Event{}
|
||||
var events []Event
|
||||
go func() {
|
||||
for event := range outputChan {
|
||||
events = append(events, mapEventObject(event))
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ func readSpaceurl() []SpaceUrl {
|
|||
return result
|
||||
}
|
||||
|
||||
func deleteSpaceurl(id string) {
|
||||
func deleteSpaceurl(url string) {
|
||||
session, err := mgo.Dial(config.MongoDbServer)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -108,7 +108,7 @@ func deleteSpaceurl(id string) {
|
|||
session.SetMode(mgo.Monotonic, true)
|
||||
|
||||
c := session.DB(config.MongoDbDatabase).C("spaceurl")
|
||||
c.Remove(bson.M{"_id": id})
|
||||
c.Remove(bson.M{"url": url})
|
||||
}
|
||||
|
||||
func readCalendar() []Calendar {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@ var config = ConfigFile{}
|
|||
|
||||
func main() {
|
||||
data, _ := ioutil.ReadFile("config.yaml")
|
||||
yaml.Unmarshal(data, &config)
|
||||
err := yaml.Unmarshal(data, &config)
|
||||
if err != nil {
|
||||
panic("Can't load config")
|
||||
}
|
||||
config.SharedSecret = os.Getenv("SHARED_SECRET")
|
||||
|
||||
router := NewRouter()
|
||||
|
|
@ -55,7 +58,7 @@ func SpaceUrlAdd(w http.ResponseWriter, r *http.Request) {
|
|||
func SpaceUrlUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
SharedSecret := vars["SharedSecret"]
|
||||
if(SharedSecret == config.SharedSecret) {
|
||||
if SharedSecret == config.SharedSecret {
|
||||
spaceUrl := SpaceUrl{}
|
||||
createEntry(&spaceUrl, w, r)
|
||||
updateSpaceurl(spaceUrl)
|
||||
|
|
@ -65,9 +68,9 @@ func SpaceUrlUpdate(w http.ResponseWriter, r *http.Request) {
|
|||
func SpaceUrlDelete(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
SharedSecret := vars["SharedSecret"]
|
||||
Id := vars["id"]
|
||||
Url := vars["url"]
|
||||
if SharedSecret == config.SharedSecret {
|
||||
deleteSpaceurl(Id)
|
||||
deleteSpaceurl(Url)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -77,11 +80,10 @@ func loadSpaceData() {
|
|||
timestamp := time.Now().Unix()
|
||||
|
||||
for _, spaceUrl := range spaceUrls {
|
||||
if(spaceUrl.Validated && int64(spaceUrl.LastUpdated + 60) < timestamp) {
|
||||
if spaceUrl.Validated && int64(spaceUrl.LastUpdated + 60) < timestamp {
|
||||
spaceData := SpaceData{}
|
||||
err := getJson(spaceUrl.Url, &spaceData)
|
||||
if(err != nil)
|
||||
{
|
||||
if err != nil {
|
||||
log.Println(spaceUrl.Url)
|
||||
log.Println(err)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,5 @@ type Event struct {
|
|||
Class string `json:"class"`
|
||||
Url string `json:"url"`
|
||||
Sequence int `json:"sequence"`
|
||||
WholeDayEvent bool `json:"whileDayEvent"`
|
||||
|
||||
WholeDayEvent bool `json:"wholeDayEvent"`
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ var IndexRoutes = Routes{
|
|||
Route{
|
||||
"SpaceUrlDelete",
|
||||
"DELETE",
|
||||
"/urls/{id}/{SharedSecret}",
|
||||
"/urls/{url}/{SharedSecret}",
|
||||
SpaceUrlDelete,
|
||||
},
|
||||
Route{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue