Fix notification forum
Fix: modified: src/app/api/mobile/admin/forum/[id]/route.ts modified: src/app/api/mobile/forum/[id]/comment/route.ts modified: src/app/api/mobile/forum/[id]/report-posting/route.ts modified: src/app/api/mobile/forum/route.ts modified: src/lib/mobile/route-page-mobile.ts Add: src/app/api/mobile/forum/[id]/preview-report-posting/ ### No Issue
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
|
||||
export { GET, PUT };
|
||||
|
||||
@@ -78,6 +84,11 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
|
||||
async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const data = await request.json();
|
||||
const { senderId } = data;
|
||||
|
||||
console.log("SENDER", senderId);
|
||||
|
||||
try {
|
||||
const data = await prisma.forum_Posting.update({
|
||||
where: {
|
||||
@@ -86,6 +97,10 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
data: {
|
||||
isActive: false,
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
diskusi: true,
|
||||
},
|
||||
});
|
||||
|
||||
const deactivateComment = await prisma.forum_Komentar.updateMany({
|
||||
@@ -97,6 +112,19 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: data?.authorId as string,
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Penghapusan Postingan" as NotificationMobileTitleType,
|
||||
body: `Postingan anda telah dilaporkan: ${data?.diskusi}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "FORUM",
|
||||
deepLink: routeUserMobile.forumPreviewReportPosting({ id: id }),
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[DEACTIVATE COMMENT]", deactivateComment);
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user