mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
fix attachment upload for opengroupv1 and old file server
This commit is contained in:
parent
710c9fa269
commit
ad26e50de1
6 changed files with 9 additions and 20 deletions
|
@ -126,10 +126,9 @@
|
||||||
// If already exists we registered as a secondary device
|
// If already exists we registered as a secondary device
|
||||||
if (!window.lokiFileServerAPI) {
|
if (!window.lokiFileServerAPI) {
|
||||||
window.lokiFileServerAPIFactory = new window.LokiFileServerAPI(ourKey);
|
window.lokiFileServerAPIFactory = new window.LokiFileServerAPI(ourKey);
|
||||||
// FIXME audric
|
window.lokiFileServerAPI = window.lokiFileServerAPIFactory.establishHomeConnection(
|
||||||
// window.lokiFileServerAPI = window.lokiFileServerAPIFactory.establishHomeConnection(
|
window.getDefaultFileServer()
|
||||||
// window.getDefaultFileServer()
|
);
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.initialisedAPI = true;
|
window.initialisedAPI = true;
|
||||||
|
|
|
@ -381,7 +381,7 @@ class LokiAppDotNetServerAPI {
|
||||||
return OnionSend.serverRequest(`${this.baseServerUrl}/${endpoint}`, {
|
return OnionSend.serverRequest(`${this.baseServerUrl}/${endpoint}`, {
|
||||||
...options,
|
...options,
|
||||||
token: this.token,
|
token: this.token,
|
||||||
srvPubKey: this.pubKey,
|
srvPubKey: this.pubKeyHex,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,17 +104,6 @@ export const parseMessages = async (
|
||||||
return _.compact(messages);
|
return _.compact(messages);
|
||||||
};
|
};
|
||||||
// tslint:disable: no-http-string
|
// tslint:disable: no-http-string
|
||||||
|
|
||||||
// FIXME audric change this to
|
|
||||||
// const defaultRoom =
|
|
||||||
// 'https://opengroup.bilb.us/main?public_key=1352534ba73d4265973280431dbc72e097a3e43275d1ada984f9805b4943047d';
|
|
||||||
|
|
||||||
// const defaultRoom =
|
|
||||||
// 'http://opengroup.bilb.us:9861/main?public_key=1352534ba73d4265973280431dbc72e097a3e43275d1ada984f9805b4943047d';
|
|
||||||
|
|
||||||
// const defaultRoom =
|
|
||||||
// 'https://sog.ibolpap.finance/main?public_key=b464aa186530c97d6bcf663a3a3b7465a5f782beaa67c83bee99468824b4aa10';
|
|
||||||
|
|
||||||
const defaultServerUrl = 'http://116.203.70.33';
|
const defaultServerUrl = 'http://116.203.70.33';
|
||||||
const defaultServerPublicKey = 'a03c383cf63c3c4efe67acc52112a6dd734b3a946b9545f488aaa93da7991238';
|
const defaultServerPublicKey = 'a03c383cf63c3c4efe67acc52112a6dd734b3a946b9545f488aaa93da7991238';
|
||||||
const defaultRoom = `${defaultServerUrl}/main?public_key=${defaultServerPublicKey}`;
|
const defaultRoom = `${defaultServerUrl}/main?public_key=${defaultServerPublicKey}`;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { default as insecureNodeFetch } from 'node-fetch';
|
import { default as insecureNodeFetch } from 'node-fetch';
|
||||||
import { OpenGroupV2Room } from '../../data/opengroups';
|
import { OpenGroupV2Room } from '../../data/opengroups';
|
||||||
import { sendViaOnion } from '../../session/onions/onionSend';
|
import { sendViaOnion } from '../../session/onions/onionSend';
|
||||||
|
import { toHex } from '../../session/utils/String';
|
||||||
import { OpenGroupRequestCommonType } from '../opengroupV2/ApiUtil';
|
import { OpenGroupRequestCommonType } from '../opengroupV2/ApiUtil';
|
||||||
|
|
||||||
const protocolRegex = new RegExp('(https?://)?');
|
const protocolRegex = new RegExp('(https?://)?');
|
||||||
|
@ -131,9 +132,10 @@ export const validOpenGroupServer = async (serverUrl: string) => {
|
||||||
// decode it.
|
// decode it.
|
||||||
const obj = JSON.parse(result.response.data);
|
const obj = JSON.parse(result.response.data);
|
||||||
const pubKey = window.dcodeIO.ByteBuffer.wrap(obj.data, 'base64').toArrayBuffer();
|
const pubKey = window.dcodeIO.ByteBuffer.wrap(obj.data, 'base64').toArrayBuffer();
|
||||||
|
const pubKeyHex = toHex(pubKey);
|
||||||
// verify we can make an onion routed call to that open group with the decoded public key
|
// verify we can make an onion routed call to that open group with the decoded public key
|
||||||
// get around the FILESERVER_HOSTS filter by not using serverRequest
|
// get around the FILESERVER_HOSTS filter by not using serverRequest
|
||||||
const res = await sendViaOnion(pubKey, url, { method: 'GET' }, { noJson: true });
|
const res = await sendViaOnion(pubKeyHex, url, { method: 'GET' }, { noJson: true });
|
||||||
if (res && res.result && res.result.status === 200) {
|
if (res && res.result && res.result.status === 200) {
|
||||||
window.log.info(
|
window.log.info(
|
||||||
`loki_public_chat::validOpenGroupServer - onion routing enabled on ${url.toString()}`
|
`loki_public_chat::validOpenGroupServer - onion routing enabled on ${url.toString()}`
|
||||||
|
|
|
@ -95,7 +95,7 @@ const buildSendViaOnionPayload = (url: URL, fetchOptions: OnionFetchOptions) =>
|
||||||
) {
|
) {
|
||||||
const fData = payloadObj.body.getBuffer();
|
const fData = payloadObj.body.getBuffer();
|
||||||
const fHeaders = payloadObj.body.getHeaders();
|
const fHeaders = payloadObj.body.getHeaders();
|
||||||
tempHeaders = { ...tempHeaders, fHeaders };
|
tempHeaders = { ...tempHeaders, ...fHeaders };
|
||||||
// update headers for boundary
|
// update headers for boundary
|
||||||
// update body with base64 chunk
|
// update body with base64 chunk
|
||||||
payloadObj.body = {
|
payloadObj.body = {
|
||||||
|
|
|
@ -53,8 +53,7 @@ export class SwarmPolling {
|
||||||
|
|
||||||
public start(): void {
|
public start(): void {
|
||||||
this.loadGroupIds();
|
this.loadGroupIds();
|
||||||
// FIXME audric
|
void this.pollForAllKeys();
|
||||||
// void this.pollForAllKeys();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public addGroupId(pubkey: PubKey) {
|
public addGroupId(pubkey: PubKey) {
|
||||||
|
|
Loading…
Reference in a new issue