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

Make delete appointment via API to send emails just like the calendar page does. #1101

Closed
iliavivanov opened this issue Jul 20, 2021 · 7 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@iliavivanov
Copy link

We can delete appointment via backoffice, and it invokes POST ***/index.php/backend_api/ajax_delete_appointment.
EA send 'Appointment canceled' email to customer (if emails configured).

But if we do the same via API - DELETE ***/index.php/api/v1/appointments/:id email do not sent.

For instance, if we create an appointment via API - email was send

@alextselegidis
Copy link
Owner

Hello!

Emails should be sent even when removing appointments via the API:

https://github.com/alextselegidis/easyappointments/blob/master/application/controllers/api/v1/Appointments.php#L224

Does your user have the notifications setting enabled?

  Alex Tselegidis, Easy!Appointments Creator
  Need a customization? Get a free quote!

@alextselegidis
Copy link
Owner

Closed due to inactivity.

  Alex Tselegidis, Easy!Appointments Creator
  Need a customization? Get a free quote!

@iliavivanov
Copy link
Author

All necessary settings enabled, email configuration is OK.

1st problem
https://github.com/alextselegidis/easyappointments/blob/master/application/libraries/Notifications.php#L159
Notifications#notify_appointment_deleted method uses new Text($this->CI->input->post('cancel_reason'))
There is no post object on delete action and Type#__construct failed with InvalidArgumentException because of null cancel_reason field of form/x-www-form-url-encoded

2nd problem
Rename cancel_reason to delete_reason everythere - it is not a cancelation - it is a deletion! That it is named at API.
This problem could be skipped if 3rd solved

3rd problem
Backend_api#ajax_delete_appointment mixes delete_reason and cancel_reason in one method - only delete_reason came from form (that is thay I ask you to rename cancel_reason to delete_reason)
That is why the program flow fails on https://github.com/alextselegidis/easyappointments/blob/master/application/controllers/Backend_api.php#L427
And not all emails send.

1 similar comment
@iliavivanov
Copy link
Author

All necessary settings enabled, email configuration is OK.

1st problem
https://github.com/alextselegidis/easyappointments/blob/master/application/libraries/Notifications.php#L159
Notifications#notify_appointment_deleted method uses new Text($this->CI->input->post('cancel_reason'))
There is no post object on delete action and Type#__construct failed with InvalidArgumentException because of null cancel_reason field of form/x-www-form-url-encoded

2nd problem
Rename cancel_reason to delete_reason everythere - it is not a cancelation - it is a deletion! That it is named at API.
This problem could be skipped if 3rd solved

3rd problem
Backend_api#ajax_delete_appointment mixes delete_reason and cancel_reason in one method - only delete_reason came from form (that is thay I ask you to rename cancel_reason to delete_reason)
That is why the program flow fails on https://github.com/alextselegidis/easyappointments/blob/master/application/controllers/Backend_api.php#L427
And not all emails send.

@iliavivanov
Copy link
Author

About new Text($this->CI->input->post('cancel_reason')) rework it like new Text($this->CI->input->input_stream('cancel_reason'))

@alextselegidis
Copy link
Owner

Hello @iliavivanov,

Thanks for getting back with additional information.

I will have to check this one again before and make sure this does not happen.

The post object should be there as the cancellation is a POST request, but it could be that someone also calls the URL directly which will lead to a GET request without a cancellation reason and thus cause this problem.

  Alex Tselegidis, Easy!Appointments Creator
  Need a customization? Get a free quote!

@alextselegidis alextselegidis self-assigned this Aug 23, 2021
@alextselegidis alextselegidis added the bug Something isn't working label Aug 23, 2021
@alextselegidis alextselegidis added this to the v1.5.0 milestone Aug 23, 2021
@alextselegidis alextselegidis changed the title Make delete appointment via API to send emails (like at BO) Make delete appointment via API to send emails just like the calendar page does. Oct 22, 2021
@alextselegidis
Copy link
Owner

This is already done on develop.

Alex Tselegidis, Easy!Appointments Creator
Need a customization? Get a free quote!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants