Compare commits

..

5 Commits

Author SHA1 Message Date
7cdde6b5a9 chore(release): 1.5.35 2026-01-12 17:35:50 +08:00
e77e5eb3ac Fix notification reuse component
Fix:
- modified:   src/app/api/auth/mobile-register/route.ts
- modified:   src/lib/mobile/notification/send-notification.ts

### No Issue
2026-01-12 17:35:27 +08:00
8f3f27122a chore(release): 1.5.34 2026-01-09 17:45:54 +08:00
d84a1d84ff Fix route untuk penambahan fitur EULA
Fix:
- modified:   src/app/api/auth/mobile-login/route.ts

Add:
- src/app/api/auth/mobile-eula/

### No Issue
2026-01-09 17:45:44 +08:00
40ba31edec Fix mobile notification:
- Bug penerima pesan 2 kali

Fix:
modified:   src/lib/mobile/notification/send-notification.ts

### No Issue
2026-01-09 14:42:45 +08:00
6 changed files with 85 additions and 68 deletions

View File

@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
## [1.5.35](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.34...v1.5.35) (2026-01-12)
## [1.5.34](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.33...v1.5.34) (2026-01-09)
## [1.5.33](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.32...v1.5.33) (2026-01-06)
## [1.5.32](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.31...v1.5.32) (2026-01-05)

View File

@@ -1,6 +1,6 @@
{
"name": "hipmi",
"version": "1.5.33",
"version": "1.5.35",
"private": true,
"prisma": {
"seed": "bun prisma/seed.ts"

View File

@@ -0,0 +1,54 @@
import { prisma } from "@/lib";
import { NextResponse } from "next/server";
export async function POST(req: Request) {
try {
const { nomor } = await req.json();
const user = await prisma.user.findUnique({
where: {
nomor: nomor,
},
});
if (!user)
return NextResponse.json({
success: false,
message: "User belum terdaftar",
status: 404,
});
const updateTerms = await prisma.user.update({
where: { nomor: nomor },
data: {
termsOfServiceAccepted: true,
acceptedTermsAt: new Date(),
},
});
if (!updateTerms) {
return NextResponse.json({
success: false,
message: "Gagal setujui syarat dan ketentuan",
status: 400,
});
}
return NextResponse.json(
{
success: true,
message: "Anda telah setujui syarat dan ketentuan",
},
{ status: 200 }
);
} catch (error) {
return NextResponse.json(
{
success: false,
message: "Terjadi masalah saat setujui syarat dan ketentuan",
reason: error as Error,
},
{ status: 500 }
);
}
}

View File

@@ -6,7 +6,6 @@ export async function POST(req: Request) {
try {
const codeOtp = randomOTP();
const body = await req.json();
console.log("[Masuk API]", body);
const { nomor } = body;
const user = await prisma.user.findUnique({
@@ -15,9 +14,6 @@ export async function POST(req: Request) {
},
});
console.log(["cek user", user]);
console.log(["cek nomor", nomor]);
if (!user)
return NextResponse.json({
success: false,
@@ -66,6 +62,7 @@ export async function POST(req: Request) {
success: true,
message: "Kode verifikasi terkirim",
kodeId: createOtpId.id,
isAcceptTerms: user.termsOfServiceAccepted,
},
{ status: 200 }
);

View File

@@ -1,8 +1,12 @@
import { sessionCreate } from "@/app/(auth)/_lib/session_create";
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
import { adminMessaging } from "@/lib/firebase-admin";
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
import prisma from "@/lib/prisma";
import { NextResponse } from "next/server";
import {
NotificationMobileBodyType,
NotificationMobileTitleType,
} from "../../../../../types/type-mobile-notification";
export async function POST(req: Request) {
if (req.method !== "POST") {
@@ -84,12 +88,12 @@ export async function POST(req: Request) {
// =========== START SEND NOTIFICATION =========== //
const findAllUserBySendTo = await prisma.user.findMany({
where: { masterUserRoleId: "2" },
const adminUsers = await prisma.user.findMany({
where: { masterUserRoleId: "2", NOT: { id: data.authorId } },
select: { id: true },
});
console.log("Users to notify:", findAllUserBySendTo);
console.log("Users to notify:", adminUsers);
const dataNotification = {
title: "Pendaftaran Baru",
@@ -101,63 +105,17 @@ export async function POST(req: Request) {
senderId: createUser.id,
};
for (let a of findAllUserBySendTo) {
const createdNotification = await prisma.notifikasi.create({
data: {
...dataNotification,
recipientId: a.id,
},
});
if (createdNotification) {
const deviceToken = await prisma.tokenUserDevice.findMany({
where: {
userId: a.id,
isActive: true,
},
});
for (let i of deviceToken) {
const message = {
token: i.token,
notification: {
title: dataNotification.title,
body: dataNotification.pesan,
},
data: {
sentAt: new Date().toISOString(), // ✅ Simpan metadata di data
id: createdNotification.id,
deepLink: dataNotification.deepLink,
},
// Konfigurasi Android untuk prioritas tinggi
android: {
priority: "high" as const, // Kirim secepatnya, bahkan di doze mode untuk notifikasi penting
notification: {
channelId: "default", // Sesuaikan dengan channel yang kamu buat di Android
},
ttl: 0 as const, // Kirim secepatnya, jangan tunda
},
// Opsional: tambahkan untuk iOS juga
apns: {
payload: {
aps: {
sound: "default" as const,
// 'content-available': 1 as const, // jika butuh silent push
},
},
},
};
try {
const response = await adminMessaging.send(message);
console.log("✅ FCM sent successfully", "Response:", response);
} catch (error: any) {
console.error("❌ FCM send failed:", error);
// Lanjutkan ke token berikutnya meski satu gagal
}
}
}
}
await sendNotificationMobileToManyUser({
recipientIds: adminUsers.map((user) => user.id),
senderId: data.authorId,
payload: {
title: "Pendaftaran User Baru" as NotificationMobileTitleType,
body: "User baru telah melakukan registrasi. Ayo cek dan verifikasi!" as NotificationMobileBodyType,
type: "announcement",
deepLink: routeAdminMobile.userAccess({ id: createUser.id }),
kategoriApp: "OTHER",
},
});
// =========== END SEND NOTIFICATION =========== //

View File

@@ -22,7 +22,10 @@ export async function sendNotificationMobileToOneUser({
}) {
try {
const kategoriToNormalCase = _.lowerCase(payload.kategoriApp);
const titleFix = `${_.startCase(kategoriToNormalCase)}: ${payload.title}`;
const titleFix =
kategoriToNormalCase === "other"
? payload.title
: `${_.startCase(kategoriToNormalCase)}: ${payload.title}`;
console.log("titleFix", titleFix);
// 1. Simpan notifikasi ke DB
@@ -64,6 +67,7 @@ export async function sendNotificationMobileToOneUser({
sentAt: new Date().toISOString(), // ✅ Simpan metadata di data
id: notification.id,
deepLink: payload.deepLink,
recipientId: recipientId,
},
android: {
priority: "high" as const,