Skip to content

Commit

Permalink
Update Calendar credentials path to take into account embedded assets
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorunic committed Jan 18, 2024
1 parent 3ebf8e0 commit 674986b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions messenger/calendar.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ import (
)

const (
CalendarAPILimit = 5 // 5 req/s per user
CalendarMinDelay = 1 * time.Second / CalendarAPILimit
CalendarMaxResults = 100
DefaultCalendarCredentials = "calendar_credentials.json" // default Google Calendar credentials file
CalendarAPILimit = 5 // 5 req/s per user
CalendarMinDelay = 1 * time.Second / CalendarAPILimit
CalendarMaxResults = 100
CalendarCredentials = "assets/calendar_credentials.json" // embedded Google Calendar credentials file

)

Expand Down Expand Up @@ -147,9 +147,9 @@ func Calendar(ctx context.Context, ch <-chan interface{}, name, tokFile string,
// - string: The calendar ID.
// - error: Any error that occurred during initialization.
func InitCalendar(ctx context.Context, tokFile string, name string) (*calendar.Service, string, error) {
b, err := credentialFS.ReadFile(DefaultCalendarCredentials)
b, err := credentialFS.ReadFile(CalendarCredentials)
if err != nil {
logger.Error().Msgf("Unable to read credentials file %s: %v", DefaultCalendarCredentials, err)
logger.Error().Msgf("Unable to read credentials file %s: %v", CalendarCredentials, err)

return nil, "", ErrCalendarReadingCreds
}
Expand All @@ -158,7 +158,7 @@ func InitCalendar(ctx context.Context, tokFile string, name string) (*calendar.S

config, err = google.ConfigFromJSON(b, calendar.CalendarReadonlyScope, calendar.CalendarEventsScope)
if err != nil {
logger.Error().Msgf("Unable to parse credentials file %s: %v", DefaultCalendarCredentials, err)
logger.Error().Msgf("Unable to parse credentials file %s: %v", CalendarCredentials, err)

return nil, "", ErrCalendarParsingCreds
}
Expand Down

0 comments on commit 674986b

Please sign in to comment.