From 5b6617f76f7cab4721d9d304c2a701b5f75f3630 Mon Sep 17 00:00:00 2001 From: Marcos Fonseca Date: Wed, 24 Jul 2024 17:24:09 -0300 Subject: [PATCH] =?UTF-8?q?Removendo=20coment=C3=A1rios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/config/config.go | 2 +- backend/internal/services/calendar_service.go | 2 +- backend/internal/services/email_service.go | 2 +- backend/internal/services/gmail_service.go | 4 ++-- backend/internal/services/google_calendar_service.go | 10 +++++----- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/config/config.go b/backend/config/config.go index b509cef..1b2d6bb 100644 --- a/backend/config/config.go +++ b/backend/config/config.go @@ -27,7 +27,7 @@ func GetEventGoogleMeet() string { return meetEvent } -func SetupOAuthConfig() *oauth2.Config { // Função que lê as variáveis de ambiente e retorna um ponteiro para uma configuração OAuth2 +func SetupOAuthConfig() *oauth2.Config { err := godotenv.Load() diff --git a/backend/internal/services/calendar_service.go b/backend/internal/services/calendar_service.go index 7a5a80a..90ed3dd 100644 --- a/backend/internal/services/calendar_service.go +++ b/backend/internal/services/calendar_service.go @@ -7,7 +7,7 @@ import ( "google.golang.org/api/calendar/v3" ) -type CalendarService interface { // Interface que define os métodos que devem ser implementados por um serviço de calendário +type CalendarService interface { InitializeService(ctx context.Context, config *oauth2.Config, token *oauth2.Token) (CalendarAPI, error) AddGuestToEvent(ctx context.Context, service CalendarAPI, hangoutLink, email string) (*calendar.Event, error) FindEventByHangoutLink(ctx context.Context, service CalendarAPI, hangoutLink string) (*calendar.Event, error) diff --git a/backend/internal/services/email_service.go b/backend/internal/services/email_service.go index f95f7d6..6e5def1 100644 --- a/backend/internal/services/email_service.go +++ b/backend/internal/services/email_service.go @@ -5,6 +5,6 @@ import ( "google.golang.org/api/calendar/v3" ) -type EmailService interface { // Interface que define os métodos que devem ser implementados por um serviço de e-mail +type EmailService interface { SendMentorshipInvitation(recipient string, eventDetails *calendar.Event, token *oauth2.Token) error } diff --git a/backend/internal/services/gmail_service.go b/backend/internal/services/gmail_service.go index ddde3fa..523915f 100644 --- a/backend/internal/services/gmail_service.go +++ b/backend/internal/services/gmail_service.go @@ -19,14 +19,14 @@ type GmailService struct { token *oauth2.Token } -func NewGmailService(config *oauth2.Config, token *oauth2.Token) EmailService { // Construtor responsável por encapsular a criação de uma instância de GmailService e retornar um ponteiro para ela +func NewGmailService(config *oauth2.Config, token *oauth2.Token) EmailService { return &GmailService{ config: config, token: token, } } -func (gs *GmailService) SendMentorshipInvitation(recipient string, eventDetails *calendar.Event, token *oauth2.Token) error { // Método que envia um convite de mentoria por e-mail +func (gs *GmailService) SendMentorshipInvitation(recipient string, eventDetails *calendar.Event, token *oauth2.Token) error { ctx := context.Background() client := gs.config.Client(ctx, token) diff --git a/backend/internal/services/google_calendar_service.go b/backend/internal/services/google_calendar_service.go index b1e5267..dfb3389 100644 --- a/backend/internal/services/google_calendar_service.go +++ b/backend/internal/services/google_calendar_service.go @@ -12,13 +12,13 @@ import ( "google.golang.org/api/option" ) -type GoogleCalendarService struct{} // Estrutura que implementa a interface CalendarService +type GoogleCalendarService struct{} -func NewGoogleCalendarService() CalendarService { // Construtor responsável por encapsular a criação de uma instância de GoogleCalendarService e retornar um ponteiro para ela +func NewGoogleCalendarService() CalendarService { return &GoogleCalendarService{} } -func (gcs *GoogleCalendarService) InitializeService(ctx context.Context, config *oauth2.Config, token *oauth2.Token) (CalendarAPI, error) { // Método que inicializa o serviço de calendário +func (gcs *GoogleCalendarService) InitializeService(ctx context.Context, config *oauth2.Config, token *oauth2.Token) (CalendarAPI, error) { client, err := auth.CreateOAuthClient(ctx, config, token) @@ -34,7 +34,7 @@ func (gcs *GoogleCalendarService) InitializeService(ctx context.Context, config return &RealCalendarService{GoogleCalendar: service}, nil } -func (gcs *GoogleCalendarService) FindEventByHangoutLink(ctx context.Context, api CalendarAPI, hangoutLink string) (*calendar.Event, error) { // Método que recebe um link do Google Meet e retorna o evento correspondente +func (gcs *GoogleCalendarService) FindEventByHangoutLink(ctx context.Context, api CalendarAPI, hangoutLink string) (*calendar.Event, error) { events, err := api.EventsList("primary").Do() @@ -51,7 +51,7 @@ func (gcs *GoogleCalendarService) FindEventByHangoutLink(ctx context.Context, ap return nil, fmt.Errorf("event with HangoutLink %s not found", hangoutLink) } -func (gcs *GoogleCalendarService) AddGuestToEvent(ctx context.Context, api CalendarAPI, hangoutLink, email string) (*calendar.Event, error) { // Método que adiciona um convidado a um evento +func (gcs *GoogleCalendarService) AddGuestToEvent(ctx context.Context, api CalendarAPI, hangoutLink, email string) (*calendar.Event, error) { eventDetails, err := gcs.FindEventByHangoutLink(ctx, api, hangoutLink)