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/server/src/jamid/state-enums.ts b/server/src/jamid/state-enums.ts
new file mode 100644
index 0000000..08b75da
--- /dev/null
+++ b/server/src/jamid/state-enums.ts
@@ -0,0 +1,54 @@
+/*
+ * 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',
+}
+
+export enum NameRegistrationEndedState {
+ Success,
+ InvalidCredentials,
+ InvalidName,
+ AlreadyTaken,
+ Error,
+}
+
+export enum MessageState {
+ Unknown,
+ Sending,
+ Sent,
+ Displayed,
+ Failure,
+ Cancelled,
+}
+
+export enum ConversationMemberEventType {
+ Add,
+ Join,
+ Remove,
+ Ban,
+ Unban,
+}