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