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:
@@ -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 });
|
||||
}
|
||||
|
||||
9
backend/src/share/dto/myShareSecurity.dto.ts
Normal file
9
backend/src/share/dto/myShareSecurity.dto.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Expose } from "class-transformer";
|
||||
|
||||
export class MyShareSecurityDTO {
|
||||
@Expose()
|
||||
passwordProtected: boolean;
|
||||
|
||||
@Expose()
|
||||
maxViews: number;
|
||||
}
|
||||
@@ -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,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user