Fix #2: ical calendar: take 'cancelled' status into account #4
@ -23,9 +23,11 @@ var _ EventConsumer = (*CallAndReponse)(nil)
|
||||
// MeetingTimer provides the next meeting time.
|
||||
type MeetingTimer interface {
|
||||
NextMeetingTime() time.Time
|
||||
MeetingsOnMonth(ctx context.Context, timeInMonth time.Time) []time.Time
|
||||
MeetingsOnMonth(ctx context.Context, timeInMonth time.Time) []MeetingInfo
|
||||
}
|
||||
|
||||
var _ MeetingTimer = (*RemoteCalendar)(nil)
|
||||
|
||||
type CallAndResponseCommand interface {
|
||||
CmdTag() string
|
||||
CmdDescription() string
|
||||
|
@ -51,10 +51,10 @@ func (c *CmdCalendar) Handle(ctx context.Context, car *CallAndReponse, evt *even
|
||||
car.sendReplyInThread(ctx, evt, calendarMD)
|
||||
}
|
||||
|
||||
func MeetingCalendar(ctx context.Context, meetingTimes []time.Time) string {
|
||||
func MeetingCalendar(ctx context.Context, meetings []MeetingInfo) string {
|
||||
log := GetBotLog(ctx)
|
||||
|
||||
dateInMonth := meetingTimes[0]
|
||||
dateInMonth := meetings[0].StartTime
|
||||
firstOfMonth := time.Date(dateInMonth.Year(), dateInMonth.Month(), 1, 0, 0, 0, 0, dateInMonth.Location())
|
||||
lastOfMonth := firstOfMonth.AddDate(0, 1, -1)
|
||||
|
||||
@ -70,10 +70,14 @@ func MeetingCalendar(ctx context.Context, meetingTimes []time.Time) string {
|
||||
meetingCal[weekIndex][weekdayIndex] = fmt.Sprintf("%2d", dayNum)
|
||||
}
|
||||
|
||||
for _, meetingTime := range meetingTimes {
|
||||
weekIndex, weekdayIndex := calendarIndex(meetingTime, firstOfMonth)
|
||||
// dayNum := strings.TrimSpace(meetingCal[weekIndex][weekdayIndex])
|
||||
entry := "<strong><u>" + meetingTime.Format("15:04") + "</u></strong>"
|
||||
for _, meeting := range meetings {
|
||||
weekIndex, weekdayIndex := calendarIndex(meeting.StartTime, firstOfMonth)
|
||||
var entry string
|
||||
if meeting.IsCancelled {
|
||||
entry = "❌"
|
||||
} else {
|
||||
entry = "<strong>" + meeting.StartTime.Format("15:04") + "</strong>"
|
||||
}
|
||||
meetingCal[weekIndex][weekdayIndex] = entry
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user