serialize message as base64

pull/6/head
sachaaaaa 7 years ago
parent 1e14022e2f
commit 8ada6ce8ad

@ -29,7 +29,7 @@ function initialize({ url }) {
body = JSON.stringify({
pub_key: options.pub_key,
message: String.fromCharCode.apply(null, options.data),
message: options.data,
ttl: options.ttl,
})

@ -308,40 +308,45 @@ OutgoingMessage.prototype = {
},
sendToNumber(number) {
const options = {
pub_key: number,
data: this.getPlaintext(),
ttl: 2 * 24 * 60 * 60
};
return this.lokiserver.sendMessage(options).then(
(result, status) => {
this.successfulNumbers[this.successfulNumbers.length] = number;
this.numberCompleted();
},
(error) => console.log('Loki sendMessage failed')
);
/*
return this.getStaleDeviceIdsForNumber(number).then(updateDevices =>
this.getKeysForNumber(number, updateDevices)
.then(this.reloadDevicesAndSend(number, true))
.catch(error => {
if (error.message === 'Identity key changed') {
// eslint-disable-next-line no-param-reassign
error = new textsecure.OutgoingIdentityKeyError(
number,
error.originalMessage,
error.timestamp,
error.identityKey
);
this.registerError(number, 'Identity key changed', error);
} else {
this.registerError(
number,
`Failed to retrieve new device keys for number ${number}`,
error
);
}
})
);*/
if (true /* skipEncryption */)
{
const options = {
pub_key: number,
data: StringView.bytesToBase64(this.getPlaintext()),
ttl: 2 * 24 * 60 * 60
};
return this.lokiserver.sendMessage(options).then(
(result, status) => {
this.successfulNumbers[this.successfulNumbers.length] = number;
this.numberCompleted();
},
(error) => console.log('Loki sendMessage failed')
);
}
else
{
return this.getStaleDeviceIdsForNumber(number).then(updateDevices =>
this.getKeysForNumber(number, updateDevices)
.then(this.reloadDevicesAndSend(number, true))
.catch(error => {
if (error.message === 'Identity key changed') {
// eslint-disable-next-line no-param-reassign
error = new textsecure.OutgoingIdentityKeyError(
number,
error.originalMessage,
error.timestamp,
error.identityKey
);
this.registerError(number, 'Identity key changed', error);
} else {
this.registerError(
number,
`Failed to retrieve new device keys for number ${number}`,
error
);
}
})
);
}
},
};

@ -134,7 +134,6 @@ function prepareURL(pathSegments, moreKeys) {
serverUrl: config.get('serverUrl'),
cdnUrl: config.get('cdnUrl'),
certificateAuthority: config.get('certificateAuthority'),
skipEncryption: config.get('skipEncryption'),
environment: config.environment,
node_version: process.versions.node,
hostname: os.hostname(),

Loading…
Cancel
Save