fix attachment upload for opengroupv1 and old file server

This commit is contained in:
Audric Ackermann 2021-04-30 11:37:28 +10:00
parent 710c9fa269
commit ad26e50de1
No known key found for this signature in database
GPG key ID: 999F434D76324AD4
6 changed files with 9 additions and 20 deletions

View file

@ -126,10 +126,9 @@
// If already exists we registered as a secondary device
if (!window.lokiFileServerAPI) {
window.lokiFileServerAPIFactory = new window.LokiFileServerAPI(ourKey);
// FIXME audric
// window.lokiFileServerAPI = window.lokiFileServerAPIFactory.establishHomeConnection(
// window.getDefaultFileServer()
// );
window.lokiFileServerAPI = window.lokiFileServerAPIFactory.establishHomeConnection(
window.getDefaultFileServer()
);
}
window.initialisedAPI = true;

View file

@ -381,7 +381,7 @@ class LokiAppDotNetServerAPI {
return OnionSend.serverRequest(`${this.baseServerUrl}/${endpoint}`, {
...options,
token: this.token,
srvPubKey: this.pubKey,
srvPubKey: this.pubKeyHex,
});
}

View file

@ -104,17 +104,6 @@ export const parseMessages = async (
return _.compact(messages);
};
// 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 defaultServerPublicKey = 'a03c383cf63c3c4efe67acc52112a6dd734b3a946b9545f488aaa93da7991238';
const defaultRoom = `${defaultServerUrl}/main?public_key=${defaultServerPublicKey}`;

View file

@ -1,6 +1,7 @@
import { default as insecureNodeFetch } from 'node-fetch';
import { OpenGroupV2Room } from '../../data/opengroups';
import { sendViaOnion } from '../../session/onions/onionSend';
import { toHex } from '../../session/utils/String';
import { OpenGroupRequestCommonType } from '../opengroupV2/ApiUtil';
const protocolRegex = new RegExp('(https?://)?');
@ -131,9 +132,10 @@ export const validOpenGroupServer = async (serverUrl: string) => {
// decode it.
const obj = JSON.parse(result.response.data);
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
// 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) {
window.log.info(
`loki_public_chat::validOpenGroupServer - onion routing enabled on ${url.toString()}`

View file

@ -95,7 +95,7 @@ const buildSendViaOnionPayload = (url: URL, fetchOptions: OnionFetchOptions) =>
) {
const fData = payloadObj.body.getBuffer();
const fHeaders = payloadObj.body.getHeaders();
tempHeaders = { ...tempHeaders, fHeaders };
tempHeaders = { ...tempHeaders, ...fHeaders };
// update headers for boundary
// update body with base64 chunk
payloadObj.body = {

View file

@ -53,8 +53,7 @@ export class SwarmPolling {
public start(): void {
this.loadGroupIds();
// FIXME audric
// void this.pollForAllKeys();
void this.pollForAllKeys();
}
public addGroupId(pubkey: PubKey) {