Skip to content

Automated event creation for submitted event requests#12

Open
dokicaaa wants to merge 1 commit into
mainfrom
events-backend-suport
Open

Automated event creation for submitted event requests#12
dokicaaa wants to merge 1 commit into
mainfrom
events-backend-suport

Conversation

@dokicaaa
Copy link
Copy Markdown
Contributor

@dokicaaa dokicaaa commented May 8, 2026

  • When a user submits a form it creates both an event request and event as a draft.
  • Sets default status value to "pending"
  • Links them together via ID
  • If event gets published -> hook changes status to "approved" -> sends email to user that the event has been approved -> adds event to collection.

@dokicaaa dokicaaa requested a review from BojanaAri May 10, 2026 15:07
Copy link
Copy Markdown
Contributor

@BojanaAri BojanaAri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good 👍


import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('api::event-request.event-request');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this line removed, you are removing all of the default routes (find, findOne, update,..etc) from strapi for event-request. This means that you are overriding the default routes and only adding one route for the event-request content type.
Inside the cms folder, run npm run strapi routes:list and you will see :)

Comment thread cms/src/index.ts

const FIREBASE_FCM_CREDENTIALS_PATH = './base42-mobile-app-fcm-firebase-adminsdk.json';

const eventRequestApprovalMiddleware = () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Export this middleware to a new file, the same way event-notifications is handled

documentId: id,
populate: ['event' as any],
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also verify if the user is authorized for an additional check.

Suggested change
if (!user) {
return ctx.unauthorized();
}


const request: any = await strapi.documents('api::event-request.event-request').findOne({
documentId: id,
populate: ['event' as any],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is any needed here?
I think populate: ['event'] is enough

async approve(ctx) {
const { id } = ctx.params;

const request: any = await strapi.documents('api::event-request.event-request').findOne({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try not to use any a lot, maybe define a type for the request. (& everywhere that can be changed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants