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

Feat/support file sending #15

Merged
merged 4 commits into from
Oct 13, 2023

Conversation

ZaikoXander
Copy link
Contributor

No description provided.

- Implement file sending logic
	- When botpress_response type is 'file' or 'image' or 'video'
	- Downloads the file from the url in disk
	- And then sends it to chatwoot
		- Enable chatwoot file type identification by mime type
			- Using the MimeMagic gem and the file_path

- Create temp_files folder
	- To store the files downloaded from the url

- Create functions:
	- response_image?
	- response_file?
	- response_video?
	- download_file

- Rename functions:
	- 'botpress_response_choise_options?' -> 'response_choice_options?'
		- Also correcting typo in the name
	- build_choise_options_body -> build_choice_options_body
		- Only correcting typo in the name

- Add mimemagic dependency
- Add byebug as a development/test dependency

- Add some files/folders in .gitignore
	- files in temp_files folder
	- .byebug_history file
	- .idea folder
- Refactor download_file function to save file in memory
- Refactor the file sending logic to use the new download_file function
  - Unified request_url variable to url variable
  - Create get_file_name_by_url function

- Remove mimemagic gem
  - File class objects already have a content_type method

- Remote temp_files folder
- Remove temp_files folder from .gitignore
- Separate send file logic from SendToChatwoot into a new class
  - SendFileToChatwootRequest

- Add some Rails loggers into SendFileToChatwootRequest
- Create SendFileToChatwootRequestTest:
  - Test SendFileToChatwootRequest get_file_name_by_url function:
    - 'should return valid file name'
    - 'should throw invalid file name error'

- Add tests in ChatwootControllerTest:
  - 'should send image'
  - 'should send video'
  - 'should send file'
  - 'should send file with message'

- In SendFileToChatwootRequest:
  - Make the form_data content optional
  - Fix use case response by transforming the status code into string
  - Add a try...catch to download_file function
  - Add in get_file_name_by_url function a validation
    - If not valid throw an error

- In ReceiveEvent:
  - Capture each of the chatwoot responses
    - To return at use case response

- Add test files in fixtures:
  - image-file.png
  - pdf-file.pdf
  - video.file.mp4
@douglara douglara merged commit 53871e2 into douglara:main Oct 13, 2023
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants