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

Implement internal pir opt out #5845

Merged
merged 12 commits into from
Apr 8, 2025
Merged

Conversation

karlenDimla
Copy link
Contributor

@karlenDimla karlenDimla commented Apr 1, 2025

Task/Issue URL: https://app.asana.com/0/72649045549333/1209242689024725/f

Description

This PR covers all the logic for opt-out. More details in the attached task.

Steps to test this PR

No need to do a specific test for this PR.
The stacked PR’2 test case should cover all - since formatting is much better.

Copy link
Contributor Author

karlenDimla commented Apr 1, 2025

@karlenDimla karlenDimla mentioned this pull request Apr 1, 2025
if (this is OptOutStep) {
this.copy(
brokerName = brokerName,
profilesToOptOut = repository.getExtractProfileResultForBroker(brokerName)?.extractResults?.filter {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This step is only relevant for optout. We need to obtain the extracted profiles with result set to true (if any) - those are the considered valid records.

@karlenDimla karlenDimla force-pushed the feature/karl/pir/poc-opt-out branch from c1f28ce to dd9f7c2 Compare April 2, 2025 17:55
return kotlin.runCatching {
var attempt = 0
var result: Pair<ConfirmationStatus, String?> = Unknown to null
while (attempt < MAX_AWAIT_EMAIL_ATTEMPT) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It’s a bit slow today - this could take 90 seconds. However, it seems like we might need longer since I am not getting any links today.

import kotlinx.coroutines.withContext
import logcat.logcat

interface PirActionsRunner {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this to common package which contains everything shared between scan and optout that is not necessarily script specific

state: State,
callback: String,
) {
withContext(dispatcherProvider.main()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like this doesn’t show anything visually but i can see the actions passing.

) {
val broker = brokersToExecute[state.currentBrokerIndex]

if (state.transactionID.isEmpty()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is possible if we get an error in getcaptcha action. We just fail this rightaway.

),
)
} else {
nativeBrokerActionHandler.pushAction(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic here polls for the solution until we hit max retries (50) every 5 seconds. We can update the frequency here - but so far it does take 2 minutes+ to get the solution

state: State,
pollingIntervalSeconds: Float,
) {
val broker = brokersToExecute[state.currentBrokerIndex]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We might need to move out the polling to the runner since NativeBrokerActionHandler is shared across all runners. It is not a problem today because this is mainly used in opt out where we use only one runner.

}

private suspend fun handleGetEmail(state: State) {
val broker = brokersToExecute[state.currentBrokerIndex]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This handles getting email address to be used for opt out for every profile.

}

@ContributesBinding(AppScope::class)
class RealPirRunStateHandler @Inject constructor(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted this class from the runner since that class is getting too big. This handles pixels and saving states to db

@@ -94,10 +93,15 @@ class RealPirScan @Inject constructor(
lastName = "Smith",
city = "Chicago",
state = "IL",
addresses = listOf(),
addresses = listOf(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed to get proper extracted profile matches (not documented anywhere)

@karlenDimla karlenDimla merged commit e13ae94 into develop Apr 8, 2025
6 checks passed
@karlenDimla karlenDimla deleted the feature/karl/pir/poc-opt-out branch April 8, 2025 08:03
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