Add public theme
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 2m52s
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 2m52s
This commit is contained in:
@@ -183,7 +183,7 @@ func filterBookingsByGeography(bookings []*solidaritytypes.Booking, departurePol
|
||||
|
||||
func (h *ApplicationHandler) GetSolidarityTransportOverview(ctx context.Context, status, driverID, startDate, endDate, departureGeoLayer, departureGeoCode, destinationGeoLayer, destinationGeoCode, passengerAddressGeoLayer, passengerAddressGeoCode, histStatus, histDriverID, histStartDate, histEndDate, histDepartureGeoLayer, histDepartureGeoCode, histDestinationGeoLayer, histDestinationGeoCode, histPassengerAddressGeoLayer, histPassengerAddressGeoCode string, archivedFilter bool, driverAddressGeoLayer, driverAddressGeoCode string) (*SolidarityTransportOverviewResult, error) {
|
||||
// Get ALL drivers for the accountsMap (used in bookings display)
|
||||
allDrivers, err := h.solidarityDrivers("", false)
|
||||
allDrivers, err := h.solidarityDrivers(ctx, "", false)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("issue getting all solidarity drivers")
|
||||
allDrivers = []mobilityaccountsstorage.Account{}
|
||||
@@ -196,7 +196,7 @@ func (h *ApplicationHandler) GetSolidarityTransportOverview(ctx context.Context,
|
||||
}
|
||||
|
||||
// Get filtered drivers for the drivers tab display
|
||||
accounts, err := h.solidarityDrivers("", archivedFilter)
|
||||
accounts, err := h.solidarityDrivers(ctx, "", archivedFilter)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("issue getting solidarity drivers")
|
||||
accounts = []mobilityaccountsstorage.Account{}
|
||||
@@ -241,7 +241,7 @@ func (h *ApplicationHandler) GetSolidarityTransportOverview(ctx context.Context,
|
||||
return strings.Compare(firstNameA, firstNameB)
|
||||
})
|
||||
|
||||
beneficiariesMap, err := h.services.GetBeneficiariesMap()
|
||||
beneficiariesMap, err := h.services.GetBeneficiariesMap(ctx)
|
||||
if err != nil {
|
||||
beneficiariesMap = map[string]mobilityaccountsstorage.Account{}
|
||||
}
|
||||
@@ -435,7 +435,7 @@ type SolidarityTransportBookingsResult struct {
|
||||
|
||||
func (h *ApplicationHandler) GetSolidarityTransportBookings(ctx context.Context, startDate, endDate *time.Time, status, driverID, departureGeoLayer, departureGeoCode, destinationGeoLayer, destinationGeoCode, passengerAddressGeoLayer, passengerAddressGeoCode string) (*SolidarityTransportBookingsResult, error) {
|
||||
// Get all drivers
|
||||
drivers, err := h.solidarityDrivers("", false)
|
||||
drivers, err := h.solidarityDrivers(ctx, "", false)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("issue getting solidarity drivers")
|
||||
drivers = []mobilityaccountsstorage.Account{}
|
||||
@@ -447,7 +447,7 @@ func (h *ApplicationHandler) GetSolidarityTransportBookings(ctx context.Context,
|
||||
}
|
||||
|
||||
// Get beneficiaries
|
||||
beneficiariesMap, err := h.services.GetBeneficiariesMap()
|
||||
beneficiariesMap, err := h.services.GetBeneficiariesMap(ctx)
|
||||
if err != nil {
|
||||
beneficiariesMap = map[string]mobilityaccountsstorage.Account{}
|
||||
}
|
||||
@@ -1030,7 +1030,7 @@ func (h *ApplicationHandler) GetSolidarityTransportJourneyData(ctx context.Conte
|
||||
// Get passenger account
|
||||
var passenger mobilityaccountsstorage.Account
|
||||
if passengerID != "" {
|
||||
passengerResp, err := h.services.GetAccount(passengerID)
|
||||
passengerResp, err := h.services.GetAccount(ctx, passengerID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get passenger account: %w", err)
|
||||
}
|
||||
@@ -1048,7 +1048,7 @@ func (h *ApplicationHandler) GetSolidarityTransportJourneyData(ctx context.Conte
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
@@ -1093,7 +1093,7 @@ func (h *ApplicationHandler) CreateSolidarityTransportJourneyBooking(ctx context
|
||||
// Get passenger account for pricing
|
||||
var passenger mobilityaccountsstorage.Account
|
||||
if passengerID != "" {
|
||||
passengerResp, err := h.services.GetAccount(passengerID)
|
||||
passengerResp, err := h.services.GetAccount(ctx, passengerID)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not get passenger account: %w", err)
|
||||
}
|
||||
@@ -1171,7 +1171,7 @@ func (h *ApplicationHandler) CreateSolidarityTransportJourneyBooking(ctx context
|
||||
// Send SMS if not disabled
|
||||
if !doNotSend && message != "" {
|
||||
send_message := strings.ReplaceAll(message, "{booking_id}", resp.Booking.Id)
|
||||
if err := h.GenerateSMS(driverID, send_message); err != nil {
|
||||
if err := h.GenerateSMS(ctx, driverID, send_message); err != nil {
|
||||
log.Error().Err(err).Msg("failed to send SMS")
|
||||
}
|
||||
}
|
||||
@@ -1248,12 +1248,12 @@ func (h *ApplicationHandler) GetSolidarityTransportBookingData(ctx context.Conte
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) solidarityDrivers(searchFilter string, archivedFilter bool) ([]mobilityaccountsstorage.Account, error) {
|
||||
func (h *ApplicationHandler) solidarityDrivers(ctx context.Context, searchFilter string, archivedFilter bool) ([]mobilityaccountsstorage.Account, error) {
|
||||
request := &mobilityaccounts.GetAccountsRequest{
|
||||
Namespaces: []string{"solidarity_drivers"},
|
||||
}
|
||||
|
||||
resp, err := h.services.GRPC.MobilityAccounts.GetAccounts(context.TODO(), request)
|
||||
resp, err := h.services.GRPC.MobilityAccounts.GetAccounts(ctx, request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1320,7 +1320,7 @@ func (h *ApplicationHandler) CalculateSolidarityTransportPricing(ctx context.Con
|
||||
// Get passenger account
|
||||
var passenger mobilityaccountsstorage.Account
|
||||
if passengerID != "" {
|
||||
passengerResp, err := h.services.GetAccount(passengerID)
|
||||
passengerResp, err := h.services.GetAccount(ctx, passengerID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get passenger account: %w", err)
|
||||
}
|
||||
@@ -1376,6 +1376,17 @@ func (h *ApplicationHandler) calculateSolidarityTransportPricing(ctx context.Con
|
||||
}
|
||||
}
|
||||
}
|
||||
if pst, ok := op_map["previous_solidarity_transport_count"]; ok {
|
||||
if pst_str, ok := pst.(string); ok {
|
||||
if pst_str != "" {
|
||||
if n, err := strconv.Atoi(pst_str); err == nil {
|
||||
history = history + n
|
||||
} else {
|
||||
log.Error().Err(err).Str("n", pst_str).Msg("string to int conversion error")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1459,7 +1470,7 @@ func (h *ApplicationHandler) UpdateSolidarityTransportBookingStatus(ctx context.
|
||||
if previousStatus != "VALIDATED" && status == "VALIDATED" {
|
||||
if message != "" {
|
||||
send_message := strings.ReplaceAll(message, "{booking_id}", bookingID)
|
||||
h.GenerateSMS(passenger.ID, send_message)
|
||||
h.GenerateSMS(ctx, passenger.ID, send_message)
|
||||
}
|
||||
if err := h.CreditWallet(ctx, passenger.ID, -1*booking.Journey.Price.Amount, "Transport solidaire", "Débit transport solidaire"); err != nil {
|
||||
return fmt.Errorf("could not debit passenger wallet: %w", err)
|
||||
@@ -1467,6 +1478,32 @@ func (h *ApplicationHandler) UpdateSolidarityTransportBookingStatus(ctx context.
|
||||
if err := h.CreditWallet(ctx, driver.ID, booking.DriverCompensationAmount, "Transport solidaire", "Crédit transport solidaire"); err != nil {
|
||||
return fmt.Errorf("could not credit driver wallet: %w", err)
|
||||
}
|
||||
|
||||
if notify {
|
||||
groupsrequest := &groupsmanagement.GetGroupsRequest{
|
||||
Namespaces: []string{"parcoursmob_organizations"},
|
||||
Member: booking.PassengerId,
|
||||
}
|
||||
|
||||
groupsresp, err := h.services.GRPC.GroupsManagement.GetGroups(ctx, groupsrequest)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("")
|
||||
} else if len(groupsresp.Groups) > 0 {
|
||||
members, _, err := h.groupmembers(groupsresp.Groups[0].Id)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("could not retrieve groupe members")
|
||||
} else {
|
||||
for _, m := range members {
|
||||
if email, ok := m.Data["email"].(string); ok {
|
||||
h.emailing.Send("solidarity_transport.booking_driver_accept", email, map[string]string{
|
||||
"bookingid": booking.Id,
|
||||
"baseUrl": h.config.GetString("base_url"),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Credit passenger / debit driver when previous status was VALIDATED and new status is not VALIDATED anymore
|
||||
|
||||
Reference in New Issue
Block a user