1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-07-02 07:20:38 +02:00

fix: convert async function to sync function

This commit is contained in:
Elias Schneider 2022-12-02 14:43:52 +01:00
parent b649d8bf8e
commit 1dbfe0bbc9
3 changed files with 8 additions and 7 deletions

View File

@ -22,7 +22,7 @@ export class EmailService {
if (!this.config.get("emailRecepientsEnabled")) if (!this.config.get("emailRecepientsEnabled"))
throw new InternalServerErrorException("Email service disabled"); throw new InternalServerErrorException("Email service disabled");
const shareUrl = `${this.config.get("APP_URL")}/share/${shareId}`; const shareUrl = `${this.config.get("appUrl")}/share/${shareId}`;
await transporter.sendMail({ await transporter.sendMail({

View File

@ -78,14 +78,15 @@ export class FileService {
return fs.createReadStream(`./data/uploads/shares/${shareId}/archive.zip`); return fs.createReadStream(`./data/uploads/shares/${shareId}/archive.zip`);
} }
async getFileDownloadUrl(shareId: string, fileId: string) { getFileDownloadUrl(shareId: string, fileId: string) {
const downloadToken = this.generateFileDownloadToken(shareId, fileId); const downloadToken = this.generateFileDownloadToken(shareId, fileId);
return `${this.config.get( return `${this.config.get(
"APP_URL" "appUrl"
)}/api/shares/${shareId}/files/${fileId}?token=${downloadToken}`; )}/api/shares/${shareId}/files/${fileId}?token=${downloadToken}`;
} }
async generateFileDownloadToken(shareId: string, fileId: string) { generateFileDownloadToken(shareId: string, fileId: string) {
if (fileId == "zip") fileId = undefined; if (fileId == "zip") fileId = undefined;
return this.jwtService.sign( return this.jwtService.sign(
@ -100,7 +101,7 @@ export class FileService {
); );
} }
async verifyFileDownloadToken(shareId: string, token: string) { verifyFileDownloadToken(shareId: string, token: string) {
try { try {
const claims = this.jwtService.verify(token, { const claims = this.jwtService.verify(token, {
secret: this.config.get("jwtSecret"), secret: this.config.get("jwtSecret"),

View File

@ -36,7 +36,7 @@
"header": [], "header": [],
"body": { "body": {
"mode": "raw", "mode": "raw",
"raw": "{\n \"firstName\" : \"System\",\n \"lastName\" : \"Test\",\n \"email\": \"system@test.org\",\n \"password\": \"J2y8unpJUcJDRv\"\n}", "raw": "{\n \"email\": \"system@test.org\",\n \"username\": \"system.test\",\n \"password\": \"J2y8unpJUcJDRv\"\n}",
"options": { "options": {
"raw": { "raw": {
"language": "json" "language": "json"
@ -97,7 +97,7 @@
], ],
"body": { "body": {
"mode": "raw", "mode": "raw",
"raw": "{\n \"firstName\" : \"System\",\n \"lastName\" : \"Test2\",\n \"email\": \"system2@test.org\",\n \"password\": \"N44HcHgeuAvfCT\"\n}", "raw": "{\n \"email\": \"system2@test.org\",\n \"username\": \"system.test2\",\n \"password\": \"N44HcHgeuAvfCT\"\n}",
"options": { "options": {
"raw": { "raw": {
"language": "json" "language": "json"