Closed carboxylman closed 1 year ago
The URL I chose for the opt out in the backend is \<host>/v1/email/opt_out. It has two query params: email and key. It returns 404 if the email and matching key are not found, or 200 if successful.
Thank you Brain, this is really helpful. Is it OK to assume that the opt-out button in the email contains email and key? Since to opt-out i need to get those params.
Yes. My assumption is that you'll create a frontend endpoint which will be the actual destination for the link in the email, and that frontend endpoint will call this one. I will include the email and key as query params, unless you prefer them in some other format.
Also then endpoint returns json message.
{'message': 'opted out of future communication'}
on success, and {'message': 'email or key not found'}
on 404.
ok i created a frontend page in at <host>/optout
here https://github.com/ITI/searcch/tree/189a-optout-ui. The webpage will automatically call your API endpoint when it mounts. I also navigates a user to home page if he doesn't have email or key params. Let me know your thoughts!
@ckouder For the auto claim, do you want to just look for the same email and key query params on the artifact page? Or perhaps it's better to have a url like /artifact/{id}/claim?key=''&email=''.
The requirements as I understand them:
I suppose I probably need to provide an endpoint to verify the key.
Slight revision, it will return 401 Unauthorized instead of 404 if the key is not found.
There is an existing endpoint artifact/request/owner/<artifact-group-id>
for the data POST
by standard claim request UI. Can we do GET
artifact/request/owner/<artifact-group-id>?key=''&email=''
for the magic code?
That works for me.
@ckouder How is the opt out handler coming along? Is it ready for testing? I tried checking out branch 189a-optout-ui and calling the optout endpoint, but I get the following error.
An error occurred
Cannot read properties of undefined (reading 'index')
I also don't see my backend endpoint being called.
@brian-at-sri Sorry my bad! I forget to add opt out endpoint on my end. It should be fixed by now. Would you please try again?
I now receive a 404 response. The backend is still not being called. The backend endpoint is as follows:
<backend_host>/v1/email/opt_out
Okay got it. just pushed another commit. Frontend should call /v1/email/opt_out
by now. I thought you are using /v1/optout
for backend as well
Oh right, I forgot I made it a POST endpoint. Can you make that change as well?
No worries! I got it. Let's do pair coding sometime if you'd like. I never did it before but I believe it would reduce some communication problems... I'm working on claim-ownership ui now. How can I use that backend endpoint for magic code? what data does backend expecting from my end? POST
or GET
?
I haven't created a backend endpoint for the claim-ownership code. I'm not sure what would be best. I could simply whip up an endpoint that would return true/false if the code was valid, then you could go through the normal claim process. Or we could extend the existing claim process to accept the the key code.
I'd love to help but I've actually overshot my budget on SEARCCH and need to back off on spending. I think for now simply opening a page with the existing claim dialog opened will be sufficient in the short term. We can attempt an automatic claim using the key if there is budget for it later.
We need two new frontend features, related to backend https://github.com/ITI/searcch-backend/issues/95: