mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-10-23 03:31:56 +00:00
validate zulip server in pref window
This commit is contained in:
@@ -6,10 +6,10 @@
|
||||
const data = db.getData("/");
|
||||
|
||||
if (data["domain"] !== undefined) {
|
||||
window.location.href = 'https://' + data["domain"];
|
||||
window.location.href = data["domain"];
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
dialogs.prompt('Enter the URL for your Zulip server', function(url) {
|
||||
|
||||
let newurl = 'https://' + url.replace(/^https?:\/\//,'')
|
||||
|
@@ -8,6 +8,7 @@ document.getElementById('close-button').addEventListener('click', function (e) {
|
||||
|
||||
function addDomain() {
|
||||
|
||||
const request = require('request');
|
||||
const ipcRenderer = require('electron').ipcRenderer;
|
||||
const JsonDB = require('node-json-db');
|
||||
const db = new JsonDB('domain', true, true);
|
||||
@@ -16,8 +17,18 @@ function addDomain() {
|
||||
newDomain = newDomain.replace(/^https?:\/\//,'')
|
||||
|
||||
const domain = 'https://' + newDomain;
|
||||
const checkDomain = domain + '/static/audio/zulip.ogg';
|
||||
|
||||
request(checkDomain, function (error, response, body) {
|
||||
if (!error && response.statusCode !== 404) {
|
||||
document.getElementById('urladded').innerHTML = newDomain + ' Added';
|
||||
db.push('/domain', newDomain);
|
||||
ipcRenderer.send('new-domain', domain);
|
||||
}
|
||||
else{
|
||||
document.getElementById('urladded').innerHTML = "Not a vaild Zulip server";
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
document.getElementById('urladded').innerHTML = newDomain + ' Added';
|
||||
db.push('/domain', newDomain);
|
||||
ipcRenderer.send('new-domain', domain);
|
||||
}
|
||||
|
Reference in New Issue
Block a user