-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #683 from desci-labs/feat/auto-mint-doi
feat: Attestation Privileges and Automated DOI Workflow (publish and claim verification)
- Loading branch information
Showing
15 changed files
with
147 additions
and
51 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...erver/prisma/migrations/20241202124458_attestation_doi_and_orcid_privileges/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- AlterTable | ||
ALTER TABLE "Attestation" ADD COLUMN "canMintDoi" BOOLEAN NOT NULL DEFAULT false, | ||
ADD COLUMN "canUpdateOrcid" BOOLEAN NOT NULL DEFAULT false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { NextFunction, Response } from 'express'; | ||
import { Request } from 'express'; | ||
import _ from 'lodash'; | ||
|
||
import { BadRequestError } from '../../../core/ApiError.js'; | ||
import { SuccessResponse } from '../../../core/ApiResponse.js'; | ||
import { MintError } from '../../../core/doi/error.js'; | ||
import { logger as parentLogger } from '../../../logger.js'; | ||
import { RequestWithUser } from '../../../middleware/authorisation.js'; | ||
import { getTargetDpidUrl } from '../../../services/fixDpid.js'; | ||
import { doiService } from '../../../services/index.js'; | ||
import { DiscordChannel, discordNotify, DiscordNotifyType } from '../../../utils/discordUtils.js'; | ||
import { ensureUuidEndsWithDot } from '../../../utils.js'; | ||
|
||
const logger = parentLogger.child({ module: 'ADMIN::DOI' }); | ||
|
||
export const listDoiRecords = async (_req: RequestWithUser, res: Response, _next: NextFunction) => { | ||
const data = await doiService.listDoi(); | ||
logger.info({ data }, 'List DOIs'); | ||
new SuccessResponse(data).send(res); | ||
}; | ||
|
||
export const mintDoi = async (req: Request, res: Response, _next: NextFunction) => { | ||
const { uuid } = req.params; | ||
if (!uuid) throw new BadRequestError(); | ||
const sanitizedUuid = ensureUuidEndsWithDot(uuid); | ||
const isPending = await doiService.hasPendingSubmission(sanitizedUuid); | ||
if (isPending) { | ||
throw new MintError('You have a pending submission'); | ||
} else { | ||
const submission = await doiService.mintDoi(sanitizedUuid); | ||
const data = _.pick(submission, ['id', 'status']); | ||
new SuccessResponse(data).send(res); | ||
|
||
const targetDpidUrl = getTargetDpidUrl(); | ||
discordNotify({ | ||
channel: DiscordChannel.DoiMinting, | ||
type: DiscordNotifyType.INFO, | ||
title: 'Mint DOI', | ||
message: `${targetDpidUrl}/${submission.dpid} sent a request to mint: ${submission.uniqueDoi}`, | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.