Skip to content

Commit

Permalink
ticket previews loading properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ichub committed Sep 27, 2024
1 parent d67f76d commit 5e3e65e
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ export function initGenericIssuanceRoutes(
"/generic-issuance/api/ticket-previews/:email/:orderCode",
async (req, res) => {
checkGenericIssuanceServiceStarted(genericIssuanceService);

const email = checkUrlParam(req, "email");
const orderCode = checkUrlParam(req, "orderCode");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ import {
IBadgeGiftingDB,
IContactSharingDB
} from "../../database/queries/ticketActionDBs";
import { PCDHTTPError } from "../../routing/pcdHttpError";
import { ApplicationContext } from "../../types";
import { logger } from "../../util/logger";
import { DiscordService } from "../discordService";
import { EmailService } from "../emailService";
import { PagerDutyService } from "../pagerDutyService";
import { PersistentCacheService } from "../persistentCacheService";
import { InMemoryPipelineAtomDB } from "./InMemoryPipelineAtomDB";
import { PretixPipeline } from "./pipelines/PretixPipeline";
import { Pipeline, PipelineUser } from "./pipelines/types";
import { CredentialSubservice } from "./subservices/CredentialSubservice";
import { PipelineSubservice } from "./subservices/PipelineSubservice";
Expand Down Expand Up @@ -351,16 +353,30 @@ export class GenericIssuanceService {
email: string,
orderCode: string
): Promise<TicketPreviewResultValue> {
const devconPipelineId = process.env.DEVCON_PIPELINE_ID;
const devconPipeline = (await this.getAllPipelineInstances()).find(
(p) => p.id === devconPipelineId && PretixPipeline.is(p)
) as PretixPipeline | undefined;

if (!devconPipeline) {
throw new PCDHTTPError(
400,
"devcon pipeline not found " + devconPipelineId
);
}

const tickets = await devconPipeline.getAllTickets();

const matchingTickets = tickets.atoms.filter(
(atom) => atom.email === email && atom.orderCode === orderCode
);

const ticketDatas = matchingTickets.map((atom) =>
devconPipeline.atomToPODTicketData(atom, "1234")
);

return {
tickets: [
{
name: "Test",
email: "[email protected]",
ticketSecret: "test",
eventName: "Test Event",
productName: "Test Product"
}
]
tickets: ticketDatas
} satisfies TicketPreviewResultValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ export class PretixPipeline implements BasePipeline {
});
}

private atomToPODTicketData(
public atomToPODTicketData(
atom: PretixAtom,
semaphoreV4Id: string
): IPODTicketData {
Expand Down
1 change: 1 addition & 0 deletions packages/lib/passport-interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@pcd/pcd-collection": "0.11.6",
"@pcd/pcd-types": "0.11.4",
"@pcd/pod": "0.1.7",
"@pcd/pod-ticket-pcd": "0.1.7",
"@pcd/semaphore-group-pcd": "0.11.6",
"@pcd/semaphore-identity-pcd": "0.11.6",
"@pcd/pod-pcd": "0.1.7",
Expand Down
10 changes: 3 additions & 7 deletions packages/lib/passport-interface/src/RequestTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { EdDSAPublicKey } from "@pcd/eddsa-pcd";
import { EdDSATicketPCD, EdDSATicketPCDTypeName } from "@pcd/eddsa-ticket-pcd";
import { PCDAction } from "@pcd/pcd-collection";
import { ArgsOf, PCDOf, PCDPackage, SerializedPCD } from "@pcd/pcd-types";

import { IPODTicketData } from "@pcd/pod-ticket-pcd/src/schema";
import { SerializedSemaphoreGroup } from "@pcd/semaphore-group-pcd";
import { SemaphoreSignaturePCD } from "@pcd/semaphore-signature-pcd";
import { Credential } from "./Credential";
Expand Down Expand Up @@ -1238,11 +1240,5 @@ export type OneClickEmailResponseValue = {
};

export type TicketPreviewResultValue = {
tickets: Array<{
name: string;
email: string;
ticketSecret: string;
eventName: string;
productName: string;
}>;
tickets: Array<IPODTicketData>;
};
3 changes: 3 additions & 0 deletions packages/lib/passport-interface/tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
{
"path": "../pod/tsconfig.cjs.json"
},
{
"path": "../../pcd/pod-ticket-pcd/tsconfig.cjs.json"
},
{
"path": "../../pcd/semaphore-group-pcd/tsconfig.cjs.json"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/lib/passport-interface/tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
{
"path": "../pod/tsconfig.esm.json"
},
{
"path": "../../pcd/pod-ticket-pcd/tsconfig.esm.json"
},
{
"path": "../../pcd/semaphore-group-pcd/tsconfig.esm.json"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/lib/passport-interface/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
{
"path": "../pod"
},
{
"path": "../../pcd/pod-ticket-pcd"
},
{
"path": "../../pcd/semaphore-group-pcd"
},
Expand Down
1 change: 1 addition & 0 deletions packages/pcd/pod-ticket-pcd/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./PODTicketPCD";
export * from "./PODTicketPCDPackage";
export * from "./schema";

0 comments on commit 5e3e65e

Please sign in to comment.