cleaned up the accounts, limits and revenue sharing and unified the config in one place

pull/1/head
Caleb James DeLisle 8 years ago
parent 6c1861dbc6
commit 66520b6041

@ -116,11 +116,46 @@ module.exports = {
'contact', 'contact',
], ],
/* Domain /* Limits, Subscriptions and Contact
* 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 * 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.
*/
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.
*/ */
// domain: 'https://cryptpad.fr', adminEmail: 'i.did.not.read.my.config@cryptpad.fr',
/* /*
You have the option of specifying an alternative storage adaptor. You have the option of specifying an alternative storage adaptor.
@ -211,12 +246,6 @@ module.exports = {
*/ */
//restrictUploads: false, //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) /* Max Upload Size (bytes)
* this sets the maximum size of any one file uploaded to the server. * this sets the maximum size of any one file uploaded to the server.
* anything larger than this size will be rejected * anything larger than this size will be rejected

@ -37,8 +37,6 @@ define(function() {
config.enableHistory = true; config.enableHistory = true;
config.enablePinLimit = true;
/* user passwords are hashed with scrypt, and salted with their username. /* user passwords are hashed with scrypt, and salted with their username.
this value will be appended to the username, causing the resulting hash this value will be appended to the username, causing the resulting hash
to differ from other CryptPad instances if customized. This makes it 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>" + 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.'; '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.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.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>"+ out.pinLimitNotPinned = "You've reached your storage limit.<br>"+
"This pad is not stored in your CryptDrive."; "This pad is not stored in your CryptDrive.";

@ -1,4 +1,5 @@
/*@flow*/ /*@flow*/
/*jshint esversion: 6 */
/* Use Nacl for checking signatures of messages */ /* Use Nacl for checking signatures of messages */
var Nacl = require("tweetnacl"); var Nacl = require("tweetnacl");
@ -8,6 +9,7 @@ var Nacl = require("tweetnacl");
var Fs = require("fs"); var Fs = require("fs");
var Path = require("path"); var Path = require("path");
var Https = require("https"); var Https = require("https");
const Package = require('./package.json');
var RPC = module.exports; 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 // To each key is associated an object containing the 'limit' value and a 'note' explaining that limit
var limits = {}; var limits = {};
var updateLimits = function (config, publicKey, cb) { var updateLimits = function (config, publicKey, cb) {
if (config.adminEmail === false && config.noSubscriptionButton === true) { return; }
if (typeof cb !== "function") { cb = function () {}; } if (typeof cb !== "function") { cb = function () {}; }
var defaultLimit = typeof(config.defaultStorageLimit) === 'number'? var defaultLimit = typeof(config.defaultStorageLimit) === 'number'?
@ -382,8 +385,10 @@ var updateLimits = function (config, publicKey, cb) {
} }
var body = JSON.stringify({ var body = JSON.stringify({
domain: config.domain, domain: config.myDomain,
subdomain: config.subdomain subdomain: config.mySubdomain,
adminEmail: config.adminEmail,
version: Package.version
}); });
var options = { var options = {
host: 'accounts.cryptpad.fr', host: 'accounts.cryptpad.fr',

@ -121,6 +121,7 @@ app.get('/api/config', function(req, res){
waitSeconds: 60, waitSeconds: 60,
urlArgs: 'ver=' + Package.version + (DEV_MODE? '-' + (+new Date()): ''), urlArgs: 'ver=' + Package.version + (DEV_MODE? '-' + (+new Date()): ''),
}, },
noSubscriptionButton: (config.noSubscriptionButton === true),
websocketPath: config.useExternalWebsocket ? undefined : config.websocketPath, websocketPath: config.useExternalWebsocket ? undefined : config.websocketPath,
websocketURL:'ws' + ((useSecureWebsockets) ? 's' : '') + '://' + host + ':' + websocketURL:'ws' + ((useSecureWebsockets) ? 's' : '') + '://' + host + ':' +
websocketPort + '/cryptpad_websocket', websocketPort + '/cryptpad_websocket',

@ -599,7 +599,7 @@ define([
var data = makePad(href, name); var data = makePad(href, name);
getStore().pushData(data, function (e) { getStore().pushData(data, function (e) {
if (e) { if (e) {
if (e === 'E_OVER_LIMIT' && AppConfig.enablePinLimit) { if (e === 'E_OVER_LIMIT') {
common.alert(Messages.pinLimitNotPinned, null, true); common.alert(Messages.pinLimitNotPinned, null, true);
return; return;
} }
@ -761,7 +761,7 @@ define([
}; };
common.isOverPinLimit = function (cb) { 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 usage;
var andThen = function (e, limit, plan) { var andThen = function (e, limit, plan) {
if (e) { return void cb(e); } 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 width = Math.floor(Math.min(quota, 1)*200); // the bar is 200px width
var $usage = $('<span>', {'class': 'usage'}).css('width', width+'px'); 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 origin = encodeURIComponent(window.location.hostname);
var $upgradeLink = $('<a>', { var $upgradeLink = $('<a>', {
href: "https://accounts.cryptpad.fr/#!on=" + origin, href: "https://accounts.cryptpad.fr/#!on=" + origin,
@ -845,7 +848,7 @@ define([
else if (quota < 1) { $usage.addClass('warning'); } else if (quota < 1) { $usage.addClass('warning'); }
else { else {
$usage.addClass('above'); $usage.addClass('above');
if (!limitReachedDisplayed) { if (!limitReachedDisplayed && Config.noSubscriptionButton === true) {
limitReachedDisplayed = true; limitReachedDisplayed = true;
common.alert(Messages._getKey('pinAboveLimitAlert', [prettyUsage, encodeURIComponent(window.location.hostname)]), null, true); common.alert(Messages._getKey('pinAboveLimitAlert', [prettyUsage, encodeURIComponent(window.location.hostname)]), null, true);
} }

@ -500,8 +500,12 @@ define([
var todo = function (e, overLimit) { var todo = function (e, overLimit) {
if (e) { return void console.error("Unable to get the pinned usage"); } if (e) { return void console.error("Unable to get the pinned usage"); }
if (overLimit) { if (overLimit) {
var message = Messages.pinLimitReachedAlert;
if (ApiConfig.noSubscriptionButton === true) {
message = Messages.pinLimitReachedAlertNoAccounts;
}
$limit.show().click(function () { $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) { var todo = function (e, overLimit) {
if (e) { return void console.error("Unable to get the pinned usage"); } if (e) { return void console.error("Unable to get the pinned usage"); }
if (overLimit) { if (overLimit) {
var key = 'pinLimitReachedAlert';
if (ApiConfig.noSubscriptionButton === true) {
key = 'pinLimitReachedAlertNoAccounts';
}
$limit.show().click(function () { $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 */ /* add the usage */
if (AppConfig.enablePinLimit) { Cryptpad.createUsageBar(function (err, $limitContainer) {
Cryptpad.createUsageBar(function (err, $limitContainer) { if (err) { return void logError(err); }
if (err) { return void logError(err); } $leftside.html('');
$leftside.html(''); $leftside.append($limitContainer);
$leftside.append($limitContainer); });
});
}
/* add a history button */ /* add a history button */
var histConfig = { var histConfig = {

Loading…
Cancel
Save