remove unused code, add try/catch block
This commit is contained in:
		
							
								
								
									
										37
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								src/main.ts
									
									
									
									
									
								
							| @ -11,28 +11,6 @@ import { createWebsocket } from "./websocket.js"; | ||||
|  | ||||
| const prisma = new PrismaClient(); | ||||
|  | ||||
| // const getNotifications = async () => { | ||||
| //   try { | ||||
| //     const request = await fetch( | ||||
| //       `${process.env.PLEROMA_INSTANCE_URL}/api/v1/notifications?types[]=mention`, | ||||
| //       { | ||||
| //         method: "GET", | ||||
| //         headers: { | ||||
| //           Authorization: `Bearer ${process.env.INSTANCE_BEARER_TOKEN}`, | ||||
| //         }, | ||||
| //       } | ||||
| //     ); | ||||
|  | ||||
| //     const notifications: Notification[] = await request.json(); | ||||
|  | ||||
| //     return notifications; | ||||
| //   } catch (error: any) { | ||||
| //     throw new Error(error.message); | ||||
| //   } | ||||
| // }; | ||||
|  | ||||
| // const notifications = await getNotifications(); | ||||
|  | ||||
| const storeUserData = async (notification: Notification): Promise<void> => { | ||||
|   try { | ||||
|     await prisma.user.upsert({ | ||||
| @ -182,6 +160,7 @@ ws.on("upgrade", () => { | ||||
| }); | ||||
|  | ||||
| ws.on("message", async (data) => { | ||||
|   try { | ||||
|     const message: WSEvent = JSON.parse(data.toString("utf-8")); | ||||
|     if (message.event !== "notification") { | ||||
|       // only watch for notification events | ||||
| @ -193,15 +172,7 @@ ws.on("message", async (data) => { | ||||
|     if (ollamaResponse) { | ||||
|       await postReplyToStatus(payload, ollamaResponse); | ||||
|     } | ||||
|   } catch (error: any) { | ||||
|     console.error(error.message); | ||||
|   } | ||||
| }); | ||||
|  | ||||
| // if (notifications) { | ||||
| //   await Promise.all( | ||||
| //     notifications.map(async (notification) => { | ||||
| //       const ollamaResponse = await generateOllamaRequest(notification); | ||||
| //       if (ollamaResponse) { | ||||
| //         postReplyToStatus(notification, ollamaResponse); | ||||
| //       } | ||||
| //     }) | ||||
| //   ); | ||||
| // } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user