Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Provide survey URL (EXPOSUREAPP-4858) #2307

Merged
merged 8 commits into from
Feb 11, 2021

Conversation

LukasLechnerDev
Copy link
Contributor

The component that provides the URL for Surveys.

For our current survey (high-risk cards), the base URL is loaded from our AppConfig and then the one-time-password is added as a query parameter. The name of this query parameter is also contained in the AppConfig

@LukasLechnerDev LukasLechnerDev added the maintainers Tag pull requests created by maintainers label Feb 8, 2021
@LukasLechnerDev LukasLechnerDev added this to the 1.13.0 milestone Feb 8, 2021
@LukasLechnerDev LukasLechnerDev requested a review from a team February 8, 2021 16:19
@LukasLechnerDev LukasLechnerDev changed the title Provide survey URL (EXPOSUREAPP-4658) Provide survey URL (EXPOSUREAPP-4858) Feb 8, 2021
@harambasicluka harambasicluka added prio PRs to review first. enhancement Improvement of an existing feature labels Feb 9, 2021
@BMItr BMItr self-assigned this Feb 9, 2021
* @throws IllegalStateException If no one time password (otp) can be loaded from the OTPRepository of if the
* AppConfig doesn't contain a link to a survey
*/
suspend fun provideUrl(type: Surveys.Type): String {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please consider to put this logic/method to Surveys.kt
we could then validate if the OTP has been used already this month.
If no OTP is there, we can just generate one...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My plan was that after the OTP generation/validation/authentication (Part of Chris' subtask) ,Surveys.kt can simply call provideUrl(). At this point, a generated, validated and authenticated OTP should be stored in our OtpRepository that is then loaded by SurveyUrlProvider to assemble the URL.

I pushed a new commit where the UrlProvider is called in Surveys.kt.

Do you think the UrlProvider shouldn't be a separate component but a method in Surveys.kt? What would be the benefit?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SurveyUrlProvider could be irritating if one calls it from another class than Surveys.
For e.g. one tries to get an URL for a High_Risk_Survey. He could use the url provider instead of surveys and so accidentally skip the generation/validation/authentication of the OTP.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the OTP (re)generated on-demand?

What is the calling classes expected to do when provideUrl throws IllegalStateException?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BMItter
I added a new commit. Now you need to pass the OTP to the UrlProvider and since only the Surveys class is going to generate OTPs, it shouldn't be called from anywhere else.

@d4rken
I changed the UrlProvider so that we now already have to pass an authenticated OTP to it.
I guess the calling class should show a "Something went wrong...." error message to the user in this case.

@jurajkusnier jurajkusnier self-assigned this Feb 9, 2021
* @throws IllegalStateException If no one time password (otp) can be loaded from the OTPRepository of if the
* AppConfig doesn't contain a link to a survey
*/
suspend fun provideUrl(type: Surveys.Type): String {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the OTP (re)generated on-demand?

What is the calling classes expected to do when provideUrl throws IllegalStateException?

@sonarcloud
Copy link

sonarcloud bot commented Feb 11, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

80.0% 80.0% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@BMItr BMItr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👌

@LukasLechnerDev LukasLechnerDev merged commit 07dd578 into release/1.13.x Feb 11, 2021
@LukasLechnerDev LukasLechnerDev deleted the feature/4658-Provide-survey-URL branch February 11, 2021 14:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Improvement of an existing feature maintainers Tag pull requests created by maintainers prio PRs to review first.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants