Skip to content

Commit

Permalink
🔥 remove former ical formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
iChemy committed Aug 2, 2023
1 parent a422a9e commit 7ac759e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 57 deletions.
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/traPtitech/knoQ
go 1.20

require (
github.com/arran4/golang-ical v0.0.0-20230425234049-f69e132f2b0c
github.com/carlescere/scheduler v0.0.0-20170109141437-ee74d2f83d82
github.com/go-gormigrate/gormigrate/v2 v2.1.0
github.com/go-sql-driver/mysql v1.7.1
Expand All @@ -13,7 +14,6 @@ require (
github.com/jszwec/csvutil v1.8.0
github.com/labstack/echo-contrib v0.15.0
github.com/labstack/echo/v4 v4.10.2
github.com/lestrrat-go/ical v0.0.0-20201229070544-61f83f92eaf4
github.com/ory/dockertest/v3 v3.10.0
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/stretchr/testify v1.8.4
Expand All @@ -32,7 +32,6 @@ require (
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/arran4/golang-ical v0.0.0-20230425234049-f69e132f2b0c // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -51,9 +50,7 @@ require (
github.com/imdario/mergo v0.3.12 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/lestrrat-go/bufferpool v0.0.0-20210118235918-2deb6a84c94c // indirect
github.com/lib/pq v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
Expand Down
6 changes: 0 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@ github.com/labstack/echo/v4 v4.10.2 h1:n1jAhnq/elIFTHr1EYpiYtyKgx4RW9ccVgkqByZaN
github.com/labstack/echo/v4 v4.10.2/go.mod h1:OEyqf2//K1DFdE57vw2DRgWY0M7s65IVQO2FzvI4J5k=
github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8=
github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
github.com/lestrrat-go/bufferpool v0.0.0-20180220091733-e7784e1b3e37/go.mod h1:vs3QXw2t0jsgjLEG7JZt0uE1jcSkxnQr+5bhQ80UJHE=
github.com/lestrrat-go/bufferpool v0.0.0-20210118235918-2deb6a84c94c h1:Txi8K4WxH1BefzJqBrWIRH0JiiZlR4lUUsP+SPOqRXc=
github.com/lestrrat-go/bufferpool v0.0.0-20210118235918-2deb6a84c94c/go.mod h1:KwmXn5FpkX4is3nM+CKsCnFSqdY7ujdNpE2L/KztlDM=
github.com/lestrrat-go/ical v0.0.0-20201229070544-61f83f92eaf4 h1:fki3ZusGjvcjvWqK4QxzQ2/dJ5RnWaOawQDtjhO2oQw=
github.com/lestrrat-go/ical v0.0.0-20201229070544-61f83f92eaf4/go.mod h1:+LubDFwR2Ub76rO5RSWSyyl5TeP6/2blWXUNp8cW6ds=
github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
Expand Down Expand Up @@ -202,7 +197,6 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
Expand Down
48 changes: 3 additions & 45 deletions presentation/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

ics "github.com/arran4/golang-ical"
"github.com/gofrs/uuid"
"github.com/lestrrat-go/ical"
)

type ScheduleStatus int
Expand Down Expand Up @@ -106,47 +105,6 @@ type EventRes struct {
Model
}

func iCalVeventFormat(e *domain.Event, host string) *ical.Event {
timeLayout := "20060102T150405Z"
vevent := ical.NewEvent()
_ = vevent.AddProperty("uid", e.ID.String())
_ = vevent.AddProperty("dtstamp", time.Now().UTC().Format(timeLayout))
_ = vevent.AddProperty("dtstart", e.TimeStart.UTC().Format(timeLayout))
_ = vevent.AddProperty("dtend", e.TimeEnd.UTC().Format(timeLayout))
_ = vevent.AddProperty("created", e.CreatedAt.UTC().Format(timeLayout))
_ = vevent.AddProperty("last-modified", e.UpdatedAt.UTC().Format(timeLayout))
_ = vevent.AddProperty("summary", e.Name)
e.Description += "\n\n"
e.Description += "-----------------------------------\n"
e.Description += "イベント詳細ページ\n"
e.Description += fmt.Sprintf("%s/events/%v", host, e.ID)
_ = vevent.AddProperty("description", e.Description)
_ = vevent.AddProperty("location", e.Room.Place)
_ = vevent.AddProperty("organizer", e.CreatedBy.DisplayName)

return vevent
}

func ICalFormat(events []*domain.Event, host string) *ical.Calendar {
c := ical.New()
ical.NewEvent()
tz := ical.NewTimezone()
_ = tz.AddProperty("TZID", "Asia/Tokyo")
std := ical.NewStandard()
_ = std.AddProperty("TZOFFSETFROM", "+9000")
_ = std.AddProperty("TZOFFSETTO", "+9000")
_ = std.AddProperty("TZNAME", "JST")
_ = std.AddProperty("DTSTART", "19700101T000000")
_ = tz.AddEntry(std)
_ = c.AddEntry(tz)

for _, e := range events {
vevent := iCalVeventFormat(e, host)
_ = c.AddEntry(vevent)
}
return c
}

func GenerateEventWebhookContent(method string, e *EventDetailRes, nofiticationTargets []string, origin string, isMention bool) string {
jst, _ := time.LoadLocation("Asia/Tokyo")
timeFormat := "01/02(Mon) 15:04"
Expand Down Expand Up @@ -216,7 +174,7 @@ func ConvdomainEventToEventDetailRes(src domain.Event) (dst EventDetailRes) {
return
}

func NewICalVeventFormat(e *domain.Event, host string, attendeeMap map[uuid.UUID]*domain.User) *ics.VEvent {
func iCalVeventFormat(e *domain.Event, host string, attendeeMap map[uuid.UUID]*domain.User) *ics.VEvent {
vevent := ics.NewEvent(e.ID.String())
vevent.SetDtStampTime(time.Now())
vevent.SetStartAt(e.TimeStart)
Expand Down Expand Up @@ -246,7 +204,7 @@ func NewICalVeventFormat(e *domain.Event, host string, attendeeMap map[uuid.UUID
return vevent
}

func NewICalFormat(events []*domain.Event, host string, attendeeMap map[uuid.UUID]*domain.User) *ics.Calendar {
func ICalFormat(events []*domain.Event, host string, attendeeMap map[uuid.UUID]*domain.User) *ics.Calendar {
var tz ics.VTimezone
var std ics.Standard
cal := ics.NewCalendar()
Expand All @@ -258,7 +216,7 @@ func NewICalFormat(events []*domain.Event, host string, attendeeMap map[uuid.UUI
tz.Components = append(tz.Components, &std)
cal.Components = append(cal.Components, &tz)
for _, e := range events {
vevent := NewICalVeventFormat(e, host, attendeeMap)
vevent := iCalVeventFormat(e, host, attendeeMap)
cal.AddVEvent(vevent)
}
return cal
Expand Down
3 changes: 1 addition & 2 deletions router/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ func (h *Handlers) HandleGetiCalByPrivateID(c echo.Context) error {
if err != nil {
return judgeErrorResponse(err)
}

cal := presentation.NewICalFormat(events, h.Origin, attendeeMap)
cal := presentation.ICalFormat(events, h.Origin, attendeeMap)
var buf bytes.Buffer
cal.SerializeTo(&buf)

Check failure on line 254 in router/events.go

View workflow job for this annotation

GitHub Actions / Lint

Error return value of `cal.SerializeTo` is not checked (errcheck)
return c.Blob(http.StatusOK, "text/calendar", buf.Bytes())
Expand Down

0 comments on commit 7ac759e

Please sign in to comment.