summaryrefslogtreecommitdiff
path: root/internal
AgeCommit message (Collapse)AuthorFiles
2022-12-21[bugfix] Close reader gracefully when streaming recache of remote media to ↵Libravatar tobi8
fileserver api caller (#1281) * close pipereader on failed data function * gently slurp the bytes * readability updates * go fmt * tidy up file server tests + add more cases * start moving io wrappers to separate iotools package. Remove use of buffering while piping recache stream Signed-off-by: kim <grufwub@gmail.com> * add license text Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: kim <grufwub@gmail.com>
2022-12-17[feature] Enable basic video support (mp4 only) (#1274)Libravatar tobi10
* [feature] basic video support * fix missing semicolon * replace text shadow with stacked icons Co-authored-by: f0x <f0x@cthu.lu>
2022-12-16[chore] fix some little config whoopsies (#1272)Libravatar tobi1
2022-12-16update go-cache to v3.2.0 with support for ignoring errors (#1273)Libravatar kim1
2022-12-16[chore/bugfix] Switch markdown from blackfriday to goldmark (#1267)Libravatar Autumn!5
Co-authored-by: Autumn! <autumnull@posteo.net>
2022-12-15[bugfix] Use null for empty api status `language` (#1268)Libravatar tobi4
* [bugfix] Use null for empty api status `language` * update swagger docs
2022-12-14[feature] support Sec-Websocket-Protocol in streaming API (#1254)Libravatar Matthew Phillips3
* [feature] support Sec-Websocket-Protocol in streaming API * Fix lint problem * Update based on reviews
2022-12-14[feature] domain block wildcarding (#1178)Libravatar kim5
* for domain block lookups, lookup along subdomain parts Signed-off-by: kim <grufwub@gmail.com> * only lookup up to a max of 5 domain parts to prevent DOS, limit inserted domains to max of 5 subdomains Signed-off-by: kim <grufwub@gmail.com> * add test for domain block wildcarding Signed-off-by: kim <grufwub@gmail.com> * check cached status first, increase cached domain time Signed-off-by: kim <grufwub@gmail.com> * fix domain wildcard part building logic Signed-off-by: kim <grufwub@gmail.com> * create separate domain.BlockCache{} type to hold all domain blocks in memory Signed-off-by: kim <grufwub@gmail.com> * remove unused variable Signed-off-by: kim <grufwub@gmail.com> * add docs and test to domain block cache, check for domain == host in domain block getter funcs Signed-off-by: kim <grufwub@gmail.com> * add license text Signed-off-by: kim <grufwub@gmail.com> * check order in which we check primary cache Signed-off-by: kim <grufwub@gmail.com> * add better documentation of how domain block checking is performed Signed-off-by: kim <grufwub@gmail.com> * change Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
2022-12-13[bugfix] fix unordered favorites (#1245)Libravatar Christoph Voigt3
* [bugfix] fix unordered favorites * add test for favouritesget * add license to new test files
2022-12-12[feature] allow uncaching of other media types (#1234)Libravatar kim9
* simplify pruneRemote, remove unncecessary media trace logging, update RemoteOlderThan() to include headers/avis Signed-off-by: kim <grufwub@gmail.com> * cleanup pruneallmeta, add remote header to pruneremote tests Signed-off-by: kim <grufwub@gmail.com> * fix olderthan duration additions Signed-off-by: kim <grufwub@gmail.com> * fix broken test now that test model header changed Signed-off-by: kim <grufwub@gmail.com> * instead use new remote test account for new header model Signed-off-by: kim <grufwub@gmail.com> * use newer generated ULID for remote_account_3 to ensure it is sorted last Signed-off-by: kim <grufwub@gmail.com> * reorganize serialized keys to match expected test account model order Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
2022-12-11[feature] support configuring database caches (#1246)Libravatar kim8
* update config generator to support nested structs, add cache configuration options * update envparsing test * add cache configuration to config parse tests * set cache configuration in testrig * move caches to sub-cache "gts" namespace, update envparsing, add cache config docs to example config Signed-off-by: kim <grufwub@gmail.com>
2022-12-10[feature] Start implementing refetch of lost media files via ↵Libravatar tobi12
`/api/v1/admin/media_refetch` (#1221) * [chore] Move ShortcodeDomain to its own little util func * [feature] Add RefetchEmojis function to media manager * [feature] Expose admin media refresh via admin API * update following review feedback - change/fix log levels - make sure not to try to refetch local emojis - small style refactoring + comments * log on emoji refetch start Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: kim <grufwub@gmail.com>
2022-12-09[bugfix] fix unordered favorites (#1236)Libravatar Christoph Voigt1
2022-12-09[feature] Allow users to create + delete bookbarks, and view bookmarked ↵Libravatar Matthew Phillips22
statuses (#1168) * Implement Bookmarks * Update based on review comments * Update swagger doc * Fix argument passing to status.Bookmark * Update changed test * Updates based on latest PR review
2022-12-08[chore] move caches to a separate State{} structure (#1078)Libravatar kim21
* move caches to a separate State{} structure Signed-off-by: kim <grufwub@gmail.com> * fix call to log.Panic not using formatted call Signed-off-by: kim <grufwub@gmail.com> * move caches to use interfaces, to make switchouts easier in future Signed-off-by: kim <grufwub@gmail.com> * fix rebase issue Signed-off-by: kim <grufwub@gmail.com> * improve code comment Signed-off-by: kim <grufwub@gmail.com> * fix further issues after rebase Signed-off-by: kim <grufwub@gmail.com> * heh Signed-off-by: kim <grufwub@gmail.com> * add missing license text Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
2022-12-06[feature] overhaul the oidc system (#961)Libravatar Dominik Süß13
* [feature] overhaul the oidc system this allows for more flexible username handling and prevents account takeover using old email addresses * [feature] add migration path for old OIDC users * [feature] nicer error reporting for users * [docs] document the new OIDC flow * [fix] return early on oidc error * [docs]: add comments on the finalization logic
2022-12-06[feature] media: add webp support (#1155)Libravatar Sigrid Solveig Haflínudóttir5
* media: add webp support Signed-off-by: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> * bump exif-terminator to v0.5.0 Signed-off-by: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> Signed-off-by: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
2022-12-05[bugfix]: Prevent extension of S3 presigned url TTL (#1208)Libravatar Dominik Süß1
Thanks :)
2022-12-04[chore] Fix a few possible cases of int truncation (#1207)Libravatar Daniele Sluijters8
This fixes a couple of cases where due to int being platform dependent a value could get truncated if running on 32bits.
2022-12-02[performance]: make s3 urls cacheable (#1194)v0.6.0-rc3Libravatar Dominik Süß1
Implements #864 and should speed up s3 based installations by a lot. With more static urls, we can then also implement #1026 for even better performance when used in conjunction with CDNs
2022-12-02[bugfix] Fix `admin account confirm` on pre-confirmed account setting email ↵Libravatar tobi1
address to empty string (#1203)
2022-12-02[bugfix] Add missing continues in emoji get funcs (#1200)Libravatar tobi1
2022-12-01[chore] Remove duplicate prefixes from sanitizer (#1195)Libravatar Daniele Sluijters1
In the previous changes that expanded the IPv4 and IPv6 deny lists based on the IANA registries we inadvertently added a number of duplicates. This is unnecessary as they're already caught by larger prefixes and means there's less entries to scan. This change removes all prefixes that are subnets of other prefixes.
2022-12-01[bugfix] Use case-insensitive selects when getting remote accounts by ↵v0.6.0-rc2Libravatar tobi2
username/domain (#1191) * [bugfix] Case-insensitive account selection * don't lowercase cache key
2022-11-30[feature] Support PKCS1 "RSA PUBLIC KEY" pem block type (#1179)Libravatar Sigrid Solveig Haflínudóttir1
* ap: add support for PKCS1 "RSA PUBLIC KEY" pem block type Signed-off-by: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> * ap: report no PEM data or unknown pem block type Signed-off-by: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> Signed-off-by: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
2022-11-30[bugfix] Don't call `strings.ToLower()` on usernames when selecting account ↵Libravatar tobi7
by domain+username (#1190) * don't lowercase account username when doing a select * test getting remote user with uppercase username
2022-11-30[bugfix] Avoid accidentally marking changed emojis as orphaned + pruning ↵Libravatar tobi9
them (#1188) * add predictable instance account to tests, use it in emoji urls + paths * use static image url to select emojis when pruning orphaned
2022-11-29[bugfix] don't return error during account serialize on deleted emoji (#1177)Libravatar kim1
* only return error for emoji fetch if NOT errnoentries Signed-off-by: kim <grufwub@gmail.com> * reformat gts->api model slice conversion to standard error behaviours and reduce code reuse Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
2022-11-29[bugfix] wrap the correct error on failed account update (#1176)Libravatar kim1
Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
2022-11-29[chore] Tidy up some of the search logic (#1082)v0.6.0-rc1Libravatar tobi23
* start refactoring some of the search + deref logic * add tests for search api * rename GetRemoteAccount + GetRemoteStatus * make search function a bit simpler + clearer * fix little fucky wucky uwu owo i'm just a little guy * update faulty switch statements * update test to use storage struct * redo switches for clarity * reduce repeated logic in search tests * fastfail getstatus by uri * debug log + trace log better * add implementation note * return early if no result for namestring search * return + check on dereferencing error types * errors hah what errors * remove unneeded error type alias, add custom error text during stringification itself * fix a woops recursion :see_no_evil: Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: kim <grufwub@gmail.com>
2022-11-27fix missing lookup cache key for invalid domain block (#1158)Libravatar kim1
2022-11-27[bugfix] Use Host domain for UA (#1156)Libravatar Daniele Sluijters1
In d6f4d196c978d81041ea99a32e2d6f63b0639472 we swapped to use the AccountDomain but that actually goes against the intent of the change. This reverts that change and uses the host domain again.
2022-11-26[chore] Set User-Agent header in transport (#1154)Libravatar Daniele Sluijters6
Currently requests set their own User-Agent. This moves it down to set it in the transport's do() method, to guarantee it's always set on all requests.
2022-11-26Tweak the User-Agent a bit (#1153)Libravatar Daniele Sluijters1
* [bugfix] Use AccountDomain for user agent By using the account domain we can pinpoint the source of the request more accurately when looking at the User-Agent header. * [chore] Align user-agent header with spec Based on RFC 7231, our User-Agent header doesn't quite match. It seems to always want Name [/ Version] pairs, with comments in parenthesis and multiple comments separated by a semicolon. Align our UA with that, using application name first by itself in case someone has customised it with the source instance in a comment. Follow that up with gotosocial/<version> and a comment pointing at the source code. This also drops the mention of gofed/activity since a fork is in use.
2022-11-26Additional IP range validations (#1152)Libravatar Daniele Sluijters4
* [bugfix] Ensure requests happen over TCP It's possible for the network to be udp4 or udp6. This is rather unlikely to occur, but since we're given the network anyway as part of the Sanitize function getting called we might as well check for it. * [chore] Align reserved v6 blocks to IANA registry * [chore] Add test for ValidateIP The net and netip packages diverge in that net.ParseIP will consider an IPv4-mapped address to be an IPv4 address and as such it would get caught by the IPv4Reserved list. However, netip considers it an IPv6 address, so we need to ensure the mapped range is in IPv6Reserved. * [chore] Align reserved v4 blocks to IANA registry This includes a number of tests for /32's explicitly called out in the registry to ensure we always consider those invalid.
2022-11-25[bugfix]: Fix IPv6 validation (#1150)Libravatar Daniele Sluijters1
* [bugfix]: Fix IPv6 validation The current code considers ff00::/8 valid, but contrary to the comment that's not the global unicast range. ff-prefixes in IPv6 denote multicast. This adapts the code to take the same approach as IPv4, explicitly blacklisting reserved internal/private ranges. * [chore] Add missing 4 in IPv4Reserved doc comment
2022-11-25[feature] Add `admin media prune orphaned` CLI command (#1146)Libravatar tobi7
* add FilePath regex * add `admin media prune orphaned` command * add prune orphaned function to media manager * don't mark flag as required * document admin media prune orphaned cmd * oh envparsing.sh you coy minx
2022-11-24[feature] `PATCH /api/v1/admin/custom_emojis/{id}` endpoint (#1061)Libravatar tobi9
* start adding admin emoji PATCH stuff * updating works OK, now how about copying * allow emojis to be copied * update swagger docs * update admin processer to use non-interface storage driver * remove shortcode updating for local emojis * go fmt Co-authored-by: f0x52 <f0x@cthu.lu>
2022-11-24[bugfix] Fix status boosts giving 404 (#1137)Libravatar tobi3
We broke this at some point recently, and i'm not sure when. In any case, i updated some of the logic in there + added a test for it.
2022-11-24[bugfix] Prevent future statuses entering timelines (#1134)Libravatar tobi5
* [bugfix] Prevent future statuses entering timeline Statuses created more than 5 minutes into the future are now rejected in the visibility package. * Come on buddy
2022-11-24[chore] cleanup storage implementation, no need for multiple interface types ↵Libravatar kim30
(#1131) Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
2022-11-23[feature/performance] Fail fast when doing remote transport calls inside ↵Libravatar tobi17
incoming request contexts (#1119) * [feature/performance] Fail fast when doing remote transport calls inside incoming request contexts * [chore] Reduce outgoing request timeout to 15s * log error messages when fastfailing * use context.Value() instead of wrapped context, wrap error with fastfail instead of extra log entry * add fast-fail context key test Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: kim <grufwub@gmail.com>
2022-11-23[chore/frontend] remove references to unused bundle.js (#1128)Libravatar tobi4
2022-11-22[feature] Prune timelines once per hour to plug memory leak (#1117)Libravatar tobi16
* export highest/lowest ULIDs as proper const * add stop + start to timeline manager, other small fixes * unexport unused interface funcs + tidy up * add LastGot func * add timeline Prune function * test prune * update lastGot
2022-11-22[chore] use kv.KVStore also for S3 storage (#1113)Libravatar kim2
* replace s3 storage implementation to also use kv.KVStore Signed-off-by: kim <grufwub@gmail.com> * pull in latest `go-store` fix Signed-off-by: kim <grufwub@gmail.com> * pull-in go-store v2.0.9 fixes, update s3 put chunk size to 5MiB Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
2022-11-22[chore] markdown: disable Smartypants rendering (#1111)Libravatar Norwin2
* [enhancement] markdown: disable SmartyPantsFractions fixes #1028 * some fractions are still converted to unicode to fix that, we might need to disable smartypants indeed in its entirety * disable smartypants completely for lack of a better simple solution
2022-11-20[chore] simplify logging to remove "safetywriter" given os.File has ↵Libravatar kim2
concurrency protection (#1083) Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
2022-11-20[chore] improve errors returned fetching account/statues from DB (#1084)Libravatar kim2
Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
2022-11-20[performance] add account block DB cache and remove block query joins (#1085)Libravatar kim11
* add account block DB cache and remove reliance on relational joins * actually include cache key arguments... * add a PutBlock() method which also updates the block cache, update tests accordingly * use `PutBlock` instead of `Put(ctx, block)` * add + use functions for deleting + invalidating blocks Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2022-11-20[bugfix] fix possible infinite loop on federated AP profile delete (#1091)Libravatar kim1
* refactor federator account statuses delete to better catch errors, ensure next maxID is always set Signed-off-by: kim <grufwub@gmail.com> * fix error statement missing 2nd format operator Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>