Tietokilta / ilmomasiina

Event signup system for tietokilta.fi and beyond
MIT License
1 stars 9 forks source link

checkSlugAvailability doesn't take into account soft-deleted events #142

Open ApsiV11 opened 3 weeks ago

ApsiV11 commented 3 weeks ago

Event model is currently defined with paranoid: true. This causes a soft deletion to happen when an event is deleted so the deletedAt is set to non-null timestamp and the event is not actually deleted.

checkSlugAvailability doesn't take into account soft deleted events so it returns available to frontend when a slug that is used in a previous soft deleted event is used again. However trying to save the event causes a unique constraint conflict since slug is defined as unique.

Possible fixes would to be actually delete the event completely on deletion, checking also soft deleted events in checkSlugAvailability or upserting the soft deleted event on trying to use the same slug.

In FK repo, fixed this with just checking also soft deleted events. https://github.com/fyysikkokilta/ilmomasiina/commit/1e5240757f155d6637c2144f13d90fef224e230d

ApsiV11 commented 3 weeks ago

Ah so there is a cron-job that deletes soft deleted events after 14 days or the set amount of time. Removing straight away wouldn't be desirable then.