From d79b92facf814fca1a33bd9fe58d588a51f46758 Mon Sep 17 00:00:00 2001 From: Abhijeet Rastogi Date: Mon, 23 Oct 2023 17:27:25 -0700 Subject: [PATCH] events: hash now includes "description" - 2 ( #17) --- calendar/gcal/event.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 calendar/gcal/event.go diff --git a/calendar/gcal/event.go b/calendar/gcal/event.go new file mode 100644 index 0000000..427c88a --- /dev/null +++ b/calendar/gcal/event.go @@ -0,0 +1,25 @@ +package gcal + +import ( + "bytes" + "crypto/md5" + "encoding/hex" + + googlecalendar "google.golang.org/api/calendar/v3" +) + +// Event is the local-representation of googlecalendar.Event +type Event struct { + *googlecalendar.Event +} + +func (e Event) Hash() string { + var buffer bytes.Buffer + buffer.WriteString(e.Summary) + buffer.WriteString(e.Start.DateTime) + buffer.WriteString(e.End.DateTime) + buffer.WriteString(e.Description) + + md5sum := md5.Sum(buffer.Bytes()) + return hex.EncodeToString(md5sum[:]) +}