pinnwand icon indicating copy to clipboard operation
pinnwand copied to clipboard

Add crud utilities

Open wookie184 opened this issue 1 year ago • 2 comments

Not ready yet, just opening as a draft. Sorry for the large PR, I think it's worth it though.

This makes a lot of logic shared to reduce the amount of code there is and fix and help prevent some issues:

  • https://github.com/supakeen/pinnwand/issues/182: RE "Are pastes being reaped on all show pages?", the repaste endpoint doesn't currently, but this fixes that and ensures it can't be forgotten in the future
  • The previous logic for checking if a paste with multiple files went over the file size when the files were combined only checked the total size once all the files were processed. This meant you could have e.g. 100 files just under the size limit individually and DoS the server because it has to process them all with pygments. Now an error is raised as soon as the combined size goes above the max allowed.
  • Some validation logic was inconsistent across different endpoints (most endpoints consider whitespace an empty paste which isn't allowed, but api_v1 didn't). Centralising the logic ensures all endpoints are consistent when they should be.

To Do:

  • Add tests
  • Add docstrings
  • Tidy up code
  • Make sure error responses are in the correct format for each endpoint respectively.

wookie184 avatar Jan 20 '24 02:01 wookie184

There's quite a lot of stuff here that I like :)

supakeen avatar Mar 10 '24 20:03 supakeen

Just adding a note that i've not forgotten about this, I'll fix the conflicts and finish this off when I get a chance 👍

wookie184 avatar Apr 16 '24 11:04 wookie184