Build post chat and attachment workflows
This commit is contained in:
@@ -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})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user