feat(MyShares): show information about own share security options (#720)

* Provide security information about owned shares

* Add visitor count display for shares with max views

* Add password protection indicator to shares table

* Remove validation from MyShareSecurityDTO

* center lock icon and add spacing

* refactor: run formatter

---------

Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
Aaron
2024-12-31 15:21:00 +01:00
committed by GitHub
parent 4d3aa398a2
commit b58dcdba0b
7 changed files with 60 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ import { Expose, plainToClass, Type } from "class-transformer";
import { ShareDTO } from "./share.dto";
import { FileDTO } from "../../file/dto/file.dto";
import { OmitType } from "@nestjs/swagger";
import { MyShareSecurityDTO } from "./myShareSecurity.dto";
export class MyShareDTO extends OmitType(ShareDTO, [
"files",
@@ -21,6 +22,9 @@ export class MyShareDTO extends OmitType(ShareDTO, [
@Type(() => OmitType(FileDTO, ["share", "from"] as const))
files: Omit<FileDTO, "share" | "from">[];
@Expose()
security?: MyShareSecurityDTO;
from(partial: Partial<MyShareDTO>) {
return plainToClass(MyShareDTO, partial, { excludeExtraneousValues: true });
}

View File

@@ -0,0 +1,9 @@
import { Expose } from "class-transformer";
export class MyShareSecurityDTO {
@Expose()
passwordProtected: boolean;
@Expose()
maxViews: number;
}

View File

@@ -233,7 +233,7 @@ export class ShareService {
orderBy: {
expiration: "desc",
},
include: { recipients: true, files: true },
include: { recipients: true, files: true, security: true },
});
return shares.map((share) => {
@@ -241,6 +241,10 @@ export class ShareService {
...share,
size: share.files.reduce((acc, file) => acc + parseInt(file.size), 0),
recipients: share.recipients.map((recipients) => recipients.email),
security: {
maxViews: share.security?.maxViews,
passwordProtected: !!share.security?.password,
},
};
});
}