Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f9f8b6fe7 | ||
|
|
bf1b2633c8 | ||
|
|
b3ea96c191 |
@@ -1,3 +1,10 @@
|
||||
## [1.8.1](https://github.com/stonith404/pingvin-share/compare/v1.8.0...v1.8.1) (2025-01-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* wrong validation for expiration in reverse share modal ([b3ea96c](https://github.com/stonith404/pingvin-share/commit/b3ea96c1916980863fc6903c64cd2a7b32d66cfb))
|
||||
|
||||
## [1.8.0](https://github.com/stonith404/pingvin-share/compare/v1.7.2...v1.8.0) (2025-01-02)
|
||||
|
||||
|
||||
|
||||
4
backend/package-lock.json
generated
4
backend/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "pingvin-share-backend",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "pingvin-share-backend",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.679.0",
|
||||
"@nestjs/cache-manager": "^2.2.2",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pingvin-share-backend",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"scripts": {
|
||||
"build": "nest build",
|
||||
"dev": "cross-env NODE_ENV=development nest start --watch",
|
||||
|
||||
@@ -345,7 +345,9 @@ export class AuthService {
|
||||
if (refreshToken) {
|
||||
const now = moment();
|
||||
const sessionDuration = this.config.get("general.sessionDuration");
|
||||
const maxAge = moment(now).add(sessionDuration.value, sessionDuration.unit).diff(now);
|
||||
const maxAge = moment(now)
|
||||
.add(sessionDuration.value, sessionDuration.unit)
|
||||
.diff(now);
|
||||
response.cookie("refresh_token", refreshToken, {
|
||||
path: "/api/auth/token",
|
||||
httpOnly: true,
|
||||
|
||||
@@ -36,8 +36,7 @@ export class ConfigService extends EventEmitter {
|
||||
if (configVariable.type == "boolean") return value == "true";
|
||||
if (configVariable.type == "string" || configVariable.type == "text")
|
||||
return value;
|
||||
if (configVariable.type == "timespan")
|
||||
return stringToTimespan(value);
|
||||
if (configVariable.type == "timespan") return stringToTimespan(value);
|
||||
}
|
||||
|
||||
async getByCategory(category: string) {
|
||||
|
||||
@@ -26,10 +26,11 @@ export class ReverseShareService {
|
||||
.toDate();
|
||||
|
||||
const parsedExpiration = parseRelativeDateToAbsolute(data.shareExpiration);
|
||||
const maxExpiration = this.config.get("share.maxExpiration");
|
||||
if (
|
||||
this.config.get("share.maxExpiration") !== 0 &&
|
||||
maxExpiration.value !== 0 &&
|
||||
parsedExpiration >
|
||||
moment().add(this.config.get("share.maxExpiration"), "hours").toDate()
|
||||
moment().add(maxExpiration.value, maxExpiration.unit).toDate()
|
||||
) {
|
||||
throw new BadRequestException(
|
||||
"Expiration date exceeds maximum expiration date",
|
||||
|
||||
@@ -61,9 +61,7 @@ export class ShareService {
|
||||
maxExpiration.value !== 0 &&
|
||||
(expiresNever ||
|
||||
parsedExpiration >
|
||||
moment()
|
||||
.add(maxExpiration.value, maxExpiration.unit)
|
||||
.toDate())
|
||||
moment().add(maxExpiration.value, maxExpiration.unit).toDate())
|
||||
) {
|
||||
throw new BadRequestException(
|
||||
"Expiration date exceeds maximum expiration date",
|
||||
|
||||
4
frontend/package-lock.json
generated
4
frontend/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "pingvin-share-frontend",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "pingvin-share-frontend",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.13.3",
|
||||
"@emotion/server": "^11.11.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pingvin-share-frontend",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
|
||||
@@ -96,7 +96,9 @@ const AdminConfigInput = ({
|
||||
{configVariable.type == "timespan" && (
|
||||
<TimespanInput
|
||||
value={stringToTimespan(configVariable.value)}
|
||||
onChange={(timespan) => onValueChange(configVariable, timespanToString(timespan))}
|
||||
onChange={(timespan) =>
|
||||
onValueChange(configVariable, timespanToString(timespan))
|
||||
}
|
||||
w={201}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -3,81 +3,86 @@ import { Timespan } from "../../types/timespan.type";
|
||||
import { NativeSelect, NumberInput } from "@mantine/core";
|
||||
import useTranslate from "../../hooks/useTranslate.hook";
|
||||
|
||||
const TimespanInput = ({ label, value, onChange, ...restProps }: {
|
||||
label?: string,
|
||||
value: Timespan,
|
||||
onChange: (timespan: Timespan) => void,
|
||||
[key: string]: any,
|
||||
const TimespanInput = ({
|
||||
label,
|
||||
value,
|
||||
onChange,
|
||||
...restProps
|
||||
}: {
|
||||
label?: string;
|
||||
value: Timespan;
|
||||
onChange: (timespan: Timespan) => void;
|
||||
[key: string]: any;
|
||||
}) => {
|
||||
const [unit, setUnit] = useState(value.unit);
|
||||
const [inputValue, setInputValue] = useState(value.value);
|
||||
const t = useTranslate();
|
||||
|
||||
const version = inputValue == 1 ? "singular" : "plural";
|
||||
const unitSelect = (
|
||||
<NativeSelect
|
||||
data={[
|
||||
{
|
||||
value: "minutes",
|
||||
label: t(`upload.modal.expires.minute-${version}`),
|
||||
},
|
||||
{
|
||||
value: "hours",
|
||||
label: t(`upload.modal.expires.hour-${version}`),
|
||||
},
|
||||
{
|
||||
value: "days",
|
||||
label: t(`upload.modal.expires.day-${version}`),
|
||||
},
|
||||
{
|
||||
value: "weeks",
|
||||
label: t(`upload.modal.expires.week-${version}`),
|
||||
},
|
||||
{
|
||||
value: "months",
|
||||
label: t(`upload.modal.expires.month-${version}`),
|
||||
},
|
||||
{
|
||||
value: "years",
|
||||
label: t(`upload.modal.expires.year-${version}`),
|
||||
},
|
||||
]}
|
||||
value={unit}
|
||||
rightSectionWidth={28}
|
||||
styles={{
|
||||
input: {
|
||||
fontWeight: 500,
|
||||
borderTopLeftRadius: 0,
|
||||
borderBottomLeftRadius: 0,
|
||||
width: 120,
|
||||
marginRight: -2,
|
||||
},
|
||||
}}
|
||||
onChange={event => {
|
||||
const unit = event.currentTarget.value as Timespan["unit"];
|
||||
setUnit(unit);
|
||||
onChange({ value: inputValue, unit });
|
||||
}}
|
||||
/>
|
||||
);
|
||||
const [unit, setUnit] = useState(value.unit);
|
||||
const [inputValue, setInputValue] = useState(value.value);
|
||||
const t = useTranslate();
|
||||
|
||||
return (
|
||||
<NumberInput
|
||||
label={label}
|
||||
value={inputValue}
|
||||
min={0}
|
||||
max={999999}
|
||||
precision={0}
|
||||
rightSection={unitSelect}
|
||||
rightSectionWidth={120}
|
||||
onChange={value => {
|
||||
const inputVal = value || 0;
|
||||
setInputValue(inputVal);
|
||||
onChange({ value: inputVal, unit });
|
||||
}}
|
||||
{...restProps}
|
||||
/>
|
||||
);
|
||||
const version = inputValue == 1 ? "singular" : "plural";
|
||||
const unitSelect = (
|
||||
<NativeSelect
|
||||
data={[
|
||||
{
|
||||
value: "minutes",
|
||||
label: t(`upload.modal.expires.minute-${version}`),
|
||||
},
|
||||
{
|
||||
value: "hours",
|
||||
label: t(`upload.modal.expires.hour-${version}`),
|
||||
},
|
||||
{
|
||||
value: "days",
|
||||
label: t(`upload.modal.expires.day-${version}`),
|
||||
},
|
||||
{
|
||||
value: "weeks",
|
||||
label: t(`upload.modal.expires.week-${version}`),
|
||||
},
|
||||
{
|
||||
value: "months",
|
||||
label: t(`upload.modal.expires.month-${version}`),
|
||||
},
|
||||
{
|
||||
value: "years",
|
||||
label: t(`upload.modal.expires.year-${version}`),
|
||||
},
|
||||
]}
|
||||
value={unit}
|
||||
rightSectionWidth={28}
|
||||
styles={{
|
||||
input: {
|
||||
fontWeight: 500,
|
||||
borderTopLeftRadius: 0,
|
||||
borderBottomLeftRadius: 0,
|
||||
width: 120,
|
||||
marginRight: -2,
|
||||
},
|
||||
}}
|
||||
onChange={(event) => {
|
||||
const unit = event.currentTarget.value as Timespan["unit"];
|
||||
setUnit(unit);
|
||||
onChange({ value: inputValue, unit });
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<NumberInput
|
||||
label={label}
|
||||
value={inputValue}
|
||||
min={0}
|
||||
max={999999}
|
||||
precision={0}
|
||||
rightSection={unitSelect}
|
||||
rightSectionWidth={120}
|
||||
onChange={(value) => {
|
||||
const inputVal = value || 0;
|
||||
setInputValue(inputVal);
|
||||
onChange({ value: inputVal, unit });
|
||||
}}
|
||||
{...restProps}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default TimespanInput;
|
||||
|
||||
@@ -20,6 +20,7 @@ import useTranslate, {
|
||||
translateOutsideContext,
|
||||
} from "../../../hooks/useTranslate.hook";
|
||||
import shareService from "../../../services/share.service";
|
||||
import { Timespan } from "../../../types/timespan.type";
|
||||
import { getExpirationPreview } from "../../../utils/date.util";
|
||||
import toast from "../../../utils/toast.util";
|
||||
import FileSizeInput from "../../core/FileSizeInput";
|
||||
@@ -28,7 +29,7 @@ import showCompletedReverseShareModal from "./showCompletedReverseShareModal";
|
||||
const showCreateReverseShareModal = (
|
||||
modals: ModalsContextProps,
|
||||
showSendEmailNotificationOption: boolean,
|
||||
maxExpirationInHours: number,
|
||||
maxExpiration: Timespan,
|
||||
getReverseShares: () => void,
|
||||
) => {
|
||||
const t = translateOutsideContext();
|
||||
@@ -38,7 +39,7 @@ const showCreateReverseShareModal = (
|
||||
<Body
|
||||
showSendEmailNotificationOption={showSendEmailNotificationOption}
|
||||
getReverseShares={getReverseShares}
|
||||
maxExpirationInHours={maxExpirationInHours}
|
||||
maxExpiration={maxExpiration}
|
||||
/>
|
||||
),
|
||||
});
|
||||
@@ -47,12 +48,13 @@ const showCreateReverseShareModal = (
|
||||
const Body = ({
|
||||
getReverseShares,
|
||||
showSendEmailNotificationOption,
|
||||
maxExpirationInHours,
|
||||
maxExpiration,
|
||||
}: {
|
||||
getReverseShares: () => void;
|
||||
showSendEmailNotificationOption: boolean;
|
||||
maxExpirationInHours: number;
|
||||
maxExpiration: Timespan;
|
||||
}) => {
|
||||
console.log(maxExpiration);
|
||||
const modals = useModals();
|
||||
const t = useTranslate();
|
||||
|
||||
@@ -91,13 +93,17 @@ const Body = ({
|
||||
) as moment.unitOfTime.DurationConstructor,
|
||||
);
|
||||
if (
|
||||
maxExpirationInHours != 0 &&
|
||||
expirationDate.isAfter(moment().add(maxExpirationInHours, "hours"))
|
||||
maxExpiration.value != 0 &&
|
||||
expirationDate.isAfter(
|
||||
moment().add(maxExpiration.value, maxExpiration.unit),
|
||||
)
|
||||
) {
|
||||
form.setFieldError(
|
||||
"expiration_num",
|
||||
t("upload.modal.expires.error.too-long", {
|
||||
max: moment.duration(maxExpirationInHours, "hours").humanize(),
|
||||
max: moment
|
||||
.duration(maxExpiration.value, maxExpiration.unit)
|
||||
.humanize(),
|
||||
}),
|
||||
);
|
||||
return;
|
||||
|
||||
@@ -184,7 +184,10 @@ const CreateUploadModalBody = ({
|
||||
options.maxExpiration.value != 0 &&
|
||||
(form.values.never_expires ||
|
||||
expirationDate.isAfter(
|
||||
moment().add(options.maxExpiration.value, options.maxExpiration.unit),
|
||||
moment().add(
|
||||
options.maxExpiration.value,
|
||||
options.maxExpiration.unit,
|
||||
),
|
||||
))
|
||||
) {
|
||||
form.setFieldError(
|
||||
|
||||
@@ -31,8 +31,7 @@ const get = (key: string, configVariables: Config[]): any => {
|
||||
if (configVariable.type == "boolean") return value == "true";
|
||||
if (configVariable.type == "string" || configVariable.type == "text")
|
||||
return value;
|
||||
if (configVariable.type == "timespan")
|
||||
return stringToTimespan(value);
|
||||
if (configVariable.type == "timespan") return stringToTimespan(value);
|
||||
};
|
||||
|
||||
const finishSetup = async (): Promise<AdminConfig[]> => {
|
||||
|
||||
@@ -1,2 +1,8 @@
|
||||
export type TimeUnit = "minutes" | "hours" | "days" | "weeks" | "months" | "years";
|
||||
export type TimeUnit =
|
||||
| "minutes"
|
||||
| "hours"
|
||||
| "days"
|
||||
| "weeks"
|
||||
| "months"
|
||||
| "years";
|
||||
export type Timespan = { value: number; unit: TimeUnit };
|
||||
|
||||
@@ -34,7 +34,7 @@ export const getExpirationPreview = (
|
||||
|
||||
export const timespanToString = (timespan: Timespan) => {
|
||||
return `${timespan.value} ${timespan.unit}`;
|
||||
}
|
||||
};
|
||||
|
||||
export const stringToTimespan = (value: string): Timespan => {
|
||||
return {
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "pingvin-share",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "pingvin-share",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"devDependencies": {
|
||||
"conventional-changelog-cli": "^3.0.0"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pingvin-share",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"scripts": {
|
||||
"format": "cd frontend && npm run format && cd ../backend && npm run format",
|
||||
"lint": "cd frontend && npm run lint && cd ../backend && npm run lint",
|
||||
|
||||
Reference in New Issue
Block a user