Merge pull request #57 from shocknet/message-id-return
transmit new message id on creation
This commit is contained in:
commit
3628d6c41d
2 changed files with 10 additions and 6 deletions
|
|
@ -750,11 +750,14 @@ class Mediator {
|
|||
|
||||
await throwOnInvalidToken(token)
|
||||
|
||||
await API.Actions.sendMessage(recipientPublicKey, body, user, mySEA)
|
||||
|
||||
this.socket.emit(Action.SEND_MESSAGE, {
|
||||
ok: true,
|
||||
msg: null,
|
||||
msg: await API.Actions.sendMessage(
|
||||
recipientPublicKey,
|
||||
body,
|
||||
user,
|
||||
mySEA
|
||||
),
|
||||
origBody: reqBody
|
||||
})
|
||||
} catch (err) {
|
||||
|
|
|
|||
|
|
@ -633,11 +633,12 @@ const sendHandshakeRequest = async (recipientPublicKey, gun, user, SEA) => {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the message id.
|
||||
* @param {string} recipientPublicKey
|
||||
* @param {string} body
|
||||
* @param {UserGUNNode} user
|
||||
* @param {ISEA} SEA
|
||||
* @returns {Promise<void>}
|
||||
* @returns {Promise<string>} The message id.
|
||||
*/
|
||||
const sendMessage = async (recipientPublicKey, body, user, SEA) => {
|
||||
if (!user.is) {
|
||||
|
|
@ -689,7 +690,7 @@ const sendMessage = async (recipientPublicKey, body, user, SEA) => {
|
|||
}
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
user
|
||||
const msgNode = user
|
||||
.get(Key.OUTGOINGS)
|
||||
.get(outgoingID)
|
||||
.get(Key.MESSAGES)
|
||||
|
|
@ -697,7 +698,7 @@ const sendMessage = async (recipientPublicKey, body, user, SEA) => {
|
|||
if (ack.err) {
|
||||
rej(new Error(ack.err))
|
||||
} else {
|
||||
res()
|
||||
res(msgNode._.get)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue