allow to register name
Change-Id: I72862e179253cdc9af4c8c381282745281f9c9d8
diff --git a/JamiDaemon.js b/JamiDaemon.js
index 2e5e478..08dd3cc 100755
--- a/JamiDaemon.js
+++ b/JamiDaemon.js
@@ -128,6 +128,20 @@
index -= 1
}
},
+ "NameRegistrationEnded": (accountId, state, name) => {
+ console.log(`NameRegistrationEnded: ${accountId} ${state} ${name}`)
+ const account = this.getAccount(accountId)
+ if (account) {
+ if (state === 0)
+ account.volatileDetails['Account.registeredName'] = name
+ if (account.registeringName) {
+ account.registeringName.resolve(state)
+ delete account.registeringName
+ }
+ } else {
+ console.log(`Unknown account ${accountId}`)
+ }
+ },
"ConversationReady": (accountId, conversationId) => {
console.log(`conversationReady: ${accountId} ${conversationId}`)
const account = this.getAccount(accountId)
@@ -260,6 +274,21 @@
getAccountList() {
return this.accounts
}
+ registerName(accountId, password, name) {
+ return new Promise((resolve, reject) => {
+ if (!name)
+ return reject(new Error("Invalid name"))
+ const account = this.getAccount(accountId)
+ if (!account)
+ return reject(new Error("Can't find account"))
+ if (account.registeringName)
+ return reject(new Error("Username already being registered"))
+ if (this.dring.registerName(accountId, password, name)) {
+ account.registeringName = { name, resolve, reject }
+ }
+ })
+ }
+
getConversation(accountId, conversationId) {
const account = this.getAccount(accountId)
if (account)
diff --git a/README.txt b/README.txt
index b1a8451..6a6e74b 100644
--- a/README.txt
+++ b/README.txt
@@ -1,6 +1,6 @@
-# Jami-Jass
+# Jami-web
-Jami-Jass is a web server that starts a Dameon on NodeJS express server and serve a React web client.
+Jami-web is a web server that starts a Dameon on NodeJS express server and serve a React web client.
The first milestone is to allow user with LDAP credentials to connect to the account using JAMS service and start chatting with their contacts using instant messaging.
@@ -8,21 +8,8 @@
# Main dependencies
-Jami deamon (https://review.jami.net/admin/repos/ring-daemon)
-
-Jami node js interface (https://review.jami.net/admin/repos/ring-daemon)
-
-Node JS
-
-React
-
-Webpack
-
-Babel
-
-npm install -g node-gyp
-
-For the rest of the dependencies see package.json
+* Jami Deamon with NodeJS bindings (https://review.jami.net/admin/repos/ring-daemon),
+* NodeJS v14+
# How to start the server
@@ -33,9 +20,3 @@
LD_LIBRARY_PATH=$PATH_TO_JAMI_PROJECT/ring-project/install/daemon/lib node
To build the dring.node Javascript interface to talk to the daemon api go to the daemon repo and use ./configure --with-nodejs then execute make -j4 to build the daemon
-
-Make sure that the Makefile.ma is configured to build the Swig interfaces with the right nodejs version:
-
-node-gyp configure --target=4.0.0 --arch=x64 --dist-url=https://atom.io/download/electron
-
-
diff --git a/client/src/components/ConversationListItem.js b/client/src/components/ConversationListItem.js
index a0295d5..80a3aae 100644
--- a/client/src/components/ConversationListItem.js
+++ b/client/src/components/ConversationListItem.js
@@ -18,11 +18,9 @@
button
alignItems="flex-start"
selected={isSelected}
- style={{overflow:'hidden'}}
onClick={() => history.replace(`/account/${conversation.getAccountId()}/${uri}`)}>
<ListItemAvatar><ConversationAvatar displayName={conversation.getDisplayNameNoFallback()} /></ListItemAvatar>
<ListItemText
- style={{overflow:'hidden', textOverflow:'ellipsis'}}
primary={conversation.getDisplayName()} secondary={conversation.getDisplayUri()} />
</ListItem>
)
diff --git a/client/src/components/MessageList.js b/client/src/components/MessageList.js
index e73af6a..175f19b 100644
--- a/client/src/components/MessageList.js
+++ b/client/src/components/MessageList.js
@@ -15,12 +15,12 @@
return (
<React.Fragment>
<Box className="conversation-header">
- <Box style={{ display: 'inline-block', margin: 16, verticalAlign: 'middle' }}>
+ <Box style={{ margin: 16, flexShrink: 0 }}>
<ConversationAvatar displayName={props.conversation.getDisplayNameNoFallback()} />
</Box>
- <Box style={{ display: 'inline-block', verticalAlign: 'middle' }}>
- <Typography variant="h6">{displayName}</Typography>
- <Typography variant="subtitle1">{props.conversation.getId()}</Typography>
+ <Box style={{ flex: "1 1 auto", overflow: 'hidden' }}>
+ <Typography className="title" variant="h6">{displayName}</Typography>
+ <Typography className="subtitle" variant="subtitle1" >{props.conversation.getId()}</Typography>
</Box>
<Divider orientation="horizontal" />
</Box>
diff --git a/client/src/index.scss b/client/src/index.scss
index 05a3129..7c2adbe 100644
--- a/client/src/index.scss
+++ b/client/src/index.scss
@@ -36,10 +36,19 @@
grid-area: m;
display: flex;
flex-direction: column;
+ overflow: hidden;
}
.conversation-header {
grid-area: h;
+ display: flex;
+ align-items: center;
+ padding-right: 8px;
+
+ .title, .subtitle {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
}
.send-message-form {
diff --git a/client/src/pages/jamiAccountCreation.jsx b/client/src/pages/jamiAccountCreation.jsx
index 2bd8ea9..ac59762 100644
--- a/client/src/pages/jamiAccountCreation.jsx
+++ b/client/src/pages/jamiAccountCreation.jsx
@@ -40,9 +40,7 @@
'Accept': 'application/json',
'Content-Type': 'application/json'
},
- body: JSON.stringify({
- 'Account.registeredName': name
- })
+ body: JSON.stringify({ registerName: name })
})
.then(res => res.json())
.catch(error => {
diff --git a/routes/jami.js b/routes/jami.js
index d76462e..28c4a05 100644
--- a/routes/jami.js
+++ b/routes/jami.js
@@ -30,7 +30,12 @@
console.log("Create new account")
console.log(req.body)
try {
- res.json({ accountId: await this.jami.addAccount(req.body) })
+ const accountId = await this.jami.addAccount(req.body)
+ if (req.body.registerName) {
+ this.jami.registerName(accountId, "", req.body.registerName)
+ .then(result => console.log("Name registrtion result: " + result))
+ }
+ res.json({ accountId })
} catch (e) {
res.status(400).json({ error: e })
}