Removed online broadcast message type, changed ttl logic a little, add p2p address and port to the window object when recieve message
This commit is contained in:
parent
07076c27ae
commit
2bae6b5eed
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"storageProfile": "development1",
|
||||
"localServerPort": "8082",
|
||||
"disableAutoUpdate": true,
|
||||
"openDevTools": true
|
||||
}
|
||||
|
|
|
@ -182,8 +182,8 @@
|
|||
}
|
||||
|
||||
try {
|
||||
const swarmNodes = await window.LokiSnodeAPI.getFreshSwarmNodes(id);
|
||||
conversation.set({ swarmNodes});
|
||||
const swarmNodes = await window.LokiSnodeAPI.getFreshSwarmNodes(id);
|
||||
conversation.set({ swarmNodes });
|
||||
await window.Signal.Data.saveConversation(conversation.attributes, {
|
||||
Conversation: Whisper.Conversation,
|
||||
});
|
||||
|
|
|
@ -18,14 +18,12 @@
|
|||
}
|
||||
|
||||
async function sendOnlineBroadcastMessage(pubKey) {
|
||||
const onlineBroadcastMessage = new textsecure.protobuf.OnlineBroadcastMessage(
|
||||
{
|
||||
p2pAddress: 'testAddress',
|
||||
p2pPort: parseInt(window.localServerPort, 10),
|
||||
}
|
||||
);
|
||||
const lokiAddressMessage = new textsecure.protobuf.LokiAddressMessage({
|
||||
p2pAddress: 'testAddress',
|
||||
p2pPort: parseInt(window.localServerPort, 10),
|
||||
});
|
||||
const content = new textsecure.protobuf.Content({
|
||||
onlineBroadcastMessage,
|
||||
lokiAddressMessage,
|
||||
});
|
||||
|
||||
// will be called once the transmission succeeded or failed
|
||||
|
|
|
@ -712,16 +712,6 @@ MessageReceiver.prototype.extend({
|
|||
.then(this.unpad)
|
||||
.then(handleSessionReset);
|
||||
break;
|
||||
case textsecure.protobuf.Envelope.Type.ONLINE_BROADCAST:
|
||||
window.log.info(
|
||||
'Online broadcast message from',
|
||||
this.getEnvelopeId(envelope)
|
||||
);
|
||||
promise = captureActiveSession()
|
||||
.then(() => sessionCipher.decryptWhisperMessage(ciphertext))
|
||||
.then(this.unpad)
|
||||
.then(handleSessionReset);
|
||||
break;
|
||||
case textsecure.protobuf.Envelope.Type.FRIEND_REQUEST: {
|
||||
window.log.info('friend-request message from ', envelope.source);
|
||||
promise = fallBackSessionCipher
|
||||
|
@ -908,8 +898,8 @@ MessageReceiver.prototype.extend({
|
|||
})
|
||||
);
|
||||
},
|
||||
async handleOnlineBroadcastMessage(envelope, onlineBroadcastMessage) {
|
||||
const { p2pAddress, p2pPort } = onlineBroadcastMessage;
|
||||
async handleLokiAddressMessage(envelope, lokiAddressMessage) {
|
||||
const { p2pAddress, p2pPort } = lokiAddressMessage;
|
||||
window.LokiP2pAPI.addContactP2pDetails(
|
||||
envelope.source,
|
||||
p2pAddress,
|
||||
|
@ -1031,10 +1021,10 @@ MessageReceiver.prototype.extend({
|
|||
envelope.source,
|
||||
content.preKeyBundleMessage
|
||||
);
|
||||
if (content.onlineBroadcastMessage)
|
||||
return this.handleOnlineBroadcastMessage(
|
||||
if (content.lokiAddressMessage)
|
||||
return this.handleLokiAddressMessage(
|
||||
envelope,
|
||||
content.onlineBroadcastMessage
|
||||
content.lokiAddressMessage
|
||||
);
|
||||
if (content.syncMessage)
|
||||
return this.handleSyncMessage(envelope, content.syncMessage);
|
||||
|
|
|
@ -336,13 +336,19 @@ OutgoingMessage.prototype = {
|
|||
dcodeIO.ByteBuffer.wrap(ciphertext.body, 'binary').toArrayBuffer()
|
||||
);
|
||||
}
|
||||
const outgoingObjectType =
|
||||
this.messageType === 'onlineBroadcast'
|
||||
? textsecure.protobuf.Envelope.Type.ONLINE_BROADCAST
|
||||
: ciphertext.type; // FallBackSessionCipher sets this to FRIEND_REQUEST
|
||||
let ttl;
|
||||
if (this.messageType === 'friend-request') {
|
||||
ttl = 4 * 24 * 60 * 60; // 4 days for friend request message
|
||||
} else if (this.messageType === 'onlineBroadcast') {
|
||||
ttl = 10 * 60; // 10 minutes for online broadcast message
|
||||
} else {
|
||||
const hours = window.getMessageTTL() || 24; // 1 day default for any other message
|
||||
ttl = hours * 60 * 60;
|
||||
}
|
||||
|
||||
return {
|
||||
type: outgoingObjectType,
|
||||
type: ciphertext.type, // FallBackSessionCipher sets this to FRIEND_REQUEST
|
||||
ttl,
|
||||
ourKey,
|
||||
sourceDevice: 1,
|
||||
destinationRegistrationId: ciphertext.registrationId,
|
||||
|
@ -354,21 +360,12 @@ OutgoingMessage.prototype = {
|
|||
// TODO: handle multiple devices/messages per transmit
|
||||
const outgoingObject = outgoingObjects[0];
|
||||
const socketMessage = await this.wrapInWebsocketMessage(outgoingObject);
|
||||
let ttl;
|
||||
switch (outgoingObject.type) {
|
||||
case textsecure.protobuf.Envelope.Type.FRIEND_REQUEST:
|
||||
ttl = 4 * 24 * 60 * 60; // 4 days for friend request message
|
||||
break;
|
||||
case textsecure.protobuf.Envelope.Type.ONLINE_BROADCAST:
|
||||
ttl = 10 * 60; // 10 minutes for online broadcast message
|
||||
break;
|
||||
default: {
|
||||
const hours = window.getMessageTTL() || 24; // 1 day default for any other message
|
||||
ttl = hours * 60 * 60;
|
||||
break;
|
||||
}
|
||||
}
|
||||
await this.transmitMessage(number, socketMessage, this.timestamp, ttl);
|
||||
await this.transmitMessage(
|
||||
number,
|
||||
socketMessage,
|
||||
this.timestamp,
|
||||
outgoingObject.ttl
|
||||
);
|
||||
this.successfulNumbers[this.successfulNumbers.length] = number;
|
||||
this.numberCompleted();
|
||||
})
|
||||
|
|
|
@ -13,7 +13,6 @@ message Envelope {
|
|||
RECEIPT = 5;
|
||||
UNIDENTIFIED_SENDER = 6;
|
||||
FRIEND_REQUEST = 101; // contains prekeys + message and is using simple encryption
|
||||
ONLINE_BROADCAST = 102; // Contains address and port information for p2p messaging
|
||||
}
|
||||
|
||||
optional Type type = 1;
|
||||
|
@ -36,10 +35,10 @@ message Content {
|
|||
optional ReceiptMessage receiptMessage = 5;
|
||||
optional TypingMessage typingMessage = 6;
|
||||
optional PreKeyBundleMessage preKeyBundleMessage = 101;
|
||||
optional OnlineBroadcastMessage onlineBroadcastMessage = 102;
|
||||
optional LokiAddressMessage lokiAddressMessage = 102;
|
||||
}
|
||||
|
||||
message OnlineBroadcastMessage {
|
||||
message LokiAddressMessage {
|
||||
optional string p2pAddress = 1;
|
||||
optional uint32 p2pPort = 2;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue