1
+ import { createRouterCaller } from "app/_trpc/context" ;
1
2
import { _generateMetadata } from "app/_utils" ;
2
- import { unstable_cache } from "next/cache" ;
3
3
import { cookies , headers } from "next/headers" ;
4
4
import { redirect } from "next/navigation" ;
5
5
6
6
import { getServerSession } from "@calcom/features/auth/lib/getServerSession" ;
7
7
import WebhooksView from "@calcom/features/webhooks/pages/webhooks-view" ;
8
8
import { APP_NAME } from "@calcom/lib/constants" ;
9
- import { WebhookRepository } from "@calcom/lib/server/repository/webhook" ;
10
9
import { UserPermissionRole } from "@calcom/prisma/enums" ;
10
+ import { webhookRouter } from "@calcom/trpc/server/routers/viewer/webhook/_router" ;
11
11
12
12
import { buildLegacyRequest } from "@lib/buildLegacyCtx" ;
13
13
@@ -20,27 +20,15 @@ export const generateMetadata = async () =>
20
20
"/settings/developer/webhooks"
21
21
) ;
22
22
23
- const getCachedWebhooksList = unstable_cache (
24
- async ( { userId, userRole } : { userId : number ; userRole ?: UserPermissionRole } ) => {
25
- return await WebhookRepository . getAllWebhooksByUserId ( {
26
- userId,
27
- userRole,
28
- } ) ;
29
- } ,
30
- undefined ,
31
- { revalidate : 3600 , tags : [ "viewer.webhook.getByViewer" ] }
32
- ) ;
33
-
34
23
const WebhooksViewServerWrapper = async ( ) => {
35
24
const session = await getServerSession ( { req : buildLegacyRequest ( await headers ( ) , await cookies ( ) ) } ) ;
36
25
if ( ! session ?. user ?. id ) {
37
26
redirect ( "/auth/login" ) ;
38
27
}
39
28
40
29
const isAdmin = session . user . role === UserPermissionRole . ADMIN ;
41
- const userRole = session . user . role !== "INACTIVE_ADMIN" ? session . user . role : undefined ;
42
-
43
- const data = await getCachedWebhooksList ( { userId : session . user . id , userRole } ) ;
30
+ const caller = await createRouterCaller ( webhookRouter ) ;
31
+ const data = await caller . getByViewer ( ) ;
44
32
45
33
return < WebhooksView data = { data } isAdmin = { isAdmin } /> ;
46
34
} ;
0 commit comments