| 1 | import { and, desc, eq, like, notLike } from "drizzle-orm"; |
| 2 | import { z } |
| 3 | import { ORPCError } |
| 4 | import { db } |
| 5 | import { activityLogs, servers |
| 6 | import { adminProcedure, protectedProcedure |
| 7 | |
| 8 | export const activityRouter = |
| 9 | list: protectedProcedure |
| 10 | .input( |
| 11 | z.object({ |
| 12 | serverId: z.string |
| 13 | page: z.number |
| 14 | perPage: z.number |
| 15 | }), |
| 16 | ) |
| 17 | .handler(async ( |
| 18 | const server = |
| 19 | where: eq(servers |
| 20 | }); |
| 21 | if (!server) |
| 22 | |
| 23 | const userId = |
| 24 | const isAdmin = |
| 25 | if (!isAdmin && |
| 26 | const sub = |
| 27 | where: and(eq |
| 28 | }); |
| 29 | if (!sub) |
| 30 | } |
| 31 | |
| 32 | const offset = |
| 33 | const rows = |
| 34 | where: and(eq |
| 35 | orderBy: [desc(activityLogs |
| 36 | limit: input.perPage |
| 37 | offset, |
| 38 | with: { |
| 39 | user: { |
| 40 | columns: { name: true |
| 41 | }, |
| 42 | }, |
| 43 | }); |
| 44 | |
| 45 | return { data: |
| 46 | }), |
| 47 | |
| 48 | adminList: adminProcedure |
| 49 | .input( |
| 50 | z.object({ |
| 51 | page: z.number |
| 52 | perPage: z.number |
| 53 | }), |
| 54 | ) |
| 55 | .handler(async ( |
| 56 | const offset = |
| 57 | const rows = |
| 58 | where: like(activityLogs |
| 59 | orderBy: [desc(activityLogs |
| 60 | limit: input.perPage |
| 61 | offset, |
| 62 | with: { |
| 63 | user: { columns: { |
| 64 | server: { columns: { |
| 65 | node: { columns: { |
| 66 | }, |
| 67 | }); |
| 68 | return { data: |
| 69 | }), |
| 70 | }; |