# sr-delivery-tiktok-filter

The purpose of this function is to receive messages, representing potential deliveries and to filter out those which should not be delivered.
The eligible deliveries will be sent to event.orchardSoundRecording.delivery, so we can record ineligible deliveries in the delivery history table.

### Optional Dev Sentry DSN

If you have a dev Sentry DSN to use (using either a catch-all DSN or by setting up a dev DSN for this lambda), you can:

* `cp .env.shadow .env`
* Fill in the DSN in `.env`
* The SENTRY_DSN env var in `docker-compose.yaml` will then pick this up

If you don't fill out the environment variable, docker-compose will warn you, but it is not required.

### Running

`docker compose up --build lint-and-test` to run linting and unit tests.

If you want to skip the linter for testing purposes, set `SKIP_LINT=1` in the `docker-compose.yaml`.

`docker compose up --build function` to run the lambda function in docker.

There is a bash script in this directory that will send a sample event from a file to an already running local lambda function.

Setup
Make sure you have the following cli tools setup.
- cURL
- jq

Execution
Simply call the script with a file path as parameter. You can also use the `sample_event.json` file in this repo.

$ ./tests/call.sh $FILE_PATH.json

Or you can run a POST request - `http://localhost:9000/2015-03-31/functions/function/invocations`- being sure to pass in the event you want to run in the body of the request.

Alternatively, you can run the function using the `simulate_event.py` file, which also makes use of the event in `sample_event.json`:
1. `python -m venv venv`
2. `source venv/bin/activate`
3. `pip install -r requirements.txt`
4. `export ENVIRONMENT=<env>`
5. `python simulate_event.py`

### AWS Issues
Note the container will use env vars to set access to AWS.  Make sure to run awsume for the production account e.g. `awsume prod` in the same shell you're working in, before building the image and running the container. 

Learn more about awsume [here](https://www.notion.so/AWS-Access-f841b9dd815d4443a80e96a86c92cd2f?source=copy_link#f11f08d09f16493a8a3e9dbf38d87164) 

