Skip to content

Commit

Permalink
added ability to change expiration date and updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Edi Bibergall committed Oct 17, 2023
1 parent e5a5e92 commit 2b5855b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 23 deletions.
16 changes: 15 additions & 1 deletion extensions/securehub-file-upload/README-DE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,18 @@ Die Base URL für die SecureHub-Umgebung. Normalerweise *securehub.yourcompanyna

* SecureHub Verbindung

Für die Verbindung benötigen wir Ihren Benutzernamen und Ihr Passwort.
Für die Verbindung benötigen wir Ihren Benutzernamen und Ihr Passwort.

## Zusätzliche Einstellungen

* Nicht auhorisierte Zertifikate ablehnen

Wird automatisch auf „false“ gesetzt. Lassen Sie „false“, wenn Sie Zertifikatsfehler von SecureHub erhalten.

* Ablauf des Links festlegen

Soll der Standard-Linkablauf verwendet werden oder möchten Sie ein benutzerdefiniertes Datum verwenden?

* Linkablauf (in Tagen)

In wie vielen Tagen ab dem aktuellen Tag sollte der Link ablaufen?
16 changes: 15 additions & 1 deletion extensions/securehub-file-upload/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,18 @@ The base URL for the SecureHub environment. Usually *securehub.yourcompanyname.c

* Connection

In the conection we will need your username and password.
In the connection we will need your username and password.

## Additional Options

* Reject Unauthorized Certificates

Automatically set to false. Leave as false if you receive certificate errors from SecureHub.

* Define Link Expiration

Should the standard link expiration be used or would you like to use a custom date.

* Link Expiration (in Days)

In how many days from the current day should the link expire?
2 changes: 1 addition & 1 deletion extensions/securehub-file-upload/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extensions/securehub-file-upload/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "file-upload",
"version": "4.0.1",
"version": "4.1.0",
"description": "Triggers the securehub-file-upload webchat plugin",
"main": "build/module.js",
"scripts": {
Expand Down
27 changes: 8 additions & 19 deletions extensions/securehub-file-upload/src/nodes/uploadToSecureHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,6 @@ export const uploadToSecureHubNode = createNodeDescriptor({
const { connection, folderName, baseUrl, rejectUnauthCert, defineLinkExpiration, daysExpiration } = config;
const { username, password } = connection;

function addDaysToCurrentDate(daysToAdd: number): string {
// Get the current date and time using Luxon
let currentDate = DateTime.utc();

// Add the specified number of days
let newDate = currentDate.plus({ days: daysToAdd });

// Format the date in the desired format: YYYY-MM-DDTHH:mm:ssZ (without milliseconds)
let linkExpirationDate = newDate.toFormat('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'');

return linkExpirationDate;
}

/*
let currentDate = DateTime.utc();
let newDate = currentDate.plus({ days: daysExpiration });
let linkExpirationDate = newDate.toFormat('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'');
*/

const agent = new https.Agent({
rejectUnauthorized: false
Expand All @@ -166,7 +148,14 @@ export const uploadToSecureHubNode = createNodeDescriptor({

let linkExpirationDate;
if (defineLinkExpiration === true) {
linkExpirationDate = addDaysToCurrentDate(daysExpiration);
// Get the current date and time using Luxon
let currentDate = DateTime.utc();

// Add the specified number of days
let newDate = currentDate.plus({ days: daysExpiration });

// Format the date in the desired format: YYYY-MM-DDTHH:mm:ssZ (without milliseconds)
linkExpirationDate = newDate.toFormat('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'');
}

try {
Expand Down

0 comments on commit 2b5855b

Please sign in to comment.