Add public theme
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 2m52s

This commit is contained in:
Arnaud Delcasse
2026-01-30 18:44:17 +01:00
parent 2333bba79b
commit b5e722ff9b
23 changed files with 249 additions and 112 deletions

View File

@@ -212,7 +212,7 @@ func (h *ApplicationHandler) GetOrganizedCarpoolOverview(ctx context.Context, st
}
}
beneficiariesMap, err := h.services.GetBeneficiariesMap()
beneficiariesMap, err := h.services.GetBeneficiariesMap(ctx)
if err != nil {
beneficiariesMap = map[string]mobilityaccountsstorage.Account{}
}
@@ -403,12 +403,12 @@ func (h *ApplicationHandler) GetOrganizedCarpoolBookingData(ctx context.Context,
return nil, fmt.Errorf("carpool booking not found")
}
driver, err := h.services.GetAccount(resp.Booking.Driver.Id)
driver, err := h.services.GetAccount(ctx, resp.Booking.Driver.Id)
if err != nil {
return nil, fmt.Errorf("driver retrieval issue: %w", err)
}
passenger, err := h.services.GetAccount(resp.Booking.Passenger.Id)
passenger, err := h.services.GetAccount(ctx, resp.Booking.Passenger.Id)
if err != nil {
return nil, fmt.Errorf("passenger retrieval issue: %w", err)
}
@@ -585,7 +585,7 @@ type OrganizedCarpoolDriverDataResult struct {
func (h *ApplicationHandler) GetOrganizedCarpoolDriverData(ctx context.Context, driverID string) (*OrganizedCarpoolDriverDataResult, error) {
documents := h.filestorage.List(filestorage.PREFIX_ORGANIZED_CARPOOL_DRIVERS + "/" + driverID)
driver, err := h.services.GetAccount(driverID)
driver, err := h.services.GetAccount(ctx, driverID)
if err != nil {
return nil, fmt.Errorf("issue retrieving driver account: %w", err)
}
@@ -686,7 +686,7 @@ type OrganizedCarpoolDriverResult struct {
}
func (h *ApplicationHandler) GetOrganizedCarpoolDriver(ctx context.Context, driverID string) (*OrganizedCarpoolDriverResult, error) {
driver, err := h.services.GetAccount(driverID)
driver, err := h.services.GetAccount(ctx, driverID)
if err != nil {
return nil, fmt.Errorf("issue retrieving driver account: %w", err)
}
@@ -703,7 +703,7 @@ func (h *ApplicationHandler) GetOrganizedCarpoolDriver(ctx context.Context, driv
func (h *ApplicationHandler) UpdateOrganizedCarpoolDriver(ctx context.Context, driverID, firstName, lastName, email string, birthdate *time.Time, phoneNumber, fileNumber string, address, addressDestination any, gender, otherProperties string) (string, error) {
// Security check: verify the account exists and is an organized carpool driver
driver, err := h.services.GetAccount(driverID)
driver, err := h.services.GetAccount(ctx, driverID)
if err != nil {
return "", fmt.Errorf("issue retrieving driver account: %w", err)
}
@@ -786,7 +786,7 @@ func (h *ApplicationHandler) UpdateOrganizedCarpoolDriver(ctx context.Context, d
func (h *ApplicationHandler) ArchiveOrganizedCarpoolDriver(ctx context.Context, driverID string) error {
// Security check: verify the account exists and is an organized carpool driver
driver, err := h.services.GetAccount(driverID)
driver, err := h.services.GetAccount(ctx, driverID)
if err != nil {
return fmt.Errorf("issue retrieving driver account: %w", err)
}
@@ -815,7 +815,7 @@ func (h *ApplicationHandler) ArchiveOrganizedCarpoolDriver(ctx context.Context,
func (h *ApplicationHandler) UnarchiveOrganizedCarpoolDriver(ctx context.Context, driverID string) error {
// Security check: verify the account exists and is an organized carpool driver
driver, err := h.services.GetAccount(driverID)
driver, err := h.services.GetAccount(ctx, driverID)
if err != nil {
return fmt.Errorf("issue retrieving driver account: %w", err)
}
@@ -844,7 +844,7 @@ func (h *ApplicationHandler) UnarchiveOrganizedCarpoolDriver(ctx context.Context
func (h *ApplicationHandler) AddOrganizedCarpoolDriverDocument(ctx context.Context, driverID string, file io.Reader, filename string, fileSize int64, documentType, documentName string) error {
// Security check: verify the account exists and is an organized carpool driver
driver, err := h.services.GetAccount(driverID)
driver, err := h.services.GetAccount(ctx, driverID)
if err != nil {
return fmt.Errorf("issue retrieving driver account: %w", err)
}
@@ -876,7 +876,7 @@ func (h *ApplicationHandler) DeleteOrganizedCarpoolDriverDocument(ctx context.Co
func (h *ApplicationHandler) AddOrganizedCarpoolTrip(ctx context.Context, driverID, outwardtime, returntime string, departure, destination *geojson.Feature, days map[string]bool) error {
// Security check: verify the account exists and is an organized carpool driver
driver, err := h.services.GetAccount(driverID)
driver, err := h.services.GetAccount(ctx, driverID)
if err != nil {
return fmt.Errorf("issue retrieving driver account: %w", err)
}
@@ -911,14 +911,18 @@ func (h *ApplicationHandler) AddOrganizedCarpoolTrip(ctx context.Context, driver
for day, enabled := range days {
if enabled {
dayCode := dayMap[day]
outwardschedules = append(outwardschedules, map[string]any{
"day": dayCode,
"time_of_day": outwardtime,
})
returnschedules = append(returnschedules, map[string]any{
"day": dayCode,
"time_of_day": returntime,
})
if outwardtime != "" {
outwardschedules = append(outwardschedules, map[string]any{
"day": dayCode,
"time_of_day": outwardtime,
})
}
if returntime != "" {
returnschedules = append(returnschedules, map[string]any{
"day": dayCode,
"time_of_day": returntime,
})
}
}
}
@@ -962,12 +966,24 @@ func (h *ApplicationHandler) AddOrganizedCarpoolTrip(ctx context.Context, driver
return fmt.Errorf("failed marshaling return geojson: %w", err)
}
trips = append(trips, &proto.CarpoolFeatureCollection{
Serialized: string(outwardtrip),
})
trips = append(trips, &proto.CarpoolFeatureCollection{
Serialized: string(returntrip),
})
// Only add outward trip if outward time is provided
if outwardtime != "" {
trips = append(trips, &proto.CarpoolFeatureCollection{
Serialized: string(outwardtrip),
})
}
// Only add return trip if return time is provided
if returntime != "" {
trips = append(trips, &proto.CarpoolFeatureCollection{
Serialized: string(returntrip),
})
}
// If no trips to create, return early
if len(trips) == 0 {
return fmt.Errorf("at least one time (outward or return) must be provided")
}
req := &proto.CreateRegularRoutesRequest{
Routes: trips,
@@ -1016,21 +1032,21 @@ func (h *ApplicationHandler) GetOrganizedCarpoolJourneyData(ctx context.Context,
return nil, fmt.Errorf("could not unmarshal carpool journey: %w", err)
}
driver, err := h.services.GetAccount(driverID)
driver, err := h.services.GetAccount(ctx, driverID)
if err != nil {
return nil, fmt.Errorf("could not get driver: %w", err)
}
var passenger mobilityaccountsstorage.Account
if passengerID != "" {
passenger, err = h.services.GetAccount(passengerID)
passenger, err = h.services.GetAccount(ctx, passengerID)
if err != nil {
return nil, fmt.Errorf("could not get passenger account: %w", err)
}
}
// Get beneficiaries in current user's group
beneficiaries, err := h.services.GetBeneficiariesInGroup(currentUserGroup)
beneficiaries, err := h.services.GetBeneficiariesInGroup(ctx, currentUserGroup)
if err != nil {
return nil, fmt.Errorf("could not get beneficiaries: %w", err)
}
@@ -1192,7 +1208,7 @@ func (h *ApplicationHandler) CreateOrganizedCarpoolJourneyBooking(ctx context.Co
// Get passenger account and calculate pricing
var passenger mobilityaccountsstorage.Account
if passengerID != "" {
passenger, err = h.services.GetAccount(passengerID)
passenger, err = h.services.GetAccount(ctx, passengerID)
if err != nil {
return "", fmt.Errorf("could not get passenger account: %w", err)
}
@@ -1268,7 +1284,7 @@ func (h *ApplicationHandler) CreateOrganizedCarpoolJourneyBooking(ctx context.Co
if message != "" && !doNotSend {
send_message := strings.ReplaceAll(message, "{booking_id}", bookingRes.Booking.Id)
log.Debug().Str("message", send_message).Msg("Carpool booking created: sending message")
h.GenerateSMS(driverID, send_message)
h.GenerateSMS(ctx, driverID, send_message)
}
return bookingRes.Booking.Id, nil
@@ -1403,7 +1419,7 @@ func (h *ApplicationHandler) GetOrganizedCarpoolBookings(ctx context.Context, st
}
// Get beneficiaries
beneficiariesMap, err := h.services.GetBeneficiariesMap()
beneficiariesMap, err := h.services.GetBeneficiariesMap(ctx)
if err != nil {
beneficiariesMap = map[string]mobilityaccountsstorage.Account{}
}