paste sessionEstablishedMessage whenever needed

pull/1194/head
Audric Ackermann 5 years ago
parent 655cc0575e
commit e38ea17e21
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1775,7 +1775,12 @@
await this.setSessionResetStatus(SessionResetEnum.request_received); await this.setSessionResetStatus(SessionResetEnum.request_received);
// send empty message, this will trigger the new session to propagate // send empty message, this will trigger the new session to propagate
// to the reset initiator. // to the reset initiator.
await window.libloki.api.sendSessionEstablishedMessage(this.id); const user = new libsession.Types.PubKey(this.id);
const sessionEstablished = new window.libsession.Messages.Outgoing.SessionEstablishedMessage(
{ timestamp: Date.now() }
);
await libsession.getMessageQueue().send(user, sessionEstablished);
}, },
isSessionResetReceived() { isSessionResetReceived() {
@ -1811,7 +1816,13 @@
async onNewSessionAdopted() { async onNewSessionAdopted() {
if (this.get('sessionResetStatus') === SessionResetEnum.initiated) { if (this.get('sessionResetStatus') === SessionResetEnum.initiated) {
// send empty message to confirm that we have adopted the new session // send empty message to confirm that we have adopted the new session
await window.libloki.api.sendSessionEstablishedMessage(this.id); const user = new libsession.Types.PubKey(this.id);
const sessionEstablished = new window.libsession.Messages.Outgoing.SessionEstablishedMessage(
{ timestamp: Date.now() }
);
await libsession.getMessageQueue().send(user, sessionEstablished);
} }
await this.createAndStoreEndSessionMessage({ await this.createAndStoreEndSessionMessage({
type: 'incoming', type: 'incoming',

@ -54,14 +54,6 @@
} }
} }
async function sendSessionEstablishedMessage(pubKey) {
const user = new libsession.Types.PubKey(pubKey);
const sessionEstablished = new window.libsession.Messages.Outgoing.SessionEstablishedMessage(
{ timestamp: Date.now() }
);
await libsession.getMessageQueue().send(user, sessionEstablished);
}
// Serialise as <Element0.length><Element0><Element1.length><Element1>... // Serialise as <Element0.length><Element0><Element1.length><Element1>...
// This is an implementation of the reciprocal of contacts_parser.js // This is an implementation of the reciprocal of contacts_parser.js
function serialiseByteBuffers(buffers) { function serialiseByteBuffers(buffers) {
@ -166,7 +158,6 @@
}; };
window.libloki.api = { window.libloki.api = {
sendSessionEstablishedMessage,
sendSessionRequestsToMembers, sendSessionRequestsToMembers,
createContactSyncMessage, createContactSyncMessage,
createGroupSyncMessage, createGroupSyncMessage,

@ -1144,7 +1144,12 @@ MessageReceiver.prototype.extend({
); );
window.log.debug('sending session established to', envelope.source); window.log.debug('sending session established to', envelope.source);
// We don't need to await the call below because we just want to send it off // We don't need to await the call below because we just want to send it off
window.libloki.api.sendSessionEstablishedMessage(envelope.source); const user = new libsession.Types.PubKey(envelope.source);
const sessionEstablished = new window.libsession.Messages.Outgoing.SessionEstablishedMessage(
{ timestamp: Date.now() }
);
await libsession.getMessageQueue().send(user, sessionEstablished);
} catch (e) { } catch (e) {
window.log.warn('Failed to process session request', e); window.log.warn('Failed to process session request', e);
// TODO how to handle a failed session request? // TODO how to handle a failed session request?

Loading…
Cancel
Save