Skip to content

Commit

Permalink
Functions: Clean up webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Kündig committed Jan 24, 2025
1 parent 7f0eac7 commit b8afaca
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 56 deletions.
2 changes: 1 addition & 1 deletion admin/src/actions/CreateDonationCertificatesAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function CreateDonationCertificatesAction({ selectionController }: Collec
const functions = getFunctions(undefined, DEFAULT_REGION);
const createDonationCertificatesFunction = httpsCallable<CreateDonationCertificatesProps, string>(
functions,
'createDonationCertificates',
'webhookCreateDonationCertificates',
);

const onClick = () => {
Expand Down
2 changes: 1 addition & 1 deletion admin/src/actions/CreatePaymentForecastAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function CreatePaymentForecastAction() {
const snackbarController = useSnackbarController();

const createPaymentForecast = () => {
const runPaymentForecastTask = httpsCallable(getFunctions(undefined, DEFAULT_REGION), 'runPaymentForecastTask');
const runPaymentForecastTask = httpsCallable(getFunctions(undefined, DEFAULT_REGION), 'webhookPaymentForecastTask');
runPaymentForecastTask()
.then((result) => {
snackbarController.open({ type: 'success', message: 'Payment forecast updated successfully' });
Expand Down
2 changes: 1 addition & 1 deletion admin/src/actions/PaymentProcessAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function PaymentProcessAction() {
const triggerFirebaseFunction = (task: PaymentProcessTaskType) => {
const runPaymentProcessTask = httpsCallable<PaymentProcessProps, string>(
getFunctions(undefined, DEFAULT_REGION),
'runPaymentProcessTask',
'webhookPaymentProcessTask',
);
setIsFunctionRunning(true);
runPaymentProcessTask({
Expand Down
6 changes: 3 additions & 3 deletions admin/src/views/ScriptsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function ScriptsView() {
type: 'success',
message: 'Starting import',
});
httpsCallable(functions, 'batchImportStripeCharges')()
httpsCallable(functions, 'webhookBatchImportStripeCharges')()
.then(() => {
snackbarController.open({
type: 'success',
Expand All @@ -32,7 +32,7 @@ export function ScriptsView() {
type: 'success',
message: 'Starting creating surveys',
});
httpsCallable(functions, 'createAllSurveys')()
httpsCallable(functions, 'webhookCreateAllSurveys')()
.then(() => {
snackbarController.open({
type: 'success',
Expand All @@ -53,7 +53,7 @@ export function ScriptsView() {
type: 'success',
message: 'Starting adding amount_chf',
});
httpsCallable(functions, 'addMissingAmountChf')()
httpsCallable(functions, 'webhookAddMissingAmountChf')()
.then(() => {
snackbarController.open({
type: 'success',
Expand Down
2 changes: 0 additions & 2 deletions functions/src/functions/webhooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
createAllSurveysFunction,
} from './admin/scripts';
import stripeWebhookFunction from './stripe';
import surveyLoginFunction from './website/survey-login';

export const webhookPaymentProcessTask = paymentProcessFunction;
export const webhookPaymentForecastTask = paymentForecastFunction;
Expand All @@ -18,6 +17,5 @@ export const webhookCreateAllSurveys = createAllSurveysFunction;

// Do not rename this function, it is used by the Stripe webhook.
export const webhookStripeCharge = stripeWebhookFunction;
export const webhookSurveyCredentials = surveyLoginFunction;

export const webhookCreateDonationCertificates = createDonationCertificatesFunction;
34 changes: 0 additions & 34 deletions functions/src/functions/webhooks/website/survey-login/index.ts

This file was deleted.

15 changes: 1 addition & 14 deletions shared/src/types/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,8 @@ export const recipientSurveys = [
{ name: 'offboarded-checkin-4', startDateOffsetMonths: 72, questionaire: SurveyQuestionnaire.OffboardedCheckin },
];

export interface SurveyCredentialRequest {
phoneNumber: string;
accessToken: string;
}

export interface SurveyCredentialResponse {
recipientId: string;
surveyId: string;
email: string;
pw: string;
}

export const getSurveyUrl = (baseUrl: string, survey: Survey, surveyId: string, recipientId: string) => {
const url = new URL([baseUrl, 'survey', recipientId, surveyId].join('/'));
const getParams = { email: survey.access_email, pw: survey.access_pw };
url.search = new URLSearchParams(getParams).toString();
url.search = new URLSearchParams({ email: survey.access_email, pw: survey.access_pw }).toString();
return url.toString();
};

0 comments on commit b8afaca

Please sign in to comment.