Send payload daemon-daemon
- Add type in inteface with jamid to send data via sendAccountTextMessage
- Add route to server
Gitlab: #52
Change-Id: I4694f37ae22097bf7776f2e3698d3c080b2cff02
diff --git a/server/src/jamid/jami-signal-interfaces.ts b/server/src/jamid/jami-signal-interfaces.ts
index 5c62482..f868150 100644
--- a/server/src/jamid/jami-signal-interfaces.ts
+++ b/server/src/jamid/jami-signal-interfaces.ts
@@ -39,3 +39,9 @@
address: string;
username: string;
}
+
+export interface IncomingAccountMessage {
+ accountId: string;
+ from: string;
+ message: Record<string, string>;
+}
diff --git a/server/src/jamid/jami-swig.ts b/server/src/jamid/jami-swig.ts
index 8797b96..26ac694 100644
--- a/server/src/jamid/jami-swig.ts
+++ b/server/src/jamid/jami-swig.ts
@@ -67,6 +67,8 @@
getAccountList(): StringVect;
+ sendAccountTextMessage(accountId: string, contactId: string, message: StringMap): void;
+
lookupName(accountId: string, nameserver: string, username: string): boolean;
lookupAddress(accountId: string, nameserver: string, address: string): boolean;
registerName(accountId: string, password: string, username: string): boolean;
diff --git a/server/src/jamid/jamid.ts b/server/src/jamid/jamid.ts
index 1b7ba40..a865777 100644
--- a/server/src/jamid/jamid.ts
+++ b/server/src/jamid/jamid.ts
@@ -22,6 +22,7 @@
import { JamiSignal } from './jami-signal.js';
import {
+ IncomingAccountMessage,
NameRegistrationEnded,
RegisteredNameFound,
RegistrationStateChanged,
@@ -62,11 +63,16 @@
handlers.RegisteredNameFound = (accountId: string, state: number, address: string, username: string) =>
onRegisteredNameFound.next({ accountId, state, address, username });
+ const onIncomingAccountMessage = new Subject<IncomingAccountMessage>();
+ handlers.IncomingAccountMessage = (accountId: string, from: string, message: Record<string, string>) =>
+ onIncomingAccountMessage.next({ accountId, from, message });
+
this.events = {
onVolatileDetailsChanged: onVolatileDetailsChanged.asObservable(),
onRegistrationStateChanged: onRegistrationStateChanged.asObservable(),
onNameRegistrationEnded: onNameRegistrationEnded.asObservable(),
onRegisteredNameFound: onRegisteredNameFound.asObservable(),
+ onIncomingAccountMessage: onIncomingAccountMessage.asObservable(),
};
this.events.onVolatileDetailsChanged.subscribe(({ accountId, details }) => {
@@ -82,6 +88,9 @@
);
this.events.onNameRegistrationEnded.subscribe((ctx) => log.debug('[1] Received onNameRegistrationEnded with', ctx));
this.events.onRegisteredNameFound.subscribe((ctx) => log.debug('[1] Received onRegisteredNameFound with', ctx));
+ this.events.onIncomingAccountMessage.subscribe((ctx) =>
+ log.debug('[1] Received onIncomingAccountMessage with', ctx)
+ );
this.usernamesToAccountIds = new Map<string, string>();
@@ -139,6 +148,12 @@
return stringVectToArray(this.jamiSwig.getAccountList());
}
+ sendAccountTextMessage(accountId: string, contactId: string, type: string, message: string) {
+ const messageStringMap: StringMap = new this.jamiSwig.StringMap();
+ messageStringMap.set(type, message);
+ this.jamiSwig.sendAccountTextMessage(accountId, contactId, messageStringMap);
+ }
+
async lookupUsername(username: string) {
const hasRingNs = this.jamiSwig.lookupName('', '', username);
if (!hasRingNs) {