Create new enums to type state strings and numbers on server
New enums:
- RegisteredNameFoundState (for NS lookups which emit a RegisteredNameFound signal)
- This enum is in common/ since it is used by the common LookupResult interface
- NameRegistrationEndedState (for the NameRegistrationEnded signal)
- RegistrationState (for the RegistrationStateChanged signal)
- MessageState (for the AccountMessageStatusChanged signal)
- ConversationMemberEventType (for the ConversationMemberEvent signal)
Other changes:
- Update jamid.ts and jami-signal-interfaces.ts to use these new enums
- Update routers to use the enum members rather than magic constants
GitLab: #89
Change-Id: Ief38df0d4a35c6ecf96375bba01773e60e07b888
diff --git a/common/src/enums/registration-state.ts b/common/src/enums/registration-state.ts
deleted file mode 100644
index 591a6a3..0000000
--- a/common/src/enums/registration-state.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2022 Savoir-faire Linux Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this program. If not, see
- * <https://www.gnu.org/licenses/>.
- */
-export enum RegistrationState {
- Unregistered = 'UNREGISTERED',
- Trying = 'TRYING',
- Registered = 'REGISTERED',
- ErrorGeneric = 'ERROR_GENERIC',
- ErrorAuth = 'ERROR_AUTH',
- ErrorNetwork = 'ERROR_NETWORK',
- ErrorHost = 'ERROR_HOST',
- ErrorServiceUnavailable = 'ERROR_SERVICE_UNAVAILABLE',
- ErrorNeedMigration = 'ERROR_NEED_MIGRATION',
- Initializing = 'INITIALIZING',
-}
diff --git a/common/src/index.ts b/common/src/index.ts
index a7c0b1c..0dde015 100644
--- a/common/src/index.ts
+++ b/common/src/index.ts
@@ -16,7 +16,6 @@
* <https://www.gnu.org/licenses/>.
*/
export * from './enums/http-status-code.js';
-export * from './enums/registration-state.js';
export * from './enums/websocket-message-type.js';
export * from './interfaces/account.js';
export * from './interfaces/auth-interfaces.js';
diff --git a/common/src/interfaces/lookup-result.ts b/common/src/interfaces/lookup-result.ts
index 1d18a14..b3c21bd 100644
--- a/common/src/interfaces/lookup-result.ts
+++ b/common/src/interfaces/lookup-result.ts
@@ -16,7 +16,14 @@
* <https://www.gnu.org/licenses/>.
*/
export interface LookupResult {
- state: number; // TODO: Create enum for state
+ state: RegisteredNameFoundState;
address: string;
username: string;
}
+
+export enum RegisteredNameFoundState {
+ Found,
+ InvalidResponse,
+ NotFound,
+ Error,
+}