Fix issues with templates in polls #375
This commit is contained in:
parent
de3bb5cdcf
commit
3be85b155d
@ -719,7 +719,8 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sframeChan.query('Q_SAVE_AS_TEMPLATE', {
|
sframeChan.query('Q_SAVE_AS_TEMPLATE', {
|
||||||
toSave: toSave
|
toSave: toSave,
|
||||||
|
title: title
|
||||||
}, function () {
|
}, function () {
|
||||||
UI.alert(Messages.templateSaved);
|
UI.alert(Messages.templateSaved);
|
||||||
Feedback.send('TEMPLATE_CREATED');
|
Feedback.send('TEMPLATE_CREATED');
|
||||||
|
|||||||
@ -28,9 +28,9 @@ define([
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var makeConfig = function (hash, password) {
|
var makeConfig = function (hash, opt) {
|
||||||
// We can't use cryptget with a file or a user so we can use 'pad' as hash type
|
// We can't use cryptget with a file or a user so we can use 'pad' as hash type
|
||||||
var secret = Hash.getSecrets('pad', hash, password);
|
var secret = Hash.getSecrets('pad', hash, opt.password);
|
||||||
if (!secret.keys) { secret.keys = secret.key; } // support old hashses
|
if (!secret.keys) { secret.keys = secret.key; } // support old hashses
|
||||||
var config = {
|
var config = {
|
||||||
websocketURL: NetConfig.getWebsocketURL(),
|
websocketURL: NetConfig.getWebsocketURL(),
|
||||||
@ -38,6 +38,7 @@ define([
|
|||||||
validateKey: secret.keys.validateKey || undefined,
|
validateKey: secret.keys.validateKey || undefined,
|
||||||
crypto: Crypto.createEncryptor(secret.keys),
|
crypto: Crypto.createEncryptor(secret.keys),
|
||||||
logLevel: 0,
|
logLevel: 0,
|
||||||
|
initialState: opt.initialState
|
||||||
};
|
};
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
@ -57,7 +58,7 @@ define([
|
|||||||
}
|
}
|
||||||
opt = opt || {};
|
opt = opt || {};
|
||||||
|
|
||||||
var config = makeConfig(hash, opt.password);
|
var config = makeConfig(hash, opt);
|
||||||
var Session = { cb: cb, hasNetwork: Boolean(opt.network) };
|
var Session = { cb: cb, hasNetwork: Boolean(opt.network) };
|
||||||
|
|
||||||
config.onReady = function (info) {
|
config.onReady = function (info) {
|
||||||
@ -82,7 +83,7 @@ define([
|
|||||||
}
|
}
|
||||||
opt = opt || {};
|
opt = opt || {};
|
||||||
|
|
||||||
var config = makeConfig(hash, opt.password);
|
var config = makeConfig(hash, opt);
|
||||||
var Session = { cb: cb, };
|
var Session = { cb: cb, };
|
||||||
|
|
||||||
config.onReady = function (info) {
|
config.onReady = function (info) {
|
||||||
|
|||||||
@ -512,6 +512,10 @@ define([
|
|||||||
|
|
||||||
optsPut = optsPut || {};
|
optsPut = optsPut || {};
|
||||||
var optsGet = {};
|
var optsGet = {};
|
||||||
|
|
||||||
|
if (parsed.type === 'poll') { optsGet.initialState = '{}'; }
|
||||||
|
if (parsed2.type === 'poll') { optsPut.initialState = '{}'; }
|
||||||
|
|
||||||
Nthen(function (waitFor) {
|
Nthen(function (waitFor) {
|
||||||
if (parsed.hashData && parsed.hashData.password) {
|
if (parsed.hashData && parsed.hashData.password) {
|
||||||
common.getPadAttribute('password', waitFor(function (err, password) {
|
common.getPadAttribute('password', waitFor(function (err, password) {
|
||||||
|
|||||||
@ -479,10 +479,11 @@ define([
|
|||||||
|
|
||||||
Store.addPad = function (clientId, data, cb) {
|
Store.addPad = function (clientId, data, cb) {
|
||||||
if (!data.href && !data.roHref) { return void cb({error:'NO_HREF'}); }
|
if (!data.href && !data.roHref) { return void cb({error:'NO_HREF'}); }
|
||||||
|
var secret;
|
||||||
if (!data.roHref) {
|
if (!data.roHref) {
|
||||||
var parsed = Hash.parsePadUrl(data.href);
|
var parsed = Hash.parsePadUrl(data.href);
|
||||||
if (parsed.hashData.type === "pad") {
|
if (parsed.hashData.type === "pad") {
|
||||||
var secret = Hash.getSecrets(parsed.type, parsed.hash, data.password);
|
secret = Hash.getSecrets(parsed.type, parsed.hash, data.password);
|
||||||
data.roHref = '/' + parsed.type + '/#' + Hash.getViewHashFromKeys(secret);
|
data.roHref = '/' + parsed.type + '/#' + Hash.getViewHashFromKeys(secret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -490,7 +491,7 @@ define([
|
|||||||
if (data.owners) { pad.owners = data.owners; }
|
if (data.owners) { pad.owners = data.owners; }
|
||||||
if (data.expire) { pad.expire = data.expire; }
|
if (data.expire) { pad.expire = data.expire; }
|
||||||
if (data.password) { pad.password = data.password; }
|
if (data.password) { pad.password = data.password; }
|
||||||
if (data.channel) { pad.channel = data.channel; }
|
if (data.channel || secret) { pad.channel = data.channel || secret.channel; }
|
||||||
store.manager.addPad(data.path, pad, function (e) {
|
store.manager.addPad(data.path, pad, function (e) {
|
||||||
if (e) { return void cb({error: e}); }
|
if (e) { return void cb({error: e}); }
|
||||||
sendDriveEvent('DRIVE_CHANGE', {
|
sendDriveEvent('DRIVE_CHANGE', {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user