Skip to content

Commit

Permalink
Merge pull request #18 from KampungBudaya/dev
Browse files Browse the repository at this point in the history
RAWR [Hotfix] Group Link on Participant Acceptance
  • Loading branch information
mirzahilmi authored Sep 20, 2023
2 parents bd49b74 + f6831e3 commit cdd672f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ SHEETS_ID=
SHEETS_CREDENTIAL_PATH=

SECRET_KEY=

GROUP_LINK_TARI=
GROUP_LINK_MUSIK=
GROUP_LINK_BUSANA_KREASI=
GROUP_LINK_STAND_BAZAR=
14 changes: 13 additions & 1 deletion api/contest/usecase/contest.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,19 @@ func (uc *ContestUsecase) AcceptParticipant(ctx context.Context, id int) error {
mail.SetSender(os.Getenv("CONFIG_SENDER_NAME"))
mail.SetReciever(participant.Email)
mail.SetSubject("Announcement Email")
mail.SetBodyHTML(participant.Name, participant.Contest)

var groupLink string
if participant.Contest == "Tari" {
groupLink = os.Getenv("GROUP_LINK_TARI")
} else if participant.Contest == "Musik" {
groupLink = os.Getenv("GROUP_LINK_MUSIK")
} else if participant.Contest == "Busana Kreasi" {
groupLink = os.Getenv("GROUP_LINK_BUSANA_KREASI")
} else {
groupLink = os.Getenv("GROUP_LINK_STAND_BAZAR")
}

mail.SetBodyHTML(participant.Name, participant.Contest, groupLink)
if err := mail.SendMail(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion domain/participant.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (p *StoreParticipant) Validate() error {
case p.Category == "":
return errors.New("FIELD CATEGORY TIDAK BOLEH KOSONG")
case p.ContestID == 1 || p.ContestID == 2 || p.ContestID == 3:
if (p.VideoURL == "") || (p.Category == "UMUM" && p.VideoURL == "") {
if p.Category == "UMUM" && p.VideoURL == "" {
return errors.New("FIELD LINK VIDEO TIDAK BOLEH KOSONG")
}
case p.ContestID == 4:
Expand Down
6 changes: 2 additions & 4 deletions email.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,15 @@ <h3>Kampung Budaya 2023</h3>
Terimakasih telah mendaftar untuk Lomba di Kampung Budaya! Kami sangat
antusias untuk melihat Anda bersinar dalam acara ini.
</p>

<div class="details">
<h2>Detail Registrasi:</h2>
<ul>
<li><strong>Nama Peserta :</strong> {{.Name}}</li>
<li><strong>Jenis Lomba :</strong> {{.Contest}}</li>
</ul>
</div>
<a class="button" href="https://kampungbudayaub.org/lomba"
>Lihat Detail Acara</a
>
<a href="{{.GroupLink}}">Gabung Grup</a>
<p>Untuk informasi lebih lanjut cek di <a href="https://kampungbudayaub.org">Kampung Budaya UB 2023</a></p>
<p>
Jangan ragu untuk menghubungi kami jika Anda memiliki pertanyaan. Kami
berharap Anda akan memiliki pengalaman yang luar biasa!
Expand Down
12 changes: 7 additions & 5 deletions util/email/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (g *Gomail) SetSubject(subject string) {
g.message.SetHeader("Subject", subject)
}

func (g *Gomail) SetBodyHTML(name, contest string) error {
func (g *Gomail) SetBodyHTML(name, contest, groupLink string) error {
var body bytes.Buffer
path := "email.html"
t, err := template.ParseFiles(path)
Expand All @@ -52,11 +52,13 @@ func (g *Gomail) SetBodyHTML(name, contest string) error {
}

t.Execute(&body, struct {
Name string
Contest string
Name string
Contest string
GroupLink string
}{
Name: name,
Contest: contest,
Name: name,
Contest: contest,
GroupLink: groupLink,
})
g.message.SetBody("text/html", body.String())
return nil
Expand Down

0 comments on commit cdd672f

Please sign in to comment.