feat: reverse shares (#86)

* add first concept

* add reverse share funcionality to frontend

* allow creator to limit share expiration

* moved reverse share in seperate module

* add table to manage reverse shares

* delete complete share if reverse share was deleted

* optimize function names

* add db migration

* enable reverse share email notifications

* fix config variable descriptions

* fix migration for new installations
This commit is contained in:
Elias Schneider
2023-01-26 13:44:04 +01:00
committed by GitHub
parent 1ceb07b89e
commit 4a5fb549c6
43 changed files with 1456 additions and 280 deletions

View File

@@ -0,0 +1,26 @@
import moment from "moment";
export const getExpirationPreview = (
name: string,
form: {
values: {
never_expires?: boolean;
expiration_num: number;
expiration_unit: string;
};
}
) => {
const value = form.values.never_expires
? "never"
: form.values.expiration_num + form.values.expiration_unit;
if (value === "never") return `This ${name} will never expire.`;
const expirationDate = moment()
.add(
value.split("-")[0],
value.split("-")[1] as moment.unitOfTime.DurationConstructor
)
.toDate();
return `This ${name} will expire on ${moment(expirationDate).format("LLL")}`;
};