mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
Do not throw an error when adding the same push device twice (#10770)
* do not throw an error when adding the same push device twice * fix spelling * fix linting
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { authWithHeaders } from '../../middlewares/auth';
|
||||
import {
|
||||
NotAuthorized,
|
||||
NotFound,
|
||||
} from '../../libs/errors';
|
||||
import { model as PushDevice } from '../../models/pushDevice';
|
||||
@@ -39,8 +38,10 @@ api.addPushDevice = {
|
||||
type: req.body.type,
|
||||
};
|
||||
|
||||
// When adding a duplicate push device, fail silently instead of throwing an error
|
||||
if (pushDevices.find(device => device.regId === item.regId)) {
|
||||
throw new NotAuthorized(res.t('pushDeviceAlreadyAdded'));
|
||||
res.respond(200, user.pushDevices, res.t('pushDeviceAdded'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Concurrency safe update
|
||||
|
||||
Reference in New Issue
Block a user