handling updateRegistrationToken from frontend
MODIFY
src/server/rest/CentralRestServerService.ts
src/server/rest/CentralRestServerService.ts
@@ -227,6 +227,7 @@ class RequestMapper {
[ServerAction.SYNCHRONIZE_CAR_CATALOGS]: CarService.handleSynchronizeCarCatalogs.bind(this),
[ServerAction.CAR_UPDATE]: CarService.handleUpdateCar.bind(this),
[ServerAction.TAG_UPDATE]: TagService.handleUpdateTag.bind(this),
+ [ServerAction.REGISTRATION_TOKEN_UPDATE]: RegistrationTokenService.handleUpdateRegistrationToken.bind(this),
});
break;

MODIFY
src/server/rest/v1/service/RegistrationTokenService.ts
src/server/rest/v1/service/RegistrationTokenService.ts
@@ -89,11 +89,13 @@ export default class RegistrationTokenService {
UtilsService.assertObjectExists(action, registrationToken, `Token ID '${filteredRequest.id}' does not exist`,
MODULE_NAME, 'handleUpdateRegistrationToken', req.user);
if (Utils.isComponentActiveFromToken(req.user, TenantComponents.ORGANIZATION)) {
- // Check Site Area
+ // Check Site Area if it's provided
+ if (filteredRequest.siteAreaID) {
const siteArea = await SiteAreaStorage.getSiteArea(req.user.tenantID, filteredRequest.siteAreaID);
UtilsService.assertObjectExists(action, siteArea, `Site Area ID '${filteredRequest.siteAreaID}' does not exist`,
MODULE_NAME, 'handleUpdateRegistrationToken', req.user);
}
+ }
// Check Auth
if (!Authorizations.canUpdateRegistrationToken(req.user, registrationToken.siteArea?.siteID)) {
// Not Authorized!

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -42,6 +42,7 @@ export enum ServerAction {
REGISTRATION_TOKENS = 'RegistrationTokens',
REGISTRATION_TOKEN_DELETE = 'RegistrationTokenDelete',
REGISTRATION_TOKEN_REVOKE = 'RegistrationTokenRevoke',
+ REGISTRATION_TOKEN_UPDATE = 'RegistrationTokenUpdate',
STATUS_NOTIFICATIONS = 'StatusNotifications',

MODIFY
test/api/client/RegistrationTokenApi.ts
test/api/client/RegistrationTokenApi.ts
@@ -17,4 +17,8 @@ export default class RegistrationTokenApi extends CrudApi {
public async create(data = {}) {
return await super.create(data, '/client/api/RegistrationTokenCreate');
}
+
+ public async update(data) {
+ return super.update(data, 'client/api/RegistrationTokenUpdate');
+ }
}

handling updateRegistrationToken from frontend