Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging
commit
b910915d47
|
@ -116,11 +116,46 @@ module.exports = {
|
|||
'contact',
|
||||
],
|
||||
|
||||
/* Domain
|
||||
* If you want to have enable payments on your CryptPad instance, it has to be able to tell
|
||||
* our account server what is your domain
|
||||
/* Limits, Subscriptions and Contact
|
||||
*
|
||||
* CryptPad limits every registered user to 50MB of storage.
|
||||
* By default it also allows that limit to be increased by subscribing at accounts.cryptpad.fr
|
||||
* You can either:
|
||||
* A: Hide the button for subscribing, so everyone is limited to 50MB
|
||||
* B: Support cryptpad and share 50% of the revenue earned on your instance
|
||||
*
|
||||
* CryptPad is developed by people who need to live and who deserve an equivilent life to
|
||||
* what they would get at a company which monitizes user data. However, we intend to have
|
||||
* a mutually positive relationship with every one of our users, including you. If you are
|
||||
* getting value from CryptPad, you should be giving equal value back.
|
||||
*
|
||||
* If you are using CryptPad in a business context, please consider taking a support contract
|
||||
* by contacting sales@cryptpad.fr
|
||||
*
|
||||
* If you choose A, set this variable to true to hide the subscription button.
|
||||
*/
|
||||
// domain: 'https://cryptpad.fr',
|
||||
noSubscriptionButton: false,
|
||||
/*
|
||||
* If you choose B, set the domain of your cryptpad instance here and then contact
|
||||
* sales@cryptpad.fr and tell us your domain, we will tell you what is needed to get paid.
|
||||
*/
|
||||
myDomain: 'i.did.not.read.my.config.cryptpad.myserver.tld',
|
||||
/*
|
||||
* If you are using CryptPad internally and you want to increase the per-user storage limit,
|
||||
* change the following value.
|
||||
* Please note: Providing a public offer that is better than cryptpad.fr is an attack on
|
||||
* the project. Please leave this alone if you are providing a public service.
|
||||
*/
|
||||
defaultStorageLimit: 50 * 1024 * 1024,
|
||||
/*
|
||||
* By default, CryptPad contacts our accounts server once a day to check for changes in the
|
||||
* people who have accounts. This check-in will also send your email and the version of
|
||||
* CryptPad you run so we can reach you if we are aware of a serious problem with your
|
||||
* CryptPad instance. We will never sell it or use it for marketing. If you want to block this
|
||||
* check-in and remain completely private, set this to false and noSubscriptionButton to true.
|
||||
*/
|
||||
adminEmail: 'i.did.not.read.my.config@cryptpad.fr',
|
||||
|
||||
|
||||
/*
|
||||
You have the option of specifying an alternative storage adaptor.
|
||||
|
@ -211,12 +246,6 @@ module.exports = {
|
|||
*/
|
||||
//restrictUploads: false,
|
||||
|
||||
/* Default user storage limit (bytes)
|
||||
* if you don't want to limit users,
|
||||
* you can set this to the size of your hard disk
|
||||
*/
|
||||
defaultStorageLimit: 50 * 1024 * 1024,
|
||||
|
||||
/* Max Upload Size (bytes)
|
||||
* this sets the maximum size of any one file uploaded to the server.
|
||||
* anything larger than this size will be rejected
|
||||
|
|
|
@ -37,8 +37,6 @@ define(function() {
|
|||
|
||||
config.enableHistory = true;
|
||||
|
||||
config.enablePinLimit = true;
|
||||
|
||||
/* user passwords are hashed with scrypt, and salted with their username.
|
||||
this value will be appended to the username, causing the resulting hash
|
||||
to differ from other CryptPad instances if customized. This makes it
|
||||
|
|
|
@ -78,6 +78,7 @@ define(function () {
|
|||
out.updated_0_pinLimitReachedAlert = "You've reached your storage limit. New pads won't be stored in your CryptDrive.<br>" +
|
||||
'You can either remove pads from your CryptDrive or <a href="https://accounts.cryptpad.fr/#!on={0}" target="_blank">subscribe to a premium offer</a> to increase your limit.';
|
||||
out.pinLimitReachedAlert = out.updated_0_pinLimitReachedAlert;
|
||||
out.pinLimitReachedAlertNoAccounts = out.pinLimitReached;
|
||||
out.pinAboveLimitAlert = 'As of this release, we are imposing a 50MB limit on free data storage and you are currently using {0}. You will need to either delete some pads or subscribe on <a href="https://accounts.cryptpad.fr/#!on={1}" target="_blank">accounts.cryptpad.fr</a>. Your contribution will help us improve CryptPad and spread Zero Knowledge. Please contact <a href="https://accounts.cryptpad.fr/#/support" target="_blank">support</a> if you have any other questions.';
|
||||
out.pinLimitNotPinned = "You've reached your storage limit.<br>"+
|
||||
"This pad is not stored in your CryptDrive.";
|
||||
|
|
9
rpc.js
9
rpc.js
|
@ -1,4 +1,5 @@
|
|||
/*@flow*/
|
||||
/*jshint esversion: 6 */
|
||||
/* Use Nacl for checking signatures of messages */
|
||||
var Nacl = require("tweetnacl");
|
||||
|
||||
|
@ -8,6 +9,7 @@ var Nacl = require("tweetnacl");
|
|||
var Fs = require("fs");
|
||||
var Path = require("path");
|
||||
var Https = require("https");
|
||||
const Package = require('./package.json');
|
||||
|
||||
var RPC = module.exports;
|
||||
|
||||
|
@ -371,6 +373,7 @@ var getHash = function (Env, publicKey, cb) {
|
|||
// To each key is associated an object containing the 'limit' value and a 'note' explaining that limit
|
||||
var limits = {};
|
||||
var updateLimits = function (config, publicKey, cb) {
|
||||
if (config.adminEmail === false && config.noSubscriptionButton === true) { return; }
|
||||
if (typeof cb !== "function") { cb = function () {}; }
|
||||
|
||||
var defaultLimit = typeof(config.defaultStorageLimit) === 'number'?
|
||||
|
@ -382,8 +385,10 @@ var updateLimits = function (config, publicKey, cb) {
|
|||
}
|
||||
|
||||
var body = JSON.stringify({
|
||||
domain: config.domain,
|
||||
subdomain: config.subdomain
|
||||
domain: config.myDomain,
|
||||
subdomain: config.mySubdomain,
|
||||
adminEmail: config.adminEmail,
|
||||
version: Package.version
|
||||
});
|
||||
var options = {
|
||||
host: 'accounts.cryptpad.fr',
|
||||
|
|
|
@ -121,6 +121,7 @@ app.get('/api/config', function(req, res){
|
|||
waitSeconds: 60,
|
||||
urlArgs: 'ver=' + Package.version + (DEV_MODE? '-' + (+new Date()): ''),
|
||||
},
|
||||
noSubscriptionButton: (config.noSubscriptionButton === true),
|
||||
websocketPath: config.useExternalWebsocket ? undefined : config.websocketPath,
|
||||
websocketURL:'ws' + ((useSecureWebsockets) ? 's' : '') + '://' + host + ':' +
|
||||
websocketPort + '/cryptpad_websocket',
|
||||
|
|
|
@ -599,7 +599,7 @@ define([
|
|||
var data = makePad(href, name);
|
||||
getStore().pushData(data, function (e) {
|
||||
if (e) {
|
||||
if (e === 'E_OVER_LIMIT' && AppConfig.enablePinLimit) {
|
||||
if (e === 'E_OVER_LIMIT') {
|
||||
common.alert(Messages.pinLimitNotPinned, null, true);
|
||||
return;
|
||||
}
|
||||
|
@ -761,7 +761,7 @@ define([
|
|||
};
|
||||
|
||||
common.isOverPinLimit = function (cb) {
|
||||
if (!common.isLoggedIn() || !AppConfig.enablePinLimit) { return void cb(null, false); }
|
||||
if (!common.isLoggedIn()) { return void cb(null, false); }
|
||||
var usage;
|
||||
var andThen = function (e, limit, plan) {
|
||||
if (e) { return void cb(e); }
|
||||
|
@ -817,7 +817,10 @@ define([
|
|||
var width = Math.floor(Math.min(quota, 1)*200); // the bar is 200px width
|
||||
var $usage = $('<span>', {'class': 'usage'}).css('width', width+'px');
|
||||
|
||||
if ((quota >= 0.8 || alwaysDisplayUpgrade) && data.plan !== "power") {
|
||||
if (Config.noSubscriptionButton !== true &&
|
||||
(quota >= 0.8 || alwaysDisplayUpgrade) &&
|
||||
data.plan !== "power")
|
||||
{
|
||||
var origin = encodeURIComponent(window.location.hostname);
|
||||
var $upgradeLink = $('<a>', {
|
||||
href: "https://accounts.cryptpad.fr/#!on=" + origin,
|
||||
|
@ -845,7 +848,7 @@ define([
|
|||
else if (quota < 1) { $usage.addClass('warning'); }
|
||||
else {
|
||||
$usage.addClass('above');
|
||||
if (!limitReachedDisplayed) {
|
||||
if (!limitReachedDisplayed && Config.noSubscriptionButton === true) {
|
||||
limitReachedDisplayed = true;
|
||||
common.alert(Messages._getKey('pinAboveLimitAlert', [prettyUsage, encodeURIComponent(window.location.hostname)]), null, true);
|
||||
}
|
||||
|
|
|
@ -500,8 +500,12 @@ define([
|
|||
var todo = function (e, overLimit) {
|
||||
if (e) { return void console.error("Unable to get the pinned usage"); }
|
||||
if (overLimit) {
|
||||
var message = Messages.pinLimitReachedAlert;
|
||||
if (ApiConfig.noSubscriptionButton === true) {
|
||||
message = Messages.pinLimitReachedAlertNoAccounts;
|
||||
}
|
||||
$limit.show().click(function () {
|
||||
Cryptpad.alert(Messages.pinLimitReachedAlert, null, true);
|
||||
Cryptpad.alert(message, null, true);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -616,8 +616,12 @@ define([
|
|||
var todo = function (e, overLimit) {
|
||||
if (e) { return void console.error("Unable to get the pinned usage"); }
|
||||
if (overLimit) {
|
||||
var key = 'pinLimitReachedAlert';
|
||||
if (ApiConfig.noSubscriptionButton === true) {
|
||||
key = 'pinLimitReachedAlertNoAccounts';
|
||||
}
|
||||
$limit.show().click(function () {
|
||||
Cryptpad.alert(Messages._getKey('pinLimitReachedAlert', [encodeURIComponent(window.location.hostname)]), null, true);
|
||||
Cryptpad.alert(Messages._getKey(key, [encodeURIComponent(window.location.hostname)]), null, true);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2712,13 +2712,11 @@ define([
|
|||
}
|
||||
|
||||
/* add the usage */
|
||||
if (AppConfig.enablePinLimit) {
|
||||
Cryptpad.createUsageBar(function (err, $limitContainer) {
|
||||
if (err) { return void logError(err); }
|
||||
$leftside.html('');
|
||||
$leftside.append($limitContainer);
|
||||
});
|
||||
}
|
||||
Cryptpad.createUsageBar(function (err, $limitContainer) {
|
||||
if (err) { return void logError(err); }
|
||||
$leftside.html('');
|
||||
$leftside.append($limitContainer);
|
||||
});
|
||||
|
||||
/* add a history button */
|
||||
var histConfig = {
|
||||
|
|
Loading…
Reference in New Issue