Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix event cover upload flow #190

Open
shravanhariharan2 opened this issue May 26, 2021 · 7 comments
Open

Fix event cover upload flow #190

shravanhariharan2 opened this issue May 26, 2021 · 7 comments
Labels
Events Events related issues

Comments

@shravanhariharan2
Copy link
Collaborator

shravanhariharan2 commented May 26, 2021

Right now, the way event uploads happen is by the following order:

  • Admin creates an event
  • Admin uploads a cover for the event

The issue with this is that when an event is created, the cover field is required, but in order for a cover URL to exist, the event has to exist, so there's a dependency loop. The way frontend handles this right now is by sending two requests, the first one with a gibberish cover field that gets immediately updated by the second request. The issue with this, however, is that the requests aren't transacted, so if the upload fails then the event is still created but with a blank cover photo.

Since the both our API and the portal frontend require a cover to exist when the event is created, a proposed solution is to combine uploading and event creation in the same route (i.e. createEvent and editEvent both call StorageService::upload) so that only 1 call is needed, and so that we can transact those calls.

I haven't looked too much into multipart/form-data handling with routing-controllers, but one thing we need to do is change validation since I don't think multipart/form-data can have nested objects/fields, so we would have to do:

{
   "title": string,
   "attendanceCode": string,
   ...
}

instead of

{
  "event": {
      "title": string,
      "attendanceCode": string,
  }
}
@sumeet-bansal
Copy link
Member

Maybe instead of combining the routes, we can do #36, allow NULL event covers, and only allow the event to be published once it has a cover.

@sumeet-bansal
Copy link
Member

Or instead of persisting the event at creation time, we keep it in-memory, and then persist it in the uploadEventCover call.

@sumeet-bansal
Copy link
Member

(Just throwing out ideas.)

@sumeet-bansal
Copy link
Member

Retry uploads, max 3 times?

@sumeet-bansal
Copy link
Member

It's definitely not great that the API has this hole in it though. Combining the routes is probably the best solution, but we should still be able to upload covers after creating the event.

@steets250
Copy link
Member

we should still be able to upload covers after creating the event.

Are you talking about being able to edit an existing event? If so, we can also update the editEvent route to follow a similar idea where it can optionally take in a new event cover and upload it to AWS.

@steets250 steets250 added the Events Events related issues label Nov 16, 2021
@maxwn04
Copy link
Contributor

maxwn04 commented Apr 3, 2024

Add option to create event with existing cover url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Events Events related issues
Projects
None yet
Development

No branches or pull requests

4 participants