Skip to content

Commit

Permalink
Added sequence number, and fill-in email
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Barberio <insomniac@slackware.it>
  • Loading branch information
insomniacslk committed Sep 12, 2024
1 parent 6ab891b commit 88048c8
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
"github.com/sirupsen/logrus"
)

const (
SeqNum = 0
)

var (
hturl = url.URL{
Scheme: "https",
Expand All @@ -26,7 +30,7 @@ type StringField struct {
}

type IntField struct {
IntValue string `json:"intValue,omitempty"`
IntegerValue string `json:"integerValue,omitempty"`
}

type Value struct {
Expand All @@ -50,6 +54,20 @@ type ArrayField struct {
} `json:"arrayValue,omitempty"`
}

type MapField struct {
MapValue struct {
Fields struct {
ConferenceID IntField `json:"conference_id,omitempty"`
Conference StringField `json:"conference,omitempty"`
UpdatedAt StringField `json:"updated_at,omitempty"`
UpdatedTsz StringField `json:"updated_tsz,omitempty"`
Color StringField `json:"color,omitempty"`
Name StringField `json:"name,omitempty"`
ID IntField `json:"id,omitempty"`
} `json:"fields,omitempty"`
} `json:"mapValue,omitempty"`
}

type Item struct {
Document struct {
Name string `json:"name"`
Expand All @@ -60,7 +78,7 @@ type Item struct {
Title StringField `json:"title,omitempty"`
Description StringField `json:"description,omitempty"`
Media ArrayField `json:"media,omitempty"`
Type interface{} `json:"type,omitempty"`
Type MapField `json:"type,omitempty"`
BeginTsz StringField `json:"begin_tsz,omitempty"`
EndTsz StringField `json:"end_tsz,omitempty"`
BeginTimestamp StringField `json:"begin_timestamp,omitempty"`
Expand Down Expand Up @@ -123,12 +141,12 @@ func main() {
}
ics := fmt.Sprintf(`BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//moca/camp/schedule v1.0//EN
PRODID:-//moca/camp/schedule v1.0//IT
VTIMEZONE: Europe/Rome
`)

for _, item := range items {
eventUID := item.Document.Name
eventUID := item.Document.Fields.Type.MapValue.Fields.ID.IntegerValue
location := item.Document.Fields.Location.MapValue.Fields.Name.StringValue
speakerNames := make([]string, 0, len(item.Document.Fields.Speakers.ArrayValue.Values))
for _, v := range item.Document.Fields.Speakers.ArrayValue.Values {
Expand All @@ -143,7 +161,6 @@ VTIMEZONE: Europe/Rome
if len(speakerNames) > 0 {
speakers = strings.Join(speakerNames, ", ")
}
speakerEmail := "unknown"
start, err := time.Parse("2006-01-02T15:04:05Z", item.Document.Fields.BeginTsz.StringValue)
if err != nil {
logrus.Fatalf("Failed to parse start time %q: %v", item.Document.Fields.BeginTsz.StringValue, err)
Expand All @@ -158,7 +175,8 @@ VTIMEZONE: Europe/Rome
description = strings.Replace(description, "\r", "", -1)
ics += fmt.Sprintf(`BEGIN:VEVENT
UID:%s
ORGANIZER;CN=%s:MAILTO:%s
SEQUENCE: %d
ORGANIZER;CN=%s:MAILTO:info@olografix.org
DTSTAMP:20240912T140000Z
DTSTART:%s
DTEND:%s
Expand All @@ -169,8 +187,8 @@ LOCATION: %s
END:VEVENT
`,
eventUID,
SeqNum,
speakers,
speakerEmail,
start.Format("20060102T150405Z"),
end.Format("20060102T150405Z"),
summary,
Expand Down

0 comments on commit 88048c8

Please sign in to comment.