Skip to content

Commit

Permalink
Small change in notification col key
Browse files Browse the repository at this point in the history
  • Loading branch information
sharonm6 committed Apr 1, 2024
1 parent 558241d commit c31cc47
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
42 changes: 21 additions & 21 deletions routes/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,27 @@ itemsRouter.post("/", async (req, res) => {
res.json(item.rows[0]); // send the response immediately after adding the item
let contentString = "";

async function sendPushNotification() {
// filter out undefined keys
const subscriptionKeys = subscribedUsers.rows
.map((user) => user.notificationKey)
.filter((key) => key !== undefined);
// send push notification
await axios.post(
`${process.env.REACT_APP_AWS_BACKEND_URL}/notification/keys`,
{
subscriptionKeys: subscriptionKeys,
notificationTitle: "A nearby item was added.",
notificationBody: `A new item, ${name}, was added to ZotnFound!`,
},
{
headers: {
Authorization: `Bearer ${token}`, // verify auth
},
}
);
}
sendPushNotification();
// async function sendPushNotification() {
// // filter out undefined keys
// const subscriptionKeys = subscribedUsers.rows
// .map((user) => user.notification_key)
// .filter((key) => key !== undefined);
// // send push notification
// await axios.post(
// `${process.env.REACT_APP_AWS_BACKEND_URL}/notification/keys`,
// {
// subscriptionKeys: subscriptionKeys,
// notificationTitle: "A nearby item was added.",
// notificationBody: `A new item, ${name}, was added to ZotnFound!`,
// },
// {
// headers: {
// Authorization: `Bearer ${token}`, // verify auth
// },
// }
// );
// }
// sendPushNotification();

// COMMENT OUT FOR TESTING PURPOSES
if (process.env.NODE_ENV === "production") {
Expand Down
2 changes: 1 addition & 1 deletion routes/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ leaderboardRouter.patch(
return res.status(400).send("Invalid request parameters");
}
await pool.query(
`UPDATE ${leaderboardTable} SET notificationKey=$1 WHERE email=$2`,
`UPDATE ${leaderboardTable} SET notification_key=$1 WHERE email=$2`,
[notificationKey, email]
);
res.send("Notification subscription key updated successfully!");
Expand Down
2 changes: 1 addition & 1 deletion server/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ CREATE TABLE leaderboard(
email VARCHAR(255),
points INTEGER,
subscription BOOLEAN,
notificationKey VARCHAR(500)
notification_key VARCHAR(500)
)

1 comment on commit c31cc47

@sharonm6
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected commit message: Small change in name of notification key column

Please sign in to comment.