Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Chiefs
ChiefSend2
Commits
8fb25a94
Commit
8fb25a94
authored
Mar 29, 2021
by
Lukas Böhm
🎱
Browse files
fix mails
parent
0676d954
Pipeline
#59962
passed with stages
in 3 minutes and 6 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
api/api.go
View file @
8fb25a94
...
...
@@ -212,7 +212,7 @@ func CloseShare(w http.ResponseWriter, r *http.Request) *HTTPError {
}
// TODO send mail
SendMail
(
share
)
// TODO background job
//{
// job, err := enqueuer.Enqueue("DeleteShare", nil)
...
...
api/database.go
View file @
8fb25a94
...
...
@@ -17,7 +17,7 @@ type Share struct {
ID
uuid
.
UUID
`json:"id" gorm:"primary_key"`
Name
string
`json:"name,omitempty"`
Expires
*
time
.
Time
`json:"expires,omitempty"`
DownloadLimit
int
`json:"download_limit,omitempty"`
DownloadLimit
int
`json:"download_limit,omitempty"`
IsPublic
bool
`json:"is_public" gorm:"not null; default:false; index"`
Password
string
`json:"-"`
Emails
[]
string
`json:"emails,omitempty" gorm:"-"`
...
...
api/mail.go
View file @
8fb25a94
...
...
@@ -3,20 +3,28 @@
package
main
import
(
"fmt"
"os"
"strings"
"github.com/sendgrid/sendgrid-go"
"github.com/sendgrid/sendgrid-go/helpers/mail"
)
func
SendMail
(
sh
Share
)
error
{
if
len
(
sh
.
Emails
)
<=
0
{
return
nil
}
m
:=
mail
.
NewV3Mail
()
m
.
SetFrom
(
mail
.
NewEmail
(
os
.
Getenv
(
"SENDGRID_SENDER_NAME"
),
os
.
Getenv
(
"SENDGRID_SENDER_MAIL"
)))
m
.
SetTemplateID
(
os
.
Getenv
(
"SENDGRID_SHARE_TEMPLATE"
))
p
:=
mail
.
NewPersonalization
()
receivers
:=
[]
*
mail
.
Email
{
mail
.
NewEmail
(
"Lukas Böhm"
,
"lukas.l.boehm@fau.de"
),
var
receivers
[]
*
mail
.
Email
for
_
,
address
:=
range
sh
.
Emails
{
receivers
=
append
(
receivers
,
mail
.
NewEmail
(
strings
.
Split
(
address
,
"@"
)[
0
],
address
))
}
fmt
.
Println
(
sh
.
Emails
)
p
.
AddTos
(
receivers
...
)
p
.
SetDynamicTemplateData
(
"id"
,
sh
.
ID
.
String
())
p
.
SetDynamicTemplateData
(
"download_id"
,
sh
.
DownloadLimit
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment