-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arnaud AMBROSELLI
committed
Jul 29, 2024
1 parent
46b1e96
commit b9485da
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require("dotenv").config({ path: "./.env" }); | ||
const prisma = require("../prisma"); | ||
const { sendPushNotification } = require("../services/push-notifications"); | ||
|
||
const userId = process.argv[2]; | ||
|
||
if (!userId) { | ||
console.error("Please provide a userId as an argument"); | ||
process.exit(1); | ||
} | ||
|
||
(async () => { | ||
const user = await prisma.user.findFirst({ | ||
where: { | ||
id: userId, | ||
}, | ||
}); | ||
|
||
if (!user) { | ||
console.error(`User with id ${userId} not found`); | ||
process.exit(1); | ||
} | ||
|
||
console.log({ user }); | ||
|
||
const results = await sendPushNotification({ | ||
userId, | ||
matomoId: user.matomo_id, | ||
pushNotifToken: user.push_notif_token, | ||
title: "La notif elle est là", | ||
body: "This is a test notification", | ||
data: { | ||
type: "test", | ||
}, | ||
}); | ||
|
||
console.log(JSON.stringify(results, null, 2)); | ||
})(); |