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
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class EmailService(
val registrationStartsAt: Instant?,
val registrationEndsAt: Instant?,
val description: String?,
val publicId: String?,
)

data class EventCancellationEmailData(
Expand All @@ -120,6 +121,7 @@ class EmailService(
val endsAt: Instant?,
val location: String?,
val newCapacity: Int,
val totalCount: Int,
val registrationStartsAt: Instant?,
val registrationEndsAt: Instant,
val description: String?,
Expand All @@ -138,8 +140,7 @@ class EmailService(
.replace("{eventTitle}", formatEventTitle(data.eventTitle))
.replace("{eventDateRange}", formatEventDateRange(data.startsAt, data.endsAt, "-"))
.replace("{location}", formatLocation(data.location))
.replace("{totalCount}", data.totalCount?.toString() ?: "null")
.replace("{capacity}", data.capacity?.toString() ?: "null")
.replace("{capacityDisplay}", formatCapacity(data.totalCount, data.capacity))
.replace(
"{registrationDateRange}",
formatRegistrationDateRange(data.registrationStartsAt, data.registrationEndsAt),
Expand All @@ -165,8 +166,7 @@ class EmailService(
.replace("{eventTitle}", formatEventTitle(data.eventTitle))
.replace("{eventDateRange}", formatEventDateRange(data.startsAt, data.endsAt, "-"))
.replace("{location}", formatLocation(data.location))
.replace("{totalCount}", data.totalCount?.toString() ?: "null")
.replace("{capacity}", data.capacity?.toString() ?: "null")
.replace("{capacityDisplay}", formatCapacity(data.totalCount, data.capacity))
.replace(
"{registrationDateRange}",
formatRegistrationDateRange(data.registrationStartsAt, data.registrationEndsAt),
Expand All @@ -189,8 +189,7 @@ class EmailService(
.replace("{eventTitle}", formatEventTitle(data.eventTitle))
.replace("{eventDateRange}", formatEventDateRange(data.startsAt, data.endsAt, "-"))
.replace("{location}", formatLocation(data.location))
.replace("{totalCount}", data.totalCount?.toString() ?: "null")
.replace("{capacity}", data.capacity?.toString() ?: "null")
.replace("{capacityDisplay}", formatCapacity(data.totalCount, data.capacity))
.replace(
"{registrationDateRange}",
formatRegistrationDateRange(data.registrationStartsAt, data.registrationEndsAt),
Expand All @@ -213,16 +212,17 @@ class EmailService(
fun sendRegistrationDeleteEmail(data: RegistrationDeleteEmailData) {
val htmlContent =
loadTemplate("registration-delete.html")
.replace("{serviceDomain}", emailConfig.serviceDomain)
.replace("{name}", data.name)
.replace("{eventTitle}", formatEventTitle(data.eventTitle))
.replace("{eventDateRange}", formatEventDateRange(data.startsAt, data.endsAt, "-"))
.replace("{location}", formatLocation(data.location))
.replace("{totalCount}", data.totalCount?.toString() ?: "null")
.replace("{capacity}", data.capacity?.toString() ?: "null")
.replace("{capacityDisplay}", formatCapacity(data.totalCount, data.capacity))
.replace(
"{registrationDateRange}",
formatRegistrationDateRange(data.registrationStartsAt, data.registrationEndsAt),
).replace("{description}", formatDescription(data.description))
.replace("{publicId}", data.publicId ?: "-")

sendHtmlEmail(
to = data.toEmail,
Expand Down Expand Up @@ -258,7 +258,7 @@ class EmailService(
.replace("{serviceDomain}", emailConfig.serviceDomain)
.replace("{name}", data.name)
.replace("{waitingNum}", data.waitingNum?.toString() ?: "-")
.replace("{newCapacity}", data.newCapacity.toString())
.replace("{capacityDisplay}", formatCapacity(data.totalCount, data.newCapacity))
.replace("{eventTitle}", formatEventTitle(data.eventTitle))
.replace("{eventDateRange}", formatEventDateRange(data.startsAt, data.endsAt, "-"))
.replace("{location}", formatLocation(data.location))
Expand Down Expand Up @@ -302,8 +302,7 @@ class EmailService(
.replace("{eventTitle}", formatEventTitle(eventTitle))
.replace("{eventDateRange}", formatEventDateRange(startsAt, endsAt, "~"))
.replace("{location}", formatLocation(location))
.replace("{totalCount}", totalCount?.toString() ?: "null")
.replace("{capacity}", capacity?.toString() ?: "null")
.replace("{capacityDisplay}", formatCapacity(totalCount, capacity))
.replace(
"{registrationDateRange}",
formatRegistrationDateRange(registrationStartsAt, registrationEndsAt),
Expand Down Expand Up @@ -368,6 +367,20 @@ class EmailService(
}
}

private fun formatCapacity(
totalCount: Int?,
capacity: Int?,
): String {
if (capacity == null) return "${totalCount ?: "-"}명"
val confirmed = if (totalCount != null) minOf(totalCount, capacity) else capacity
val waitlisted = if (totalCount != null) maxOf(0, totalCount - capacity) else 0
return if (waitlisted > 0) {
"$confirmed/${capacity}명 (대기자 ${waitlisted}명)"
} else {
"$confirmed/${capacity}명"
}
}

private fun formatDescription(description: String?): String {
if (description == null) return "-"
return description.replace("\r\n", "\n").replace("\n", "<br>")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ RegistrationService(
registrationStartsAt = event.registrationStartsAt,
registrationEndsAt = event.registrationEndsAt,
description = event.description,
publicId = event.publicId,
)

afterCommit {
Expand Down Expand Up @@ -673,6 +674,9 @@ RegistrationService(
toDemote.forEach { it.status = RegistrationStatus.WAITLISTED }
registrationRepository.saveAll(toDemote)

val waitlistedCount = registrationRepository.countByEventIdAndStatus(eventId, RegistrationStatus.WAITLISTED).toInt()
val totalCount = newCapacity + waitlistedCount

val demotedPublicIds = toDemote.map { it.registrationPublicId }
val waitlistPositions =
registrationRepository
Expand All @@ -698,6 +702,7 @@ RegistrationService(
endsAt = event.endsAt,
location = event.location,
newCapacity = newCapacity,
totalCount = totalCount,
registrationStartsAt = event.registrationStartsAt,
registrationEndsAt = event.registrationEndsAt,
description = event.description,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
alt="user" width="20" style="display: block; border: 0;">
</td>
<td style="padding-bottom: 4px; padding-left: 10px; vertical-align: middle;">
정원 <span style="margin-left:8px; color:#444;">{totalCount}/{capacity}명</span>
정원 <span style="margin-left:8px; color:#444;">{capacityDisplay}</span>
</td>
</tr>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
</tr>
</table>

<a href="{serviceDomain}/event/{publicId}?regId={registrationPublicId}" style="display: block; text-decoration: none; color: inherit;">
<div style="border: 1px solid #EAEAEA; border-radius: 12px; padding: 24px; margin-bottom: 16px;">
<div style="font-size: 22px; font-weight: bold; color: #000; margin-bottom: 20px;">{eventTitle}</div>

Expand Down Expand Up @@ -66,14 +67,15 @@
alt="user" width="18" style="display: block; border: 0;">
</td>
<td style="padding-bottom: 4px; padding-left: 10px; vertical-align: middle;">
정원 <span style="margin-left:8px; color:#444;">{totalCount}/{capacity}명</span>
정원 <span style="margin-left:8px; color:#444;">{capacityDisplay}</span>
</td>
</tr>
</table>
<div
style="text-align: right; color: #CCCCCC; font-size: 24px; line-height: 1; font-family: sans-serif; font-weight: 300; margin-top: -10px;">
&rsaquo;</div>
</div>
</a>

<table border="0" cellpadding="0" cellspacing="0"
style="width: 100%; background-color: #F7F8F9; border-radius: 8px; margin-bottom: 40px;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
</tr>
</table>

<a href="{serviceDomain}/event/{publicId}" style="display: block; text-decoration: none; color: inherit;">
<div style="border: 1px solid #EAEAEA; border-radius: 12px; padding: 24px; margin-bottom: 16px;">
<div style="font-size: 20px; font-weight: bold; color: #000; margin-bottom: 20px;">{eventTitle}
</div>
Expand Down Expand Up @@ -74,14 +75,15 @@
alt="user" width="20" style="display: block; border: 0;">
</td>
<td style="padding-bottom: 4px; padding-left: 10px; vertical-align: middle;">
정원 <span style="margin-left:8px; color:#444;">{totalCount}/{capacity}명</span>
정원 <span style="margin-left:8px; color:#444;">{capacityDisplay}</span>
</td>
</tr>
</table>
<div
style="text-align: right; color: #CCCCCC; font-size: 24px; line-height: 1; font-family: sans-serif; font-weight: 300; margin-top: -10px;">
&rsaquo;</div>
</div>
</a>

<table border="0" cellpadding="0" cellspacing="0" width="100%"
style="background-color: #F7F8F9; border-radius: 8px; margin-bottom: 30px;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
</tr>
</table>

<a href="{serviceDomain}/event/{publicId}?regId={registrationPublicId}" style="display: block; text-decoration: none; color: inherit;">
<div style="border: 1px solid #EAEAEA; border-radius: 12px; padding: 24px; margin-bottom: 16px;">
<div style="font-size: 20px; font-weight: bold; color: #000; margin-bottom: 20px;">{eventTitle}
</div>
Expand Down Expand Up @@ -74,14 +75,15 @@
alt="user" width="18" style="display: block; border: 0;">
</td>
<td style="padding-bottom: 4px; padding-left: 10px; vertical-align: middle;">
정원 <span style="margin-left:8px; color:#444;">{newCapacity}명</span>
정원 <span style="margin-left:8px; color:#444;">{capacityDisplay}</span>
</td>
</tr>
</table>
<div
style="text-align: right; color: #CCCCCC; font-size: 24px; line-height: 1; font-family: sans-serif; font-weight: 300; margin-top: -10px;">
&rsaquo;</div>
</div>
</a>

<table border="0" cellpadding="0" cellspacing="0" width="100%"
style="background-color: #F7F8F9; border-radius: 8px; margin-bottom: 30px;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
</tr>
</table>

<a href="{serviceDomain}/event/{publicId}?regId={registrationPublicId}" style="display: block; text-decoration: none; color: inherit;">
<div style="border: 1px solid #EAEAEA; border-radius: 12px; padding: 24px; margin-bottom: 16px;">
<div style="font-size: 22px; font-weight: bold; color: #000; margin-bottom: 20px;">{eventTitle}</div>

Expand Down Expand Up @@ -66,14 +67,15 @@
alt="user" width="18" style="display: block; border: 0;">
</td>
<td style="padding-bottom: 4px; padding-left: 10px; vertical-align: middle;">
정원 <span style="margin-left:8px; color:#444;">{totalCount}/{capacity}명</span>
정원 <span style="margin-left:8px; color:#444;">{capacityDisplay}</span>
</td>
</tr>
</table>
<div
style="text-align: right; color: #CCCCCC; font-size: 24px; line-height: 1; font-family: sans-serif; font-weight: 300; margin-top: -10px;">
&rsaquo;</div>
</div>
</a>

<table border="0" cellpadding="0" cellspacing="0"
style="width: 100%; background-color: #F7F8F9; border-radius: 8px; margin-bottom: 40px;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
</tr>
</table>

<a href="{serviceDomain}/event/{publicId}?regId={registrationPublicId}" style="display: block; text-decoration: none; color: inherit;">
<div style="border: 1px solid #EAEAEA; border-radius: 12px; padding: 24px; margin-bottom: 16px;">
<div style="font-size: 20px; font-weight: bold; color: #000; margin-bottom: 20px;">{eventTitle}
</div>
Expand Down Expand Up @@ -74,14 +75,15 @@
alt="user" width="18" style="display: block; border: 0;">
</td>
<td style="padding-bottom: 4px; padding-left: 10px; vertical-align: middle;">
정원 <span style="margin-left:8px; color:#444;">{totalCount}/{capacity}명</span>
정원 <span style="margin-left:8px; color:#444;">{capacityDisplay}</span>
</td>
</tr>
</table>
<div
style="text-align: right; color: #CCCCCC; font-size: 24px; line-height: 1; font-family: sans-serif; font-weight: 300; margin-top: -10px;">
&rsaquo;</div>
</div>
</a>

<table border="0" cellpadding="0" cellspacing="0" width="100%"
style="background-color: #F7F8F9; border-radius: 8px; margin-bottom: 30px;">
Expand Down
Loading