Skip to content

Commit 43df723

Browse files
authored
Expose Participant hashid over hashed user id for the badge qr code (#4370)
1 parent 863d7f6 commit 43df723

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

backend/api/participants/queries.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ def participant(info: Info, id: strawberry.ID, conference: str) -> Participant |
2727

2828

2929
@strawberry.field
30-
def ticket_id_to_user_hashid(
31-
ticket_id: strawberry.ID, conference_code: str
32-
) -> str | None:
30+
def ticket_id_to_hashid(ticket_id: strawberry.ID, conference_code: str) -> str | None:
3331
conference = Conference.objects.filter(code=conference_code).first()
3432
decoded_ticket_id = decode_hashid(ticket_id)
3533
order_position = pretix.get_order_position(conference, decoded_ticket_id)
@@ -43,8 +41,10 @@ def ticket_id_to_user_hashid(
4341
if not attendee_user:
4442
return None
4543

46-
user_id = attendee_user.id
47-
return encode_hashid(int(user_id), salt=settings.USER_ID_HASH_SALT, min_length=6)
44+
participant = ParticipantModel.objects.filter(
45+
conference=conference, user=attendee_user
46+
).first()
47+
return participant.hashid
4848

4949

5050
# TODO: move this to a badge app :)
@@ -81,5 +81,5 @@ def conference_role_for_ticket_data(
8181

8282
ParticipantQueries = create_type(
8383
"ParticipantQueries",
84-
(participant, ticket_id_to_user_hashid, conference_role_for_ticket_data),
84+
(participant, ticket_id_to_hashid, conference_role_for_ticket_data),
8585
)

frontend/src/pages/b/[hashid].tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import type { GetServerSideProps } from "next";
22

33
import { getApolloClient } from "~/apollo/client";
4-
import { queryTicketIdToUserHashid } from "~/types";
4+
import { queryTicketIdToHashid } from "~/types";
55

66
export const getServerSideProps: GetServerSideProps = async ({
77
req,
88
params,
99
}) => {
1010
const hashid = params.hashid as string;
1111
const client = getApolloClient(null, req.cookies);
12-
const result = await queryTicketIdToUserHashid(client, {
12+
const result = await queryTicketIdToHashid(client, {
1313
ticketId: hashid,
1414
conference: process.env.conferenceCode,
1515
});
1616

17-
if (result.data?.ticketIdToUserHashid) {
17+
if (result.data?.ticketIdToHashid) {
1818
return {
1919
redirect: {
20-
destination: `/profile/${result.data.ticketIdToUserHashid}`,
20+
destination: `/profile/${result.data.ticketIdToHashid}`,
2121
permanent: false,
2222
},
2323
};

frontend/src/pages/b/query.graphql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
query TicketIdToUserHashid($ticketId: ID!, $conference: String!) {
2-
ticketIdToUserHashid(ticketId: $ticketId, conferenceCode: $conference)
1+
query TicketIdToHashid($ticketId: ID!, $conference: String!) {
2+
ticketIdToHashid(ticketId: $ticketId, conferenceCode: $conference)
33
}

0 commit comments

Comments
 (0)