send anchoring notification

This commit is contained in:
Loïs Mansot 2023-09-29 18:47:43 +02:00
parent 6d4d4f05e5
commit f99612a85d
No known key found for this signature in database
GPG Key ID: 8CF1F4150DDA726D
2 changed files with 16 additions and 9 deletions

View File

@ -53,7 +53,7 @@
"express": "^4.18.2",
"fp-ts": "^2.16.1",
"jsonwebtoken": "^9.0.0",
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.86",
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.87",
"module-alias": "^2.2.2",
"monocle-ts": "^2.3.13",
"multer": "^1.4.5-lts.1",

View File

@ -11,6 +11,7 @@ import authHandler from "@App/middlewares/AuthHandler";
import ruleHandler from "@App/middlewares/RulesHandler";
import folderHandler from "@App/middlewares/OfficeMembershipHandlers/FolderHandler";
import OfficeFolderAnchor from "le-coffre-resources/dist/Notary/OfficeFolderAnchor";
import NotificationBuilder from "@Common/notifications/NotificationBuilder";
const hydrateOfficeFolderAnchor = (data: any): OfficeFolderAnchor =>
OfficeFolderAnchor.hydrate<OfficeFolderAnchor>(
@ -33,7 +34,12 @@ const hydrateOfficeFolderAnchor = (data: any): OfficeFolderAnchor =>
@Controller()
@Service()
export default class OfficeFoldersController extends ApiController {
constructor(private secureService: SecureService, private officeFolderAnchorsRepository: OfficeFolderAnchorsRepository, private officeFoldersService: OfficeFoldersService) {
constructor(
private secureService: SecureService,
private officeFolderAnchorsRepository: OfficeFolderAnchorsRepository,
private officeFoldersService: OfficeFoldersService,
private notificationBuilder: NotificationBuilder,
) {
super();
}
@ -76,7 +82,7 @@ export default class OfficeFoldersController extends ApiController {
const sortedHashes = [...folderHashes].sort();
const buffer = await this.secureService.download(sortedHashes);
response.setHeader('Content-Type', 'application/pdf');
response.setHeader("Content-Type", "application/pdf");
this.httpSuccess(response, buffer);
} catch (error) {
this.httpInternalError(response, error);
@ -139,9 +145,7 @@ export default class OfficeFoldersController extends ApiController {
const officeFolderAnchor = hydrateOfficeFolderAnchor(data);
const newOfficeFolderAnchor = await this.officeFolderAnchorsRepository.create(
officeFolderAnchor
);
const newOfficeFolderAnchor = await this.officeFolderAnchorsRepository.create(officeFolderAnchor);
await this.officeFoldersService.update(
uid,
@ -213,9 +217,12 @@ export default class OfficeFoldersController extends ApiController {
const updatedOfficeFolderAnchor = await this.officeFolderAnchorsRepository.update(
officeFolderAnchorFound.uid,
officeFolderAnchor
officeFolderAnchor,
);
if (officeFolderAnchorFound.status !== "VERIFIED_ON_CHAIN" && officeFolderAnchor.status === "VERIFIED_ON_CHAIN")
this.notificationBuilder.sendFolderAnchoredNotification(officeFolderFound);
this.httpSuccess(response, updatedOfficeFolderAnchor);
return;
} catch (error) {