Notif finished

This commit is contained in:
Vins 2023-09-22 10:51:38 +02:00
parent 643ba11732
commit d45fee73e5
3 changed files with 417 additions and 397 deletions

802
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -52,7 +52,7 @@
"cron": "^2.3.1",
"express": "^4.18.2",
"jsonwebtoken": "^9.0.0",
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.72",
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.79",
"module-alias": "^2.2.2",
"multer": "^1.4.5-lts.1",
"next": "^13.1.5",

View File

@ -10,15 +10,11 @@ export default class NotificationBuilder {
public constructor(private notificationsService : NotificationsService, private documentsService: DocumentsService){}
public async sendDocumentDepositedNotification(documentEntity: Documents){
console.log(documentEntity);
if(documentEntity.document_status !== "DEPOSITED") return;
const documentPrisma = await this.documentsService.getByUid(documentEntity.uid, { depositor: {include: {contact: true}}, folder:{include:{ office: true, stakeholders: true}} });
if(!documentPrisma) throw new Error("Document not found");
const document = Document.hydrate<Document>(documentPrisma);
console.log(document);
this.notificationsService.create({
message: "Document déposé",
@ -33,16 +29,16 @@ export default class NotificationBuilder {
public async sendDocumentAnchoredNotificatiom(documentEntity: Documents){
if(documentEntity.document_status !== "ANCHORED") return;
const documentPrisma = await this.documentsService.getByUid(documentEntity.uid, { depositor: {include: {contact: true}}, folder:{include:{ office: true}} });
const documentPrisma = await this.documentsService.getByUid(documentEntity.uid, { depositor: {include: {contact: true}}, folder:{include:{ office: true, stakeholders: true}} });
if(!documentPrisma) throw new Error("Document not found");
const document = Document.hydrate<Document>(documentPrisma);
console.log(document);
this.notificationsService.create({
message: "Document anchré",
message: "Document ancré",
redirection_url: "",
created_at: new Date(),
updated_at: new Date(),
user : document.folder!.stakeholders || [],
});
}