Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions cmd/web/frontend/src/pages/Dashboard/ConfigurationPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const kekTypeOptions = [

const emailTypeOptions = [
{ value: "smtp", label: "SMTP" },
{ value: "mailerSend", label: "Mailer Send" },
{ value: "mailersend", label: "Mailersend" },
];

const colourStyles: StylesConfig = {
Expand Down Expand Up @@ -126,9 +126,6 @@ const ConfigurationPage = () => {
Username: "",
Password: "",
},
MailerSend: {
ApiKey: "",
},
},
Stat: {
KekType: kekTypeOptions[0],
Expand Down Expand Up @@ -364,7 +361,7 @@ const ConfigurationPage = () => {
</Form.Group>
</Col>
</Row>
{values.Email.EmailType.value === "smtp" ? (
{values.Email.EmailType.value === "smtp" && (
<>
<Row>
<Col md={6}>
Expand Down Expand Up @@ -419,21 +416,6 @@ const ConfigurationPage = () => {
</Col>
</Row>
</>
) : (
<Row>
<Col md={12}>
<Form.Group className="mb-3">
<Form.Label>API Key</Form.Label>
<Form.Control
type="text"
placeholder="MAILERSEND_API_KEY"
name="Email.MailerSend.ApiKey"
value={values.Email.MailerSend.ApiKey}
onChange={handleChange}
/>
</Form.Group>
</Col>
</Row>
)}
<Row>
<Col md={12} lg={6}>
Expand Down
5 changes: 1 addition & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,14 @@ func LoadDefaultConf() error {
Token: "EST6315eb22-5c76-4d47-9b75-1acb4a954070ARY",
},
Email: types.EmailStat{
EmailType: "smtp",
EmailType: "mailersend",
From: "contact@encloud.tech",
SMTP: types.SectionSMTP{
Server: "sandbox.smtp.mailtrap.io",
Port: 2525,
Username: "ac984e52bfd35d",
Password: "861b495c076713",
},
MailerSend: types.SectionMailerSend{
ApiKey: "MAILERSEND_API_KEY",
},
},
Stat: types.SectionStat{
KekType: "ecies",
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Share(uuid string, kek string, privateKey string, email string) (types.File

subject := "Share content"
r := service.NewRequest([]string{email}, subject, cfg)
if sent := r.Send(fileMetaData.Cid[0], fileMetaData.DekType, fileMetaData.Timestamp, cfg.Email.EmailType, cfg.Email.MailerSend.ApiKey); sent {
if sent := r.Send(fileMetaData.Cid[0], fileMetaData.DekType, fileMetaData.Timestamp, cfg.Email.EmailType); sent {
os.Remove(config.Assets + "/" + fmt.Sprint(fileMetaData.Timestamp) + "_dek.txt")
return fileMetaData, nil
} else {
Expand Down
8 changes: 4 additions & 4 deletions pkg/service/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ func (r *Request) sendSMTPMail(cid string, dekType string, timestamp int64) bool
return true
}

func (r *Request) sendMailerSendMail(cid string, dekType string, timestamp int64, apiKey string) bool {
func (r *Request) sendMailerSendMail(cid string, dekType string, timestamp int64) bool {
log.Println("config", r.config)
// Create an instance of the mailersend client
ms := mailersend.NewMailersend(apiKey)
ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
Expand Down Expand Up @@ -140,10 +140,10 @@ func (r *Request) sendMailerSendMail(cid string, dekType string, timestamp int64
return true
}

func (r *Request) Send(cid string, dekType string, timestamp int64, emailType string, apiKey string) bool {
func (r *Request) Send(cid string, dekType string, timestamp int64, emailType string) bool {
if emailType == "smtp" {
return r.sendSMTPMail(cid, dekType, timestamp)
} else {
return r.sendMailerSendMail(cid, dekType, timestamp, apiKey)
return r.sendMailerSendMail(cid, dekType, timestamp)
}
}
11 changes: 3 additions & 8 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ type SectionEstuary struct {

// EmailStat is sub section of config.
type EmailStat struct {
EmailType string `yaml:"emailType"`
From string `yaml:"from"`
SMTP SectionSMTP `yaml:"smtp"`
MailerSend SectionMailerSend `yaml:"mailerSend"`
EmailType string `yaml:"emailType"`
From string `yaml:"from"`
SMTP SectionSMTP `yaml:"smtp"`
}

type SectionSMTP struct {
Expand All @@ -31,10 +30,6 @@ type SectionSMTP struct {
Password string `yaml:"password"`
}

type SectionMailerSend struct {
ApiKey string `yaml:"apiKey"`
}

// SectionStat is sub section of config.
type SectionStat struct {
BadgerDB SectionBadgerDB `yaml:"badgerdb"`
Expand Down