Skip to content

Commit 1a923d2

Browse files
committed
Add DEFAULT_DOWNLOADS variable to set default download count
Fixes timvisee#39
1 parent 3bd9f00 commit 1a923d2

File tree

7 files changed

+19
-7
lines changed

7 files changed

+19
-7
lines changed

android/android.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ function body(main) {
7777
state.capabilities = {
7878
account: true
7979
}; //TODO
80-
state.archive = new Archive([], DEFAULTS.EXPIRE_SECONDS);
80+
state.archive = new Archive(
81+
[],
82+
DEFAULTS.EXPIRE_SECONDS,
83+
DEFAULTS.DOWNLOADS
84+
);
8185
state.storage = storage;
8286
state.user = new User(storage, LIMITS);
8387
state.sentry = Sentry;

app/archive.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ function isDupe(newFile, array) {
1414
}
1515

1616
export default class Archive {
17-
constructor(files = [], defaultTimeLimit = 86400) {
17+
constructor(files = [], defaultTimeLimit = 86400, defaultDownloadLimit = 1) {
1818
this.files = Array.from(files);
1919
this.defaultTimeLimit = defaultTimeLimit;
2020
this.timeLimit = defaultTimeLimit;
21-
this.dlimit = 1;
21+
this.dlimit = defaultDownloadLimit;
2222
this.password = null;
2323
}
2424

app/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ if (process.env.NODE_ENV === 'production') {
5252
DEFAULTS,
5353
WEB_UI,
5454
PREFS,
55-
archive: new Archive([], DEFAULTS.EXPIRE_SECONDS),
55+
archive: new Archive([], DEFAULTS.EXPIRE_SECONDS, DEFAULTS.DOWNLOADS),
5656
capabilities,
5757
translate,
5858
storage,

docs/docker.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Config options expecting array values (e.g. `EXPIRE_TIMES_SECONDS`, `DOWNLOAD_CO
2929
| Name | Description |
3030
|------------------|-------------|
3131
| `BASE_URL` | The HTTPS URL where traffic will be served (e.g. `https://send.firefox.com`)
32-
| `DETECT_BASE_URL` | Autodetect the base URL using browser if `BASE_URL` is unset (defaults to `false`)
32+
| `DETECT_BASE_URL` | Autodetect the base URL using browser if `BASE_URL` is unset (defaults to `false`)
3333
| `PORT` | Port the server will listen on (defaults to `1443`)
3434
| `NODE_ENV` | Run in `development` mode (unsafe) or `production` mode (the default)
3535
| `SEND_FOOTER_DMCA_URL` | A URL to a contact page for DMCA requests (empty / not shown by default)
@@ -49,6 +49,8 @@ Configure the limits for uploads and downloads. Long expiration times are risky
4949
| `MAX_DOWNLOADS` | Maximum number of downloads (defaults to `100`)
5050
| `DOWNLOAD_COUNTS` | Download limit options to show in UI dropdown, e.g. `10,1,2,5,10,15,25,50,100,1000`
5151
| `EXPIRE_TIMES_SECONDS` | Expire time options to show in UI dropdown, e.g. `3600,86400,604800,2592000,31536000`
52+
| `DEFAULT_DOWNLOADS` | Default download limit in UI (defaults to `1`)
53+
| `DEFAULT_EXPIRE_SECONDS` | Default expire time in UI (defaults to `86400`)
5254

5355
*Note: more options can be found here: https://github.com/timvisee/send/blob/master/server/config.js*
5456

@@ -89,7 +91,7 @@ $ docker run -p 1443:1443 \
8991
registry.gitlab.com/timvisee/send:latest
9092
```
9193

92-
*Note: make sure to replace the example values above with your real values before running.*
94+
*Note: make sure to replace the example values above with your real values before running.*
9395

9496

9597
**Run totally self-hosted using the current filesystem directry (`$PWD`) to store the Redis data and file uploads, with a `5GB` upload limit, 1 month expiry, and contact URL set.**

server/clientConstants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = {
1515
FOOTER_SOURCE_URL: config.footer_source_url
1616
},
1717
DEFAULTS: {
18+
DOWNLOADS: config.default_downloads,
1819
DOWNLOAD_COUNTS: config.download_counts,
1920
EXPIRE_TIMES_SECONDS: config.expire_times_seconds,
2021
EXPIRE_SECONDS: config.default_expire_seconds

server/config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ const conf = convict({
6464
default: [1, 2, 3, 4, 5, 20, 50, 100],
6565
env: 'DOWNLOAD_COUNTS'
6666
},
67+
default_downloads: {
68+
format: Number,
69+
default: 1,
70+
env: 'DEFAULT_DOWNLOADS'
71+
},
6772
max_downloads: {
6873
format: Number,
6974
default: 100,

server/routes/ws.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = function(ws, req) {
2626

2727
const fileInfo = JSON.parse(message);
2828
const timeLimit = fileInfo.timeLimit || config.default_expire_seconds;
29-
const dlimit = fileInfo.dlimit || 1;
29+
const dlimit = fileInfo.dlimit || config.default_downloads;
3030
const metadata = fileInfo.fileMetadata;
3131
const auth = fileInfo.authorization;
3232
const user = await fxa.verify(fileInfo.bearer);

0 commit comments

Comments
 (0)