Skip to content

Commit f03f167

Browse files
authored
Merge pull request #3 from himsngh/att
chore: add rsvp field in attendee
2 parents 3a3f647 + 15d90bb commit f03f167

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

generator.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ func Generate(prodId string, events ...*Event) (string, error) {
2020
return "", err
2121
}
2222
for _, event := range events {
23+
attendees := make([]Attendee, 0, len(event.Attendees))
24+
for _, att := range event.Attendees {
25+
if att.Rsvp == "" {
26+
att.Rsvp = Rsvp_False
27+
attendees = append(attendees, att)
28+
}
29+
}
30+
event.Attendees = attendees
2331
e := &vEvent{
2432
Event: event,
2533
DtStamp: FormatDateTime(time.Now()),
@@ -60,6 +68,15 @@ func (event *Event) Generate(prodId string) (string, error) {
6068
Events: []string{},
6169
}
6270

71+
attendees := make([]Attendee, 0, len(event.Attendees))
72+
for _, att := range event.Attendees {
73+
if att.Rsvp == "" {
74+
att.Rsvp = Rsvp_False
75+
attendees = append(attendees, att)
76+
}
77+
}
78+
event.Attendees = attendees
79+
6380
e := &vEvent{
6481
Event: event,
6582
DtStamp: FormatDateTime(time.Now()),

objects.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ type Attendee struct {
5959
PartStatus AttendeeStatus
6060
//RSVP is by default NO
6161
CuType CalendarUserType
62+
Rsvp RSVP
6263
}
6364

6465
type Role string
@@ -80,3 +81,12 @@ type CalendarUserType string
8081
const (
8182
INDIVIDUAL CalendarUserType = "INDIVIDUAL"
8283
)
84+
85+
// https://datatracker.ietf.org/doc/html/rfc5545#section-3.2.12
86+
// https://datatracker.ietf.org/doc/html/rfc5545#section-3.2.17
87+
type RSVP string
88+
89+
const (
90+
Rsvp_False RSVP = "FALSE"
91+
Rsvp_True RSVP = "TRUE"
92+
)

templates.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ VERSION:2.0
99

1010
const vevent = `BEGIN:VEVENT
1111
ORGANIZER;CN="{{.Organizer.CommonName}}":mailto:{{.Organizer.EmailAddress}}
12-
{{range $at := .Attendees}}ATTENDEE;CUTYPE={{$at.CuType}};ROLE={{$at.Role}};PARTSTAT={{$at.PartStatus}};CN="{{$at.CommonName}}";RSVP=FALSE:mailto:{{$at.EmailAddress}}
12+
{{range $at := .Attendees}}ATTENDEE;CUTYPE={{$at.CuType}};ROLE={{$at.Role}};PARTSTAT={{$at.PartStatus}};CN="{{$at.CommonName}}";RSVP={{$at.Rsvp}}:mailto:{{$at.EmailAddress}}
1313
{{end}}LOCATION:{{.Location}}
1414
DTSTAMP:{{.DtStamp}}
1515
DTSTART:{{.DtStart}}

0 commit comments

Comments
 (0)