| 1 | "use server"; |
| 2 | |
| 3 | import { revalidatePath } from |
| 4 | import { cookies } |
| 5 | import { createSafeActionClient } |
| 6 | import { z } |
| 7 | |
| 8 | import { fetchClient } |
| 9 | |
| 10 | import { watchLevels } |
| 11 | |
| 12 | const actionClient = createSafeActionClient |
| 13 | handleServerError: (error) |
| 14 | }); |
| 15 | |
| 16 | const repository = z |
| 17 | |
| 18 | export const setNotificationUnread = |
| 19 | .inputSchema(z.object |
| 20 | .action(async ( |
| 21 | const { error |
| 22 | params: { path: { |
| 23 | body: { unread |
| 24 | headers: { cookie: ( |
| 25 | }); |
| 26 | |
| 27 | if (error) throw |
| 28 | |
| 29 | revalidatePath("/notifications"); |
| 30 | }); |
| 31 | |
| 32 | export const markAllNotificationsRead = |
| 33 | const { error |
| 34 | headers: { cookie: ( |
| 35 | }); |
| 36 | |
| 37 | if (error) throw |
| 38 | |
| 39 | revalidatePath("/notifications"); |
| 40 | }); |
| 41 | |
| 42 | export const setThreadSubscription = |
| 43 | .inputSchema( |
| 44 | repository.extend({ |
| 45 | ) |
| 46 | .action(async ( |
| 47 | const { error |
| 48 | "/api/repositories/{username}/{repo}/issues/{number}/subscription", |
| 49 | { |
| 50 | params: { path: { |
| 51 | body: { subscribed |
| 52 | headers: { cookie: ( |
| 53 | }, |
| 54 | ); |
| 55 | |
| 56 | if (error) throw |
| 57 | |
| 58 | revalidatePath(`/${username |
| 59 | }); |
| 60 | |
| 61 | export const setRepositoryWatch = |
| 62 | .inputSchema(repository.extend |
| 63 | .action(async ( |
| 64 | const { error |
| 65 | "/api/repositories/{username}/{repo}/subscription", |
| 66 | { |
| 67 | params: { path: { |
| 68 | body: { level |
| 69 | headers: { cookie: ( |
| 70 | }, |
| 71 | ); |
| 72 | |
| 73 | if (error) throw |
| 74 | |
| 75 | revalidatePath(`/${username |
| 76 | }); |