Add DEFAULT_DOWNLOADS variable to set default download count
Fixes https://github.com/timvisee/send/issues/39
This commit is contained in:
parent
3bd9f00c25
commit
1a923d21b5
|
@ -77,7 +77,11 @@ function body(main) {
|
||||||
state.capabilities = {
|
state.capabilities = {
|
||||||
account: true
|
account: true
|
||||||
}; //TODO
|
}; //TODO
|
||||||
state.archive = new Archive([], DEFAULTS.EXPIRE_SECONDS);
|
state.archive = new Archive(
|
||||||
|
[],
|
||||||
|
DEFAULTS.EXPIRE_SECONDS,
|
||||||
|
DEFAULTS.DOWNLOADS
|
||||||
|
);
|
||||||
state.storage = storage;
|
state.storage = storage;
|
||||||
state.user = new User(storage, LIMITS);
|
state.user = new User(storage, LIMITS);
|
||||||
state.sentry = Sentry;
|
state.sentry = Sentry;
|
||||||
|
|
|
@ -14,11 +14,11 @@ function isDupe(newFile, array) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Archive {
|
export default class Archive {
|
||||||
constructor(files = [], defaultTimeLimit = 86400) {
|
constructor(files = [], defaultTimeLimit = 86400, defaultDownloadLimit = 1) {
|
||||||
this.files = Array.from(files);
|
this.files = Array.from(files);
|
||||||
this.defaultTimeLimit = defaultTimeLimit;
|
this.defaultTimeLimit = defaultTimeLimit;
|
||||||
this.timeLimit = defaultTimeLimit;
|
this.timeLimit = defaultTimeLimit;
|
||||||
this.dlimit = 1;
|
this.dlimit = defaultDownloadLimit;
|
||||||
this.password = null;
|
this.password = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ if (process.env.NODE_ENV === 'production') {
|
||||||
DEFAULTS,
|
DEFAULTS,
|
||||||
WEB_UI,
|
WEB_UI,
|
||||||
PREFS,
|
PREFS,
|
||||||
archive: new Archive([], DEFAULTS.EXPIRE_SECONDS),
|
archive: new Archive([], DEFAULTS.EXPIRE_SECONDS, DEFAULTS.DOWNLOADS),
|
||||||
capabilities,
|
capabilities,
|
||||||
translate,
|
translate,
|
||||||
storage,
|
storage,
|
||||||
|
|
|
@ -49,6 +49,8 @@ Configure the limits for uploads and downloads. Long expiration times are risky
|
||||||
| `MAX_DOWNLOADS` | Maximum number of downloads (defaults to `100`)
|
| `MAX_DOWNLOADS` | Maximum number of downloads (defaults to `100`)
|
||||||
| `DOWNLOAD_COUNTS` | Download limit options to show in UI dropdown, e.g. `10,1,2,5,10,15,25,50,100,1000`
|
| `DOWNLOAD_COUNTS` | Download limit options to show in UI dropdown, e.g. `10,1,2,5,10,15,25,50,100,1000`
|
||||||
| `EXPIRE_TIMES_SECONDS` | Expire time options to show in UI dropdown, e.g. `3600,86400,604800,2592000,31536000`
|
| `EXPIRE_TIMES_SECONDS` | Expire time options to show in UI dropdown, e.g. `3600,86400,604800,2592000,31536000`
|
||||||
|
| `DEFAULT_DOWNLOADS` | Default download limit in UI (defaults to `1`)
|
||||||
|
| `DEFAULT_EXPIRE_SECONDS` | Default expire time in UI (defaults to `86400`)
|
||||||
|
|
||||||
*Note: more options can be found here: https://github.com/timvisee/send/blob/master/server/config.js*
|
*Note: more options can be found here: https://github.com/timvisee/send/blob/master/server/config.js*
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ module.exports = {
|
||||||
FOOTER_SOURCE_URL: config.footer_source_url
|
FOOTER_SOURCE_URL: config.footer_source_url
|
||||||
},
|
},
|
||||||
DEFAULTS: {
|
DEFAULTS: {
|
||||||
|
DOWNLOADS: config.default_downloads,
|
||||||
DOWNLOAD_COUNTS: config.download_counts,
|
DOWNLOAD_COUNTS: config.download_counts,
|
||||||
EXPIRE_TIMES_SECONDS: config.expire_times_seconds,
|
EXPIRE_TIMES_SECONDS: config.expire_times_seconds,
|
||||||
EXPIRE_SECONDS: config.default_expire_seconds
|
EXPIRE_SECONDS: config.default_expire_seconds
|
||||||
|
|
|
@ -64,6 +64,11 @@ const conf = convict({
|
||||||
default: [1, 2, 3, 4, 5, 20, 50, 100],
|
default: [1, 2, 3, 4, 5, 20, 50, 100],
|
||||||
env: 'DOWNLOAD_COUNTS'
|
env: 'DOWNLOAD_COUNTS'
|
||||||
},
|
},
|
||||||
|
default_downloads: {
|
||||||
|
format: Number,
|
||||||
|
default: 1,
|
||||||
|
env: 'DEFAULT_DOWNLOADS'
|
||||||
|
},
|
||||||
max_downloads: {
|
max_downloads: {
|
||||||
format: Number,
|
format: Number,
|
||||||
default: 100,
|
default: 100,
|
||||||
|
|
|
@ -26,7 +26,7 @@ module.exports = function(ws, req) {
|
||||||
|
|
||||||
const fileInfo = JSON.parse(message);
|
const fileInfo = JSON.parse(message);
|
||||||
const timeLimit = fileInfo.timeLimit || config.default_expire_seconds;
|
const timeLimit = fileInfo.timeLimit || config.default_expire_seconds;
|
||||||
const dlimit = fileInfo.dlimit || 1;
|
const dlimit = fileInfo.dlimit || config.default_downloads;
|
||||||
const metadata = fileInfo.fileMetadata;
|
const metadata = fileInfo.fileMetadata;
|
||||||
const auth = fileInfo.authorization;
|
const auth = fileInfo.authorization;
|
||||||
const user = await fxa.verify(fileInfo.bearer);
|
const user = await fxa.verify(fileInfo.bearer);
|
||||||
|
|
Loading…
Reference in New Issue