Skip to content

Commit cc689b9

Browse files
committed
Various fixes/improvements
1 parent 3d2fb07 commit cc689b9

14 files changed

+45
-254
lines changed

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:12-alpine
1+
FROM node:14-alpine
22

33
ENV PSITRANSFER_UPLOAD_DIR=/data \
44
NODE_ENV=production
@@ -13,6 +13,7 @@ ADD *.js package.json package-lock.json README.md /app/
1313
ADD lib /app/lib
1414
ADD app /app/app
1515
ADD lang /app/lang
16+
ADD plugins /app/plugins
1617
ADD public /app/public
1718

1819
# Rebuild the frontend apps

app/src/Download.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
130130
downloadAll(format) {
131131
document.location.href = this.$root.baseURI
132-
+ '/files/' + this.sid + '++'
132+
+ 'files/' + this.sid + '++'
133133
+ MD5(
134134
this.files
135135
.filter(f => !f.downloaded || f.metadata.retention !== 'one-time')

app/src/Upload.vue

+19-6
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
| {{ $root.lang.login }}
2020
div(v-else-if="$root.configFetched")
2121
.well(v-show="state === 'uploaded'")
22-
.pull-right.btn-group
22+
.pull-right.btn-group.upload-success-btns
2323
a.btn.btn-primary(@click.prevent="showQrCode" href="#" :title="$root.lang.showQrCode")
2424
icon.fa-fw(name="qrcode")
2525
| QR-Code
26-
a.btn.btn-primary(@click="sendMail = !sendMail" :title="$root.lang.sendViaMail")
26+
a.btn.btn-primary(:href="mailLnk" :title="$root.lang.sendViaMail")
2727
icon.fa-fw(name="envelope")
2828
| {{ $root.lang.email }}
2929
clipboard.btn.btn-primary(:value='shareUrl' :title="$root.lang.copyToClipboard")
@@ -45,7 +45,6 @@
4545
.col-sm-7
4646
files
4747
.col-sm-5
48-
send-mail(v-if="sendMail" style="margin-bottom: 20px")
4948
settings
5049
.text-right(v-show='showUploadBtn')
5150
button#uploadBtn.btn.btn-lg.btn-success(@click="$store.dispatch('upload/upload')")
@@ -63,7 +62,6 @@
6362
6463
import Settings from './Upload/Settings.vue';
6564
import Files from './Upload/Files.vue';
66-
import SendMail from "./Upload/SendMail.vue";
6765
import Clipboard from './common/Clipboard.vue'
6866
import 'vue-awesome/icons/cloud-upload-alt';
6967
import 'vue-awesome/icons/upload';
@@ -78,7 +76,6 @@
7876
export default {
7977
name: 'Upload',
8078
components: {
81-
SendMail,
8279
Settings,
8380
Files,
8481
Clipboard,
@@ -88,7 +85,6 @@
8885
return {
8986
uploadPassword: '',
9087
uploadPasswordWrong: null,
91-
sendMail: false,
9288
}
9389
},
9490
@@ -164,3 +160,20 @@
164160
165161
}
166162
</script>
163+
164+
<style>
165+
@media all and (max-width: 500px) {
166+
.well {
167+
padding: 19px 8px;
168+
}
169+
.upload-success-btns {
170+
width: 100%;
171+
margin-bottom: 10px;
172+
}
173+
174+
.upload-success-btns .btn {
175+
padding: 7px 5px;
176+
font-size: 12px;
177+
}
178+
}
179+
</style>

app/src/Upload/SendMail.vue

-82
This file was deleted.

config.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,7 @@ const config = {
5959
// Limit upload size
6060
"maxFileSize": null, // Math.pow(2, 30) * 2, // 2GB
6161
"maxBucketSize": null, // Math.pow(2, 30) * 2, // 10GB
62-
"plugins": ['file-downloaded-webhook', 'file-uploaded-webhook', 'mail-notifications'],
63-
// Nodemailer smtp transport config: https://nodemailer.com/smtp/
64-
"mailer": {
65-
"host": "localhost",
66-
"port": 25,
67-
"secure": false, // true for 465, false for other ports
68-
"auth": {
69-
"user": "", // generated ethereal user
70-
"pass": "", // generated ethereal password
71-
},
72-
},
73-
"mailFrom": "PsiTransfer <[email protected]>",
62+
"plugins": ['file-downloaded-webhook', 'file-uploaded-webhook'],
7463
};
7564

7665
// Load NODE_ENV specific config

lang/de.js

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module.exports = {
3131
oneTimeDownloadExpired: "Einmal-Download: Datei ist nicht mehr verfügbar.",
3232
fileSizeExceed: "Dateigröße %% überschreitet das Maximum von %%",
3333
bucketSizeExceed: "Uploadgröße %% überschreitet das Maximum von %%",
34+
mailInvalid: "Das Format der E-Mail Adresse ist ungültig",
3435
mailTo: "Senden an",
3536
mailToPlaceholder: "E-Mail Adressen",
3637
mailFrom: "Meine E-Mail Adresse",

lang/en.js

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module.exports = {
3131
oneTimeDownloadExpired: "One-Time Download: File is not available anymore.",
3232
fileSizeExceed: "File size %% exceeds maximum of %%",
3333
bucketSizeExceed: "Upload size %% exceeds maximum of %%",
34+
mailInvalid: "The e-mail address looks faulty",
3435
mailTo: "Send to",
3536
mailToPlaceholder: "E-Mail addresses",
3637
mailFrom: "My E-Mail address",

lib/endpoints.js

+20-14
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ if (config.forceHttps) {
5252
// Static files
5353
app.use(`${ config.baseUrl }app`, express.static(path.join(__dirname, '../public/app')));
5454
app.use(`${ config.baseUrl }assets`, express.static(path.join(__dirname, '../public/assets')));
55+
// Resolve language
56+
app.use((req, res, next) => {
57+
const lang = req.acceptsLanguages(...Object.keys(config.languages)) || config.defaultLanguage;
58+
req.translations = config.languages[lang];
59+
next();
60+
});
5561

5662
// robots.txt
5763
app.get(`${ config.baseUrl }robots.txt`, (req, res) => {
@@ -68,20 +74,18 @@ app.get(`${ config.baseUrl }`, (req, res) => {
6874
if (config.uploadAppPath !== `${ config.baseUrl }`) {
6975
res.status(304).redirect(config.uploadAppPath);
7076
} else {
71-
res.send(uploadPage(pugVars));
77+
res.send(uploadPage({...pugVars, lang: req.translations}));
7278
}
7379
});
7480

7581
app.get(config.uploadAppPath, (req, res) => {
76-
res.send(uploadPage(pugVars));
82+
res.send(uploadPage({...pugVars, lang: req.translations}));
7783
});
7884

7985
// Return translations
8086
app.get(`${ config.baseUrl }lang.json`, (req, res) => {
81-
const lang = req.acceptsLanguages(...Object.keys(config.languages));
82-
const translations = config.languages[lang];
83-
eventBus.emit('getLang', translations);
84-
res.json(translations);
87+
eventBus.emit('getLang', req.translations);
88+
res.json(req.translations);
8589
});
8690

8791
// Config
@@ -115,7 +119,7 @@ app.get(`${ config.baseUrl }config.json`, (req, res) => {
115119

116120
app.get(`${ config.baseUrl }admin`, (req, res, next) => {
117121
if (!config.adminPass) return next();
118-
res.send(adminPage(pugVars));
122+
res.send(adminPage({...pugVars, lang: req.translations}));
119123
});
120124

121125
app.get(`${ config.baseUrl }admin/data.json`, (req, res, next) => {
@@ -171,7 +175,7 @@ app.get(`${ config.baseUrl }:sid`, (req, res, next) => {
171175
});
172176
} else {
173177
if (!db.get(req.params.sid)) return next();
174-
res.send(downloadPage(pugVars));
178+
res.send(downloadPage({...pugVars, lang: req.translations}));
175179
}
176180
});
177181

@@ -188,10 +192,10 @@ app.get(`${ config.baseUrl }files/:fid`, async (req, res, next) => {
188192
const format = req.params.fid.endsWith('.zip') ? 'zip' : 'tar.gz';
189193
const bucket = db.get(sid);
190194

191-
if (!bucket) return res.status(404).send(errorPage({ ...pugVars, error: 'Download bucket not found.' }));
195+
if (!bucket) return res.status(404).send(errorPage({ ...pugVars, error: 'Download bucket not found.', lang: req.translations }));
192196

193197
if (req.params.fid !== sid + '++' + MD5(bucket.map(f => f.key).join()).toString() + '.' + format) {
194-
res.status(404).send(errorPage({ ...pugVars, error: 'Invalid link' }));
198+
res.status(404).send(errorPage({ ...pugVars, error: 'Invalid link', lang: req.translations }));
195199
return;
196200
}
197201
debug(`Download Bucket ${ sid }`);
@@ -234,7 +238,8 @@ app.get(`${ config.baseUrl }files/:fid`, async (req, res, next) => {
234238
sid,
235239
file: filename,
236240
metadata: bucket[0].metadata,
237-
bucket
241+
bucket,
242+
url: req.protocol + '://' + req.get('host') + req.originalUrl,
238243
});
239244
});
240245
}
@@ -262,12 +267,13 @@ app.get(`${ config.baseUrl }files/:fid`, async (req, res, next) => {
262267
eventBus.emit('fileDownloaded', {
263268
sid,
264269
file: info.metadata.name,
265-
metadata: info.metadata
270+
metadata: info.metadata,
271+
url: req.protocol + '://' + req.get('host') + req.originalUrl,
266272
});
267273
});
268274
}
269275
catch (e) {
270-
res.status(404).send(errorPage({ ...pugVars, error: e.message }));
276+
res.status(404).send(errorPage({ ...pugVars, error: e.message, lang: req.translations }));
271277
}
272278
});
273279

@@ -353,7 +359,7 @@ app.use(`${ config.baseUrl }files`,
353359
);
354360

355361
app.use((req, res, next) => {
356-
res.status(404).send(errorPage({ ...pugVars, error: 'Download bucket not found.' }));
362+
res.status(404).send(errorPage({ ...pugVars, error: 'Download bucket not found.', lang: req.translations }));
357363
});
358364

359365
module.exports = app;

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"http-errors": "^1.8.0",
2626
"method-override": "^3.0.0",
2727
"morgan": "^1.10.0",
28-
"nodemailer": "^6.4.10",
2928
"pug": "^3.0.0",
3029
"to-object-reducer": "^1.0.1",
3130
"uuid": "^8.2.0"

0 commit comments

Comments
 (0)