chore: Add key column key to files_notary table
This commit is contained in:
parent
bb9547be9b
commit
2eddba94be
@ -0,0 +1,2 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "files_notary" ADD COLUMN "key" VARCHAR(255);
|
@ -80,6 +80,7 @@ model Whitelist {
|
|||||||
active Boolean @default(true)
|
active Boolean @default(true)
|
||||||
created_at DateTime? @default(now())
|
created_at DateTime? @default(now())
|
||||||
updated_at DateTime? @updatedAt
|
updated_at DateTime? @updatedAt
|
||||||
|
|
||||||
@@map("whitelist")
|
@@map("whitelist")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +90,7 @@ model UserWhitelist {
|
|||||||
active Boolean @default(true)
|
active Boolean @default(true)
|
||||||
created_at DateTime? @default(now())
|
created_at DateTime? @default(now())
|
||||||
updated_at DateTime? @updatedAt
|
updated_at DateTime? @updatedAt
|
||||||
|
|
||||||
@@map("user_whitelist")
|
@@map("user_whitelist")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,6 +133,7 @@ model Customers {
|
|||||||
office_uid String @db.VarChar(255)
|
office_uid String @db.VarChar(255)
|
||||||
notes Notes[]
|
notes Notes[]
|
||||||
documents_notary DocumentsNotary[]
|
documents_notary DocumentsNotary[]
|
||||||
|
|
||||||
@@map("customers")
|
@@map("customers")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +237,7 @@ model DocumentsNotary {
|
|||||||
files FilesNotary[]
|
files FilesNotary[]
|
||||||
customer Customers @relation(fields: [customer_uid], references: [uid], onDelete: Cascade)
|
customer Customers @relation(fields: [customer_uid], references: [uid], onDelete: Cascade)
|
||||||
customer_uid String @db.VarChar(255)
|
customer_uid String @db.VarChar(255)
|
||||||
document String @db.VarChar(255) @default("")
|
document String @default("") @db.VarChar(255)
|
||||||
|
|
||||||
@@map("documents_notary")
|
@@map("documents_notary")
|
||||||
}
|
}
|
||||||
@ -288,6 +291,7 @@ model FilesNotary {
|
|||||||
mimetype String @db.VarChar(255)
|
mimetype String @db.VarChar(255)
|
||||||
hash String @db.VarChar(255)
|
hash String @db.VarChar(255)
|
||||||
size Int
|
size Int
|
||||||
|
key String? @db.VarChar(255)
|
||||||
created_at DateTime? @default(now())
|
created_at DateTime? @default(now())
|
||||||
updated_at DateTime? @updatedAt
|
updated_at DateTime? @updatedAt
|
||||||
|
|
||||||
@ -373,8 +377,9 @@ model Rules {
|
|||||||
updated_at DateTime? @updatedAt
|
updated_at DateTime? @updatedAt
|
||||||
role Roles[] @relation("RolesHasRules")
|
role Roles[] @relation("RolesHasRules")
|
||||||
office_roles OfficeRoles[] @relation("OfficeRolesHasRules")
|
office_roles OfficeRoles[] @relation("OfficeRolesHasRules")
|
||||||
namespace String @db.VarChar(255) @default("notary")
|
namespace String @default("notary") @db.VarChar(255)
|
||||||
groups RulesGroups[] @relation("RulesGroupsHasRules")
|
groups RulesGroups[] @relation("RulesGroupsHasRules")
|
||||||
|
|
||||||
@@map("rules")
|
@@map("rules")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,6 +389,7 @@ model RulesGroups {
|
|||||||
created_at DateTime? @default(now())
|
created_at DateTime? @default(now())
|
||||||
updated_at DateTime? @updatedAt
|
updated_at DateTime? @updatedAt
|
||||||
rules Rules[] @relation("RulesGroupsHasRules")
|
rules Rules[] @relation("RulesGroupsHasRules")
|
||||||
|
|
||||||
@@map("rules_groups")
|
@@map("rules_groups")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,6 +441,7 @@ model TotpCodes {
|
|||||||
expire_at DateTime? @default(now())
|
expire_at DateTime? @default(now())
|
||||||
created_at DateTime? @default(now())
|
created_at DateTime? @default(now())
|
||||||
updated_at DateTime? @updatedAt
|
updated_at DateTime? @updatedAt
|
||||||
|
|
||||||
@@map("totp_codes")
|
@@map("totp_codes")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,6 +458,7 @@ model Subscriptions {
|
|||||||
seats Seats[]
|
seats Seats[]
|
||||||
created_at DateTime? @default(now())
|
created_at DateTime? @default(now())
|
||||||
updated_at DateTime? @updatedAt
|
updated_at DateTime? @updatedAt
|
||||||
|
|
||||||
@@map("subscriptions")
|
@@map("subscriptions")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,6 +470,7 @@ model Seats {
|
|||||||
user_uid String @db.VarChar(255)
|
user_uid String @db.VarChar(255)
|
||||||
created_at DateTime? @default(now())
|
created_at DateTime? @default(now())
|
||||||
updated_at DateTime? @updatedAt
|
updated_at DateTime? @updatedAt
|
||||||
|
|
||||||
@@map("seats")
|
@@map("seats")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,6 +483,7 @@ model Notes {
|
|||||||
customer_uid String @db.VarChar(255)
|
customer_uid String @db.VarChar(255)
|
||||||
folder OfficeFolders @relation(fields: [folder_uid], references: [uid], onDelete: Cascade)
|
folder OfficeFolders @relation(fields: [folder_uid], references: [uid], onDelete: Cascade)
|
||||||
folder_uid String @db.VarChar(255)
|
folder_uid String @db.VarChar(255)
|
||||||
|
|
||||||
@@map("notes")
|
@@map("notes")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ export default class FilesNotaryRepository extends BaseRepository {
|
|||||||
mimetype: file.mimetype,
|
mimetype: file.mimetype,
|
||||||
hash: file.hash,
|
hash: file.hash,
|
||||||
size: file.size,
|
size: file.size,
|
||||||
|
key: key,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return this.model.create({ ...createArgs, include: { document_notary: true } });
|
return this.model.create({ ...createArgs, include: { document_notary: true } });
|
||||||
|
@ -61,10 +61,10 @@ export default class FilesNotaryService extends BaseService {
|
|||||||
*/
|
*/
|
||||||
public async download(uid: string) {
|
public async download(uid: string) {
|
||||||
const file = await this.filesNotaryRepository.findOneByUid(uid);
|
const file = await this.filesNotaryRepository.findOneByUid(uid);
|
||||||
if (!file?.uid) return null;
|
if (!file?.key) return null;
|
||||||
const fileResult = await fetch(file.file_path.concat("?pinataGatewayToken=").concat(this.variables.PINATA_GATEWAY_TOKEN));
|
const fileResult = await fetch(file.file_path.concat("?pinataGatewayToken=").concat(this.variables.PINATA_GATEWAY_TOKEN));
|
||||||
const fileArrayBuffer = await fileResult.arrayBuffer();
|
const fileArrayBuffer = await fileResult.arrayBuffer();
|
||||||
return { file: file, buffer: await this.cryptoService.decrypt(Buffer.from(fileArrayBuffer), file.uid) };
|
return { file: file, buffer: await this.cryptoService.decrypt(Buffer.from(fileArrayBuffer), file.key) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user