all repos — caroster @ 9c60f22177be092c6ff394254db592cb09737543

[Octree] Group carpool to your event https://caroster.io

🐛 Backend fixes after UX review #500
Tim Izzo tim@octree.ch
Tue, 20 Feb 2024 09:55:26 +0100
commit

9c60f22177be092c6ff394254db592cb09737543

parent

3095e0573ccb511d048f34f1d369bcc2c996e7b9

M backend/src/api/email/locales/en.jsonbackend/src/api/email/locales/en.json

@@ -12,6 +12,10 @@ "DeletedTrip": {

"title": "<%= event.name %> - Car removed", "content": "Car <%= travel.vehicleName %> in which you've subscribed to as been removed. Go to the [Caroster](<%= host %>/e/<%= event.uuid %>) page to find another car." }, + "DeletedYourTrip": { + "title": "<%= event.name %> - Your car has been removed", + "content": "Your car <%= travel.vehicleName %> has been removed by an admin from [<%= event.name %>](<%= host %>/e/<%= event.uuid %>)." + }, "NewPassengerInYourTrip": { "title": "<%= event.name %> - A passenger has been added to your trip", "content": "A passenger has been added to your trip. on Caroster [<%= event.name %>](<%= host %>/e/<%= event.uuid %>)"
M backend/src/api/email/locales/fr.jsonbackend/src/api/email/locales/fr.json

@@ -12,6 +12,10 @@ "DeletedTrip": {

"title": "<%= event.name %> - Voiture supprimée", "content": "La voiture <%= travel.vehicleName %> pour laquelle vous vous êtes inscrit.e.s a été supprimée. Rendez-vous sur la page du [Caroster](<%= host %>/e/<%= event.uuid %>) pour trouver une autre voiture." }, + "DeletedYourTrip": { + "title": "<%= event.name %> - Votre voiture a été supprimée", + "content": "Votre voiture <%= travel.vehicleName %> a été supprimée par un admin de l'événement [<%= event.name %>](<%= host %>/e/<%= event.uuid %>)." + }, "NewPassengerInYourTrip": { "title": "<%= event.name %> - Un passager a été ajouté à votre trajet", "content": "Hey <%= user.firstname %>\n\nUn passager a été ajouté à votre trajet dans le Caroster [<%= event.name %>](<%= host %>/e/<%= event.uuid %>)."
M backend/src/api/notification/content-types/notification/schema.jsonbackend/src/api/notification/content-types/notification/schema.json

@@ -18,6 +18,7 @@ "enum": [

"NewPassengerInYourTrip", "NewTrip", "DeletedTrip", + "DeletedYourTrip", "AddedAsAdmin", "EventCreated", "EventEnded",
M backend/src/api/passenger/policies/check-creation.tsbackend/src/api/passenger/policies/check-creation.ts

@@ -7,7 +7,8 @@ const event = await strapi.entityService.findOne("api::event.event", eventId);

if (!event) throw new errors.NotFoundError(`Event not found`); - if (event.enabled_modules?.includes("caroster-plus") && !user) - throw new errors.ForbiddenError(); - else if (user) policyContext.args.data.user = user.id; + if (event.enabled_modules?.includes("caroster-plus")) { + if (user) policyContext.args.data.user = user.id; + else throw new errors.ForbiddenError(); + } };
M backend/src/api/travel/policies/check-deletion.tsbackend/src/api/travel/policies/check-deletion.ts

@@ -22,7 +22,14 @@ const admins = event.administrators?.split(/, ?/) || [];

const isAdmin = [...admins, event.email].includes(user.email); if (isAdmin) { - // TODO Create notification to travel's linked user + await strapi.entityService.create("api::notification.notification", { + data: { + type: "DeletedYourTrip", + event, + user: travel.user, + payload: { travel }, + }, + }); return true; } else if (travel.user?.email === user.email) return true; else return false;
M backend/types/generated/contentTypes.d.tsbackend/types/generated/contentTypes.d.ts

@@ -965,6 +965,7 @@ [

'NewPassengerInYourTrip', 'NewTrip', 'DeletedTrip', + 'DeletedYourTrip', 'AddedAsAdmin', 'EventCreated', 'EventEnded',
M frontend/locales/en.jsonfrontend/locales/en.json

@@ -125,6 +125,7 @@ "notifications.content": "No notification",

"notification.type.NewPassengerInYourTrip.content": "A passenger has been added to your trip.", "notification.type.NewTrip.content": "A departure close to you is available.", "notification.type.DeletedTrip.content": "A car has been removed.", + "notification.type.DeletedYourTrip.content": "Your car has been removed by an event admin", "notification.type.AddedAsAdmin.content": "You have been added as admin to an event.", "notification.type.PassengerJoinTrip.content": "A passenger wishes to contact.", "notification.type.ContactTripCreator.content": "Contact the driver for your trip.",
M frontend/locales/fr.jsonfrontend/locales/fr.json

@@ -125,6 +125,7 @@ "notifications.content": "Aucune notification",

"notification.type.NewPassengerInYourTrip.content": "Un passager a été ajouté à votre trajet.", "notification.type.NewTrip.content": "Un départ proche de vous est disponible.", "notification.type.DeletedTrip.content": "Une voiture a été supprimée.", + "notification.type.DeletedYourTrip.content": "Votre voiture a été supprimée par un admin de l'événement.", "notification.type.AddedAsAdmin.content": "Vous avez été ajouté en tant qu'admin à un événement.", "notification.type.PassengerJoinTrip.content": "Un passager souhaite prendre contact.", "notification.type.ContactTripCreator.content": "Contactez la conductrice ou le conducteur pour votre trajet.",
M frontend/locales/nl.jsonfrontend/locales/nl.json

@@ -116,6 +116,7 @@ "notifications.content": "",

"notification.type.NewPassengerInYourTrip.content": "", "notification.type.NewTrip.content": "", "notification.type.DeletedTrip.content": "", + "notification.type.DeletedYourTrip.content": "", "notification.type.AddedAsAdmin.content": "", "notification.type.ContactTripCreator.content": "", "notification.type.EnabledCarosterPlus.content": "",
M frontend/locales/pl.jsonfrontend/locales/pl.json

@@ -119,6 +119,7 @@ "notifications.content": "",

"notification.type.NewPassengerInYourTrip.content": "", "notification.type.NewTrip.content": "", "notification.type.DeletedTrip.content": "", + "notification.type.DeletedYourTrip.content": "", "notification.type.AddedAsAdmin.content": "", "notification.type.ContactTripCreator.content": "", "notification.type.EnabledCarosterPlus.content": "",
M frontend/locales/sv.jsonfrontend/locales/sv.json

@@ -116,6 +116,7 @@ "notifications.content": "",

"notification.type.NewPassengerInYourTrip.content": "", "notification.type.NewTrip.content": "", "notification.type.DeletedTrip.content": "", + "notification.type.DeletedYourTrip.content": "", "notification.type.AddedAsAdmin.content": "", "notification.type.ContactTripCreator.content": "", "notification.type.EnabledCarosterPlus.content": "",