Build post chat and attachment workflows
All checks were successful
CI / backend (push) Successful in 13m8s
CI / frontend (push) Successful in 10m46s
CI / docker (push) Successful in 2m59s

This commit is contained in:
Cauê Faleiros
2026-06-08 16:44:33 -03:00
parent 8c7e5fbbe4
commit 0b920da187
30 changed files with 3021 additions and 204 deletions

View File

@@ -25,6 +25,8 @@ type Invitation struct {
CreatedBy *string `json:"created_by"`
CreatedAt time.Time `json:"created_at"`
InvitationURL string `json:"invitation_url,omitempty"`
EmailSent bool `json:"email_sent"`
EmailError string `json:"email_error,omitempty"`
}
type CreateInvitationInput struct {

View File

@@ -5,18 +5,22 @@ import (
"strings"
"time"
"mira/backend/internal/mail"
"github.com/gin-gonic/gin"
)
type Routes struct {
store Store
appPublicURL string
mailSender mail.Sender
}
func NewRoutes(store Store, appPublicURL string) Routes {
func NewRoutes(store Store, appPublicURL string, mailSender mail.Sender) Routes {
return Routes{
store: store,
appPublicURL: strings.TrimRight(appPublicURL, "/"),
mailSender: mailSender,
}
}
@@ -106,6 +110,14 @@ func (r Routes) createInvitation(c *gin.Context) {
}
invitation.InvitationURL = r.invitationURL(token)
invitation.EmailSent = false
if r.mailSender.IsConfigured() {
if err := r.mailSender.SendInvitation(invitation.Email, invitation.InvitationURL); err != nil {
invitation.EmailError = "Convite criado, mas nao foi possivel enviar o e-mail."
} else {
invitation.EmailSent = true
}
}
c.JSON(http.StatusCreated, gin.H{"invitation": invitation})
}