fix email sender all flow
This commit is contained in:
@@ -58,6 +58,21 @@ async function notifySuspended(userId: string, reason: string) {
|
||||
});
|
||||
}
|
||||
|
||||
/** E3.8 — kabari user kalau penangguhan akunnya sudah dicabut. */
|
||||
async function notifyUnsuspended(userId: string) {
|
||||
const target = await userRepo.findById(userId);
|
||||
if (!target) return;
|
||||
await emailService.send({
|
||||
to: target.email,
|
||||
// Sertakan timestamp supaya tiap siklus suspend→unsuspend dapat email baru.
|
||||
idempotencyKey: `account_unsuspended-${userId}-${Date.now()}`,
|
||||
template: {
|
||||
template: "account_unsuspended",
|
||||
data: { userName: target.name },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function unsuspendUserAction(userId: string) {
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user) {
|
||||
@@ -75,6 +90,10 @@ export async function unsuspendUserAction(userId: string) {
|
||||
entityType: "User",
|
||||
entityId: userId,
|
||||
});
|
||||
|
||||
// Notif email user — kabari akun sudah aktif kembali.
|
||||
void notifyUnsuspended(userId);
|
||||
|
||||
revalidatePath("/admin/users");
|
||||
revalidatePath(`/admin/users/${userId}`);
|
||||
return { success: true as const };
|
||||
|
||||
Reference in New Issue
Block a user