-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.ts
46 lines (40 loc) · 1.37 KB
/
run.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { handler, UserWithWebPushSubscription } from "./src";
import { createDatabaseTunnel } from "shared/database/local/databaseTunnel";
import { getDatabaseConnection } from "shared/database/databaseConnection";
import { getYourEmail } from "shared/local/yourEmail";
import { Item } from "shared/graphql/graphql";
(async () => {
const yourEmail = await getYourEmail();
await createDatabaseTunnel();
const sql = await getDatabaseConnection();
const yourUser = await sql`
SELECT *
FROM "User"
WHERE "email" = ${yourEmail}
AND "webPushSubscription" IS NOT NULL
`.then((rows) => rows[0]);
if (!yourUser) {
throw Error(
`You (${yourEmail}) don't have a web push subscription in the DB. Please try again after subscribing in the browser via pinboard UI.`
);
}
await handler({
item: {
pinboardId: "63923",
payload: null,
mentions: [],
groupMentions: [],
userEmail: "[email protected]",
id: "535b86e2-4f01-4f60-a2d0-a5e4f5a7d312",
message: "testing one two three",
type: "message-only",
timestamp: new Date(1630517452000).toISOString(),
claimable: false,
claimedByEmail: null,
relatedItemId: null,
editHistory: null,
deletedAt: null,
} satisfies Item,
users: [yourUser as UserWithWebPushSubscription],
});
})().catch(console.error);