|
|
|
@ -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
|
|
|
|
|