attemptConnection-complete

pull/1225/head
Vincent 5 years ago
parent baf3050b1d
commit 4a13b1e6bb

@ -1092,12 +1092,22 @@
// Attempts a connection to an open group server
window.attemptConnection = async (serverURL, channelId) => {
let rawserverURL = serverURL
let completeServerURL = serverURL.toLowerCase();
const valid = window.libsession.Types.OpenGroup.validate(completeServerURL);
if (!valid) {
return new Promise((_resolve, reject) => {
reject(window.i18n('connectToServerFail'));
});
}
// Add http or https prefix to server
completeServerURL = window.libsession.Types.OpenGroup.prefixify(completeServerURL);
const rawServerURL = serverURL
.replace(/^https?:\/\//i, '')
.replace(/[/\\]+$/i, '');
rawserverURL = rawserverURL.toLowerCase();
const sslServerURL = `https://${rawserverURL}`;
const conversationId = `publicChat:${channelId}@${rawserverURL}`;
const conversationId = `publicChat:${channelId}@${rawServerURL}`;
// Quickly peak to make sure we don't already have it
const conversationExists = window.ConversationController.get(
@ -1112,7 +1122,7 @@
// Get server
const serverAPI = await window.lokiPublicChatAPI.findOrCreateServer(
sslServerURL
completeServerURL
);
// SSL certificate failure or offline
if (!serverAPI) {
@ -1129,7 +1139,7 @@
);
// Convert conversation to a public one
await conversation.setPublicSource(sslServerURL, channelId);
await conversation.setPublicSource(completeServerURL, channelId);
// and finally activate it
conversation.getPublicSendData(); // may want "await" if you want to use the API

@ -1,4 +1,3 @@
interface OpenGroupParams {
server: string;
channel: number;

@ -137,7 +137,8 @@ export const _getLeftPaneLists = (
};
}
// Remove all invalid conversations and conversatons of devices associated with cancelled attempted links
// Remove all invalid conversations and conversatons of devices associated
// with cancelled attempted links
if (!conversation.isPublic && !conversation.timestamp) {
continue;
}

Loading…
Cancel
Save