Skip to content

Commit f7de55f

Browse files
authored
Merge pull request #349 from mfts/fix/notification
fix: notifications
2 parents cd3bc9a + d4ce765 commit f7de55f

File tree

7 files changed

+1054
-780
lines changed

7 files changed

+1054
-780
lines changed

Diff for: components/mdx/components/index.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export const mdxComponents: MDXComponents = {
1919
}
2020

2121
return (
22-
// @ts-expect-error legacy refs
2322
<Link
2423
{...props}
2524
className={cn(

Diff for: lib/api/notification-helper.ts

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { getTriggerClient } from "@/trigger";
2+
import { log } from "@/lib/utils";
3+
4+
export default async function sendNotification({ viewId }: { viewId: string }) {
5+
const client = getTriggerClient();
6+
7+
if (!client) {
8+
/** If client does not exist, use fetch to send notifications */
9+
return await fetch(
10+
`${process.env.NEXTAUTH_URL}/api/jobs/send-notification`,
11+
{
12+
method: "POST",
13+
headers: {
14+
"Content-Type": "application/json",
15+
Authorization: `Bearer ${process.env.INTERNAL_API_KEY}`,
16+
},
17+
body: JSON.stringify({ viewId: viewId }),
18+
},
19+
)
20+
.then(() => {})
21+
.catch((error) => {
22+
log({
23+
message: `Failed to fetch notifications job in _/api/views_ route. \n\n Error: ${error} \n\n*Metadata*: \`{viewId: ${viewId}}\``,
24+
type: "error",
25+
mention: true,
26+
});
27+
});
28+
}
29+
30+
/** If client exists, use trigger to send notifications */
31+
return await client.sendEvent({
32+
name: "link.viewed",
33+
payload: {
34+
viewId: viewId,
35+
},
36+
});
37+
}

Diff for: next.config.js renamed to next.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ const nextConfig = {
7979
},
8080
};
8181

82-
module.exports = nextConfig;
82+
export default nextConfig;

0 commit comments

Comments
 (0)