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/jami-signal-interfaces.ts b/server/src/jamid/jami-signal-interfaces.ts
index 960034b..851239b 100644
--- a/server/src/jamid/jami-signal-interfaces.ts
+++ b/server/src/jamid/jami-signal-interfaces.ts
@@ -16,8 +16,15 @@
* <https://www.gnu.org/licenses/>.
*/
import { AccountDetails, Devices, Message, VolatileDetails } from 'jami-web-common';
+import { RegisteredNameFoundState } from 'jami-web-common';
import { ConversationRequestMetadata } from './conversation-request-metadata.js';
+import {
+ ConversationMemberEventType,
+ MessageState,
+ NameRegistrationEndedState,
+ RegistrationState,
+} from './state-enums.js';
// These interfaces are used to hold all the parameters for signal handlers
// These parameters' names and types can be found in daemon/bin/nodejs/callback.h
@@ -35,20 +42,20 @@
export interface RegistrationStateChanged {
accountId: string;
- state: string;
+ state: RegistrationState;
code: number;
details: string;
}
export interface NameRegistrationEnded {
accountId: string;
- state: number;
+ state: NameRegistrationEndedState;
username: string;
}
export interface RegisteredNameFound {
accountId: string;
- state: number;
+ state: RegisteredNameFoundState;
address: string;
username: string;
}
@@ -68,7 +75,7 @@
accountId: string;
messageId: string;
peer: string;
- state: number; // TODO: Replace state number with enum (see account_const.h)
+ state: MessageState;
}
export interface IncomingTrustRequest {
@@ -118,7 +125,7 @@
accountId: string;
conversationId: string;
memberUri: string;
- event: number;
+ event: ConversationMemberEventType;
}
export interface MessageReceived {