Updated list of commands to v4.3. Added groups & permissions. Added connections. Updated redemptions and actions to v4.3.
This commit is contained in:
40
app/api/settings/groups/users/route.ts
Normal file
40
app/api/settings/groups/users/route.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { db } from "@/lib/db"
|
||||
import { NextResponse } from "next/server";
|
||||
import fetchUserWithImpersonation from "@/lib/fetch-user-impersonation";
|
||||
import axios from "axios";
|
||||
import { env } from "process";
|
||||
import { TwitchUpdateAuthorization } from "@/lib/twitch";
|
||||
|
||||
export async function GET(req: Request) {
|
||||
try {
|
||||
const user = await fetchUserWithImpersonation(req)
|
||||
if (!user)
|
||||
return new NextResponse("Unauthorized", { status: 401 });
|
||||
|
||||
const { searchParams } = new URL(req.url)
|
||||
const groupId = searchParams.get('groupId') as string
|
||||
|
||||
let chatters: { userId: string, groupId: string, chatterId: bigint, chatterLabel: string }[]
|
||||
|
||||
if (!!groupId)
|
||||
chatters = await db.chatterGroup.findMany({
|
||||
where: {
|
||||
userId: user.id,
|
||||
groupId
|
||||
}
|
||||
})
|
||||
else
|
||||
chatters = await db.chatterGroup.findMany({
|
||||
where: {
|
||||
userId: user.id
|
||||
}
|
||||
})
|
||||
|
||||
return NextResponse.json(chatters.map(u => ({ ...u, chatterId: Number(u.chatterId) }))
|
||||
.map(({userId, chatterLabel, ...attrs}) => attrs))
|
||||
|
||||
} catch (error) {
|
||||
console.log("[GROUPS/USERS]", error);
|
||||
return new NextResponse("Internal Error", { status: 500 });
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user