mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
remove buildSessionRequest message
This commit is contained in:
parent
1fe0e3a815
commit
fbba5575ba
5 changed files with 12 additions and 47 deletions
|
@ -1956,7 +1956,7 @@
|
|||
});
|
||||
|
||||
// send a session request for all the members we do not have a session with
|
||||
window.libloki.api.sendSessionRequestsToMembers(updates.members);
|
||||
await window.libloki.api.sendSessionRequestsToMembers(updates.members);
|
||||
|
||||
const { expireTimer } = details;
|
||||
const isValidExpireTimer = typeof expireTimer === 'number';
|
||||
|
|
|
@ -1720,6 +1720,7 @@
|
|||
|
||||
await libsession.getMessageQueue().sendToGroup(expirationTimerMessage);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
isSearchable() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* global window, textsecure, dcodeIO, StringView, ConversationController, _, libsession */
|
||||
/* global window, textsecure, dcodeIO, StringView, ConversationController, libsession */
|
||||
/* eslint-disable no-bitwise */
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
|
@ -172,24 +172,15 @@
|
|||
});
|
||||
return syncMessage;
|
||||
}
|
||||
function sendSessionRequestsToMembers(members = []) {
|
||||
// For every member, see if we need to establish a session:
|
||||
members.forEach(memberPubKey => {
|
||||
const haveSession = _.some(
|
||||
textsecure.storage.protocol.sessions,
|
||||
s => s.number === memberPubKey
|
||||
);
|
||||
|
||||
async function sendSessionRequestsToMembers(members = []) {
|
||||
// For every member, trigger a session request if needed
|
||||
members.forEach(async memberStr => {
|
||||
const ourPubKey = textsecure.storage.user.getNumber();
|
||||
if (!haveSession && memberPubKey !== ourPubKey) {
|
||||
// eslint-disable-next-line more/no-then
|
||||
ConversationController.getOrCreateAndWait(memberPubKey, 'private').then(
|
||||
() => {
|
||||
const sessionRequestMessage = textsecure.OutgoingMessage.buildSessionRequestMessage(
|
||||
memberPubKey
|
||||
);
|
||||
sessionRequestMessage.sendToNumber(memberPubKey);
|
||||
}
|
||||
if (memberStr !== ourPubKey) {
|
||||
await ConversationController.getOrCreateAndWait(memberStr, 'private');
|
||||
const memberPubkey = new libsession.Types.PubKey(memberStr);
|
||||
await libsession.Protocols.SessionProtocol.sendSessionRequestIfNeeded(
|
||||
memberPubkey
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -644,33 +644,6 @@ OutgoingMessage.prototype = {
|
|||
},
|
||||
};
|
||||
|
||||
OutgoingMessage.buildSessionRequestMessage = function buildSessionRequestMessage(
|
||||
pubKey
|
||||
) {
|
||||
const body =
|
||||
'(If you see this message, you must be using an out-of-date client)';
|
||||
|
||||
const flags = textsecure.protobuf.DataMessage.Flags.SESSION_REQUEST;
|
||||
|
||||
const dataMessage = new textsecure.protobuf.DataMessage({ flags, body });
|
||||
|
||||
const content = new textsecure.protobuf.Content({
|
||||
dataMessage,
|
||||
});
|
||||
|
||||
const options = {};
|
||||
// Send a empty message with information about how to contact us directly
|
||||
return new OutgoingMessage(
|
||||
null, // server
|
||||
Date.now(), // timestamp,
|
||||
[pubKey], // numbers
|
||||
content, // message
|
||||
true, // silent
|
||||
() => null, // callback
|
||||
options
|
||||
);
|
||||
};
|
||||
|
||||
OutgoingMessage.DebugMessageType = DebugMessageType;
|
||||
|
||||
window.textsecure = window.textsecure || {};
|
||||
|
|
|
@ -111,7 +111,7 @@ export async function preprocessGroupMessage(
|
|||
}
|
||||
}
|
||||
// send a session request for all the members we do not have a session with
|
||||
window.libloki.api.sendSessionRequestsToMembers(group.members);
|
||||
await window.libloki.api.sendSessionRequestsToMembers(group.members);
|
||||
} else if (newGroup) {
|
||||
// We have an unknown group, we should request info from the sender
|
||||
const requestInfo = {
|
||||
|
|
Loading…
Reference in a new issue