mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-01 04:08:45 -05:00
fix: delete endpoint on push notification disable (#2067)
fix: add endpoint deletion on disable fix: use definemessages util refactor: add code comment
This commit is contained in:
@@ -269,16 +269,20 @@ router.delete<{ userId: number; endpoint: string }>(
|
|||||||
try {
|
try {
|
||||||
const userPushSubRepository = getRepository(UserPushSubscription);
|
const userPushSubRepository = getRepository(UserPushSubscription);
|
||||||
|
|
||||||
const userPushSub = await userPushSubRepository.findOneOrFail({
|
const userPushSub = await userPushSubRepository.findOne({
|
||||||
relations: {
|
relations: { user: true },
|
||||||
user: true,
|
|
||||||
},
|
|
||||||
where: {
|
where: {
|
||||||
user: { id: req.params.userId },
|
user: { id: req.params.userId },
|
||||||
endpoint: req.params.endpoint,
|
endpoint: req.params.endpoint,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// If not found, just return 204 to prevent push disable failure
|
||||||
|
// (rare scenario where user push sub does not exist)
|
||||||
|
if (!userPushSub) {
|
||||||
|
return res.status(204).send();
|
||||||
|
}
|
||||||
|
|
||||||
await userPushSubRepository.remove(userPushSub);
|
await userPushSubRepository.remove(userPushSub);
|
||||||
return res.status(204).send();
|
return res.status(204).send();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -111,6 +111,11 @@ const UserWebPushSettings = () => {
|
|||||||
try {
|
try {
|
||||||
await unsubscribeToPushNotifications(user?.id, endpoint);
|
await unsubscribeToPushNotifications(user?.id, endpoint);
|
||||||
|
|
||||||
|
// Delete from backend if endpoint is available
|
||||||
|
if (subEndpoint) {
|
||||||
|
await deletePushSubscriptionFromBackend(subEndpoint);
|
||||||
|
}
|
||||||
|
|
||||||
localStorage.setItem('pushNotificationsEnabled', 'false');
|
localStorage.setItem('pushNotificationsEnabled', 'false');
|
||||||
setWebPushEnabled(false);
|
setWebPushEnabled(false);
|
||||||
addToast(intl.formatMessage(messages.webpushhasbeendisabled), {
|
addToast(intl.formatMessage(messages.webpushhasbeendisabled), {
|
||||||
|
|||||||
Reference in New Issue
Block a user