All key-value settings in api.py were parsed through the following syntax:
```python
if settings["something"] is None:
...
```
This is problematic because it forces downstream implementations to also
provide all the fields, also when they are not required.
In particular, when new fields are added, downstream implementations
also have to provide them, or the integration will break.
The `settings.get("something")` syntax should be preferred, and settings
itself should also be initialized to a dict by default to prevent
dereferencing a `None` (I mean, if no settings are provided at all the
code should probably still break, but with a relevant error instead of a
fuzzier `TypeError`).
Closes: #51Closes: #52
Closes: https://github.com/Pioverpie/privatebin-api#12
Usage: set "--short-api" to "custom", provide url with "--short-url" to shorter
service which returns short link in text form. For paste url mask "{{url}}" must
be used. Link queried with GET request.
Example for Shlink service:
https://doma.in/rest/v2/short-urls/shorten?apiKey=YOURKEY&longUrl={{url}}&format=txt
Signed-off-by: R4SAS <r4sas@i2pmail.org>
New:
* Added validation of PrivateBin instance URL - #18 (it must contain trailing slash because POST is used)
* URL shortener support with various supported services - #19
* Shortener configuration, certificate validation and insecure warning settings can be configured in config file or via env
Changed:
* Restructured some parts of code by splitting big code chunks in funtions (encrypt/decrypt)
* Rework error messaging repeatable code (moved in utils)
* Reduce code duplication (requests session configuring)
Signed-off-by: r4sas <r4sas@i2pmail.org>