COVID-19-electronic-health-system / Coronalert

CoronaTracker notification service
6 stars 2 forks source link

Move unsubscribe function to lambda #16

Closed SomeMoosery closed 4 years ago

SomeMoosery commented 4 years ago

We are shifting architectures, and want to translate our Unsubscribe() functionality into a lambda function to run on AWS

To unsubscribe, we are going to require users to enter their phone numbers again. Due to us wanting to preserve privacy and anonymity of users, we will not be storing personal information related to phone numbers in our databases, just the phone numbers themselves.

tylerd92 commented 4 years ago

I would like to work on this

tylerd92 commented 4 years ago

Hey, @SomeMoosery I created the lambda for the unsubscribe. Would I be able to test it myself with our environment?

SomeMoosery commented 4 years ago

You should be able to poll the API Gateway using Postman or curl.

If you go to API Gateway -> coronalert-API -> stages -> '/ -> </<your-endpoint> -> <your-get-or-post> there should be an invoke URL that you can use, and then just add the appropriate body in the request

This is if it's for a POST. For a GET, you can add a test to your Lambda (look in the top right) and test the lambda without having the request the API each time.

acthelemann commented 4 years ago

@tylerd92 You can also test a POST through Lambda by configuring a test event with the event template Amazon API Gateway AWS Proxy. You'll need to put the escaped JSON body in the first property for the test event, body.

To escape JSON you can use this website.

tylerd92 commented 4 years ago

Hi @SomeMoosery can this issue be closed? The unsubscribe lambda has been moved to master. Also I do want to add encryption of the mongoDB uri. I do wonder if in the function there should be a check if the phone number exists in the database, or if the phone number does not exist return a message saying that. I’m thinking these could be separate issues though.

SomeMoosery commented 4 years ago

I would say definitely make another issue for encrypting MONGODB_URI - @acthelemann has done this already for subscribe I believe so it should be a quick fix.

Regarding the check you mentioned, I believe @acthelemann is working on that now #32 :)

acthelemann commented 4 years ago

@tylerd92 I was going to work on the phone number check in the evening, but if you have time, feel free to do it.

I would suggest returning a 404 status code if a phone number is not found. Take a look at the subscribe lambda for reference - it returns a 409 if a phone number is found.

acthelemann commented 4 years ago

@tylerd92 I'm going to start working on the phone number check if you haven't - let me know.

tylerd92 commented 4 years ago

I have not go for it