update anchor when requesting secure status
This commit is contained in:
parent
ab4fac8e01
commit
279ea66a50
@ -174,9 +174,10 @@ export default class OfficeFoldersController extends ApiController {
|
||||
files: true,
|
||||
},
|
||||
},
|
||||
folder_anchor: true,
|
||||
};
|
||||
|
||||
const officeFolderFound = await this.officeFoldersService.getByUid(uid, query);
|
||||
const officeFolderFound: any = await this.officeFoldersService.getByUid(uid, query);
|
||||
|
||||
if (!officeFolderFound) {
|
||||
this.httpNotFoundRequest(response, "Office folder not found");
|
||||
@ -192,9 +193,31 @@ export default class OfficeFoldersController extends ApiController {
|
||||
}
|
||||
|
||||
const sortedHashes = [...folderHashes].sort();
|
||||
const anchor = await this.secureService.verify(sortedHashes);
|
||||
const officeFolderAnchorFound = OfficeFolderAnchor.hydrate<OfficeFolderAnchor>(officeFolderFound.folder_anchor, {
|
||||
strategy: "excludeAll",
|
||||
});
|
||||
|
||||
this.httpSuccess(response, anchor);
|
||||
if (!officeFolderAnchorFound || !officeFolderAnchorFound.uid) {
|
||||
this.httpNotFoundRequest(response, {error: "Not anchored", hash_sources: sortedHashes});
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await this.secureService.verify(sortedHashes);
|
||||
|
||||
if (data.errors || data.transactions.length === 0) {
|
||||
this.httpNotFoundRequest(response, {error: "Not anchored", hash_sources: sortedHashes});
|
||||
return;
|
||||
}
|
||||
|
||||
const officeFolderAnchor = hydrateOfficeFolderAnchor(data);
|
||||
|
||||
const updatedOfficeFolderAnchor = await this.officeFolderAnchorsRepository.update(
|
||||
officeFolderAnchorFound.uid,
|
||||
officeFolderAnchor
|
||||
);
|
||||
|
||||
this.httpSuccess(response, updatedOfficeFolderAnchor);
|
||||
return;
|
||||
} catch (error) {
|
||||
this.httpInternalError(response, error);
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user