ensure promises can be collected
This commit is contained in:
parent
35045bb69a
commit
a08fed1add
@ -4166,14 +4166,16 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
|||||||
*
|
*
|
||||||
* @name PasteDecrypter.decryptPaste
|
* @name PasteDecrypter.decryptPaste
|
||||||
* @private
|
* @private
|
||||||
|
* @async
|
||||||
* @function
|
* @function
|
||||||
* @param {object} paste - paste data in object form
|
* @param {object} paste - paste data in object form
|
||||||
* @param {string} key
|
* @param {string} key
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
* @param {bool} ignoreError - ignore decryption errors iof set to true
|
* @param {bool} ignoreError - ignore decryption errors iof set to true
|
||||||
* @throws {string}
|
* @throws {string}
|
||||||
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
function decryptPaste(paste, key, password, ignoreError)
|
async function decryptPaste(paste, key, password, ignoreError)
|
||||||
{
|
{
|
||||||
let decyptionPromise;
|
let decyptionPromise;
|
||||||
if (ignoreError === true) {
|
if (ignoreError === true) {
|
||||||
@ -4182,7 +4184,7 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
|||||||
decyptionPromise = decryptOrPromptPassword(key, password, paste.data);
|
decyptionPromise = decryptOrPromptPassword(key, password, paste.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
decyptionPromise.then((plaintext) => {
|
return decyptionPromise.then((plaintext) => {
|
||||||
if (plaintext !== false) {
|
if (plaintext !== false) {
|
||||||
// on success show paste
|
// on success show paste
|
||||||
PasteViewer.setFormat(paste.meta.formatter);
|
PasteViewer.setFormat(paste.meta.formatter);
|
||||||
@ -4200,13 +4202,15 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
|||||||
*
|
*
|
||||||
* @name PasteDecrypter.decryptAttachment
|
* @name PasteDecrypter.decryptAttachment
|
||||||
* @private
|
* @private
|
||||||
|
* @async
|
||||||
* @function
|
* @function
|
||||||
* @param {object} paste - paste data in object form
|
* @param {object} paste - paste data in object form
|
||||||
* @param {string} key
|
* @param {string} key
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
* @throws {string}
|
* @throws {string}
|
||||||
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
function decryptAttachment(paste, key, password)
|
async function decryptAttachment(paste, key, password)
|
||||||
{
|
{
|
||||||
let attachmentPromise = decryptOrPromptPassword(key, password, paste.attachment);
|
let attachmentPromise = decryptOrPromptPassword(key, password, paste.attachment);
|
||||||
let attachmentNamePromise = decryptOrPromptPassword(key, password, paste.attachmentname);
|
let attachmentNamePromise = decryptOrPromptPassword(key, password, paste.attachmentname);
|
||||||
@ -4216,7 +4220,7 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
|||||||
attachmentNamePromise.catch((err) => {
|
attachmentNamePromise.catch((err) => {
|
||||||
displayDecryptionError('failed to decipher attachment name: ' + err);
|
displayDecryptionError('failed to decipher attachment name: ' + err);
|
||||||
})
|
})
|
||||||
Promise.all([attachmentPromise, attachmentNamePromise]).then((results) => {
|
return Promise.all([attachmentPromise, attachmentNamePromise]).then((results) => {
|
||||||
if (!results.some((result) => {
|
if (!results.some((result) => {
|
||||||
return result === false;
|
return result === false;
|
||||||
})) {
|
})) {
|
||||||
@ -4231,12 +4235,14 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
|||||||
*
|
*
|
||||||
* @name PasteDecrypter.decryptComments
|
* @name PasteDecrypter.decryptComments
|
||||||
* @private
|
* @private
|
||||||
|
* @async
|
||||||
* @function
|
* @function
|
||||||
* @param {object} paste - paste data in object form
|
* @param {object} paste - paste data in object form
|
||||||
* @param {string} key
|
* @param {string} key
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
function decryptComments(paste, key, password)
|
async function decryptComments(paste, key, password)
|
||||||
{
|
{
|
||||||
// remove potential previous discussion
|
// remove potential previous discussion
|
||||||
DiscussionViewer.prepareNewDiscussion();
|
DiscussionViewer.prepareNewDiscussion();
|
||||||
@ -4248,7 +4254,7 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
|||||||
CryptTool.decipher(key, password, paste.comments[i].data)
|
CryptTool.decipher(key, password, paste.comments[i].data)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Promise.all(commentDecryptionPromises).then((plaintexts) => {
|
return Promise.all(commentDecryptionPromises).then((plaintexts) => {
|
||||||
for (var i = 0; i < paste.comments.length; ++i) {
|
for (var i = 0; i < paste.comments.length; ++i) {
|
||||||
if (plaintexts[i] === false) {
|
if (plaintexts[i] === false) {
|
||||||
continue;
|
continue;
|
||||||
@ -4333,7 +4339,7 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
|||||||
|
|
||||||
// if the discussion is opened on this paste, display it
|
// if the discussion is opened on this paste, display it
|
||||||
if (paste.meta.opendiscussion) {
|
if (paste.meta.opendiscussion) {
|
||||||
decrytionPromises(decryptComments(paste, key, password));
|
decrytionPromises.push(decryptComments(paste, key, password));
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.all(decrytionPromises).then(() => {
|
Promise.all(decrytionPromises).then(() => {
|
||||||
|
@ -71,7 +71,7 @@ if ($MARKDOWN):
|
|||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-QoyJMD+9as5QQUHm4/mdiFvqHA5VvFqo+N5pn1xNFA6t5bpxS8dI1HwkFbgTQjp/cJrGqTXQ6tDDAiUixiGXNQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-d/XW7mxDbNK7y+vSpp547tr+HCKuf83N924B31rvy5RYwa2i0CDcLRDo1WZ2HRfqJT0Go52ksqifS2BYieKB+Q==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
@ -49,7 +49,7 @@ if ($MARKDOWN):
|
|||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-QoyJMD+9as5QQUHm4/mdiFvqHA5VvFqo+N5pn1xNFA6t5bpxS8dI1HwkFbgTQjp/cJrGqTXQ6tDDAiUixiGXNQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-d/XW7mxDbNK7y+vSpp547tr+HCKuf83N924B31rvy5RYwa2i0CDcLRDo1WZ2HRfqJT0Go52ksqifS2BYieKB+Q==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
Loading…
Reference in New Issue
Block a user