-
Notifications
You must be signed in to change notification settings - Fork 80
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
Refactorize and test microservice/recordings #2826
base: bleeding
Are you sure you want to change the base?
Refactorize and test microservice/recordings #2826
Conversation
4ae6502
to
eb4d3b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functional review required
7973e0c
to
ff39243
Compare
ff39243
to
94c01dc
Compare
3a085c6
to
df2fbbd
Compare
df2fbbd
to
e6989bc
Compare
|
||
public function getCallid(): ?string | ||
{ | ||
return ($this->callid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra ()
$this->rawRecordingsDir, | ||
$filename | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a check to only consider actual files and skip directories, links, and so on. The rawRecordingsDir may contain other files that are not actually Recordings.
Also, considering only files that ends with -mix.wav could be a good idea, because other files in the directory that doesn't match that pattern should be ingored, and not considered as errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is also a good point to validate file format to extract callid from the filename
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This service is here only keep file system functions separated from the logic. It's fully mocked in testing.
$this->rawRecordingInfoMockFactory( | ||
'/recordings/wrong-file-name.ogg', | ||
Encoder::RECORDING_SIZE_MIN + 1, | ||
Encoder::RECORDING_AGE_MIN + 1 | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should be ignored by the recording microservice
if (preg_match("/\w+-\w+-(.*)-\w+-mix.wav/", $this->filename, $matches)) { | ||
$this->callid = urldecode($matches[1]); | ||
$this->hashid = substr(md5($this->callid), 0, 8); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will validate this before creating a RawRecordingInfo instance. If this condition doesn't match, it's not a recording and doesn't deserve a RawRecordingInfo. Also $this->callid and $this->hashid shouldn't be nullable. If the file doesn't have those values, it can not be considered a recording, so callid could be part of the constructor imo.
$billableCalls = $this | ||
->billableCallRepository | ||
->findByCallid( | ||
$filename->getCallid() ?? '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned before, this should not happen. Callid is a must in the recording and should not be nullable.
df24ab3
to
842b736
Compare
Type Of Change
Checklist:
Description
Additional information