aboutsummaryrefslogtreecommitdiffstats
path: root/license-generator/src/errors.rs
AgeCommit message (Collapse)Author
2018-11-21Add license (mostly GNU AGPLv3+)Teddy Wing
License the software with the GNU AGPLv3+ with the exception of the 'aquatic-prime' and 'paddle' libraries and 'aquatic-prime' binary, which are licensed under the GNU GPLv3+.
2018-11-19license-generator: Respond with text for fulfillment emailTeddy Wing
Paddle will take the text from the response of this endpoint and include it in the purchase fulfillment email to a customer. Include the URL for the purchaser to download their license. Use the 'url' crate's parser to build the URL in order to URL-escape special characters. Honestly I'd rather have had a system where the license file gets included in the receipt email. Unfortunately, with the Paddle fulfillment mechanism I'm using, we can only send text. I learned after building the download endpoint that I could manage fulfillment myself. This would require me to listen to an "alert"-type Paddle webhook, and send the email myself (which would include the license file). Since I already built the license download page, I decided to just use it instead of doing the emailing. Also, my web host limits my SMTP usage, so there could be issues there. I'd have to do the emailing in a separate batch process instead of in the webhook handler to ensure that no emails would get dropped.
2018-11-13license: Remove `unwrap`sTeddy Wing
Respond with a 500 on error. Add 'aquatic-prime' to `foreign_links` errors to be able to convert it with `into()`.
2018-11-13license: Generate a license and send it in HTTP responseTeddy Wing
If the purchaser coming from POST params is found in the database, generate a license for the purchaser, zip the license, and send a response containing the zipped data. zip: Change the writer input to a mutable reference to enable us to use the zip data when writing to the response. Otherwise we get a borrow error.
2018-11-11Add `zip::license()` to make a Zip archive of a license plistTeddy Wing
2018-11-10paddle::verify_signature(): Extract signature from paramsTeddy Wing
Make it easier on users by not requiring them to pass a signature into the method. This means they don't have to extract the `p_signature` param and base64 decode it themselves. Essentially, we want to move the code from `request` that removes the `p_signature` key and base64 decodes it into the `paddle::verify_signature()` function. We need to make the string-like type params in `verify_signature()` conform additionally to `PartialEq<str>` and `PartialOrd`. Doing so allows us to find the key "p_signature". To remove the `p_signature` param from the iterator, we partition it into two iterators: one for the `p_signature` entry, and another for the rest. We then extract the value of `p_signature` and base64 decode it for verification. Add a new error type in case no `p_signature` entry is found in the iterator.
2018-11-10request::verified(): Base64 decode signature from POST paramsTeddy Wing
In order to verify the signature, it needs to be encoded as bytes.
2018-11-10paddle::verify_signature(): Remove `unwrap`sTeddy Wing
Return a `Result` from the function to pass errors through.
2018-11-09Set up a file loggerTeddy Wing
Get a file path from the `LOG_FILE` environment variable and use it for log output. Call `database::get_database_connection()` and log the error if it fails. Worried about exiting early from the FastCGI program, as DreamHost says this causes problems (https://help.dreamhost.com/hc/en-us/articles/217298967). But I don't see how the program can continue without a database connection. Return a `Result` from `main()` because it's easier to use the `?` operator for errors that happen before logging is initialised.
2018-11-09Add `get_database_connection()`Teddy Wing
Function to establish a database connection using a connection pool. Update `Purchaser::insert()` to take a `PooledConn` instead of a simple `Conn`.
2018-11-09Extract code in `lib.rs` to `errors.rs` and `purchaser.rs`Teddy Wing
Split up the code to get things a bit more organised. I want a function to create a connection to the MySQL database and I don't want to lump it in with the rest.