Commit graph

81 commits

Author SHA1 Message Date
kim
23fc70f4e6
[feature] add support for receiving federated status edits ()
* add support for extracting Updated field from Statusable implementers

* add support for status edits in the database, and update status dereferencer to handle them

* remove unused AdditionalInfo{}.CreatedAt

* remove unused AdditionalEmojiInfo{}.CreatedAt

* update new mention creation to use status.UpdatedAt

* remove mention.UpdatedAt, fixes related to NewULIDFromTime() change

* add migration to remove Mention{}.UpdatedAt field

* add migration to add the StatusEdit{} table

* start adding tests, add delete function for status edits

* add more of status edit migrations, fill in more of the necessary edit delete functionality

* remove unused function

* allow generating gotosocial compatible ulid via CLI with `go run ./cmd/gen-ulid`

* add StatusEdit{} test models

* fix new statusedits sql

* use model instead of table name

* actually remove the Mention.UpdatedAt field...

* fix tests now new models are added, add more status edit DB tests

* fix panic wording

* add test for deleting status edits

* don't automatically set `updated_at` field on updated statuses

* flesh out more of the dereferencer status edit tests, ensure updated at field set on outgoing AS statuses

* remove media_attachments.updated_at column

* fix up more tests, further complete the dereferencer status edit tests

* update more status serialization tests not expecting 'updated' AS property

* gah!! json serialization tests!!

* undo some gtscontext wrapping changes

* more serialization test fixing 🥲

* more test fixing, ensure the edit.status_id field is actually set 🤦

* fix status edit test

* grrr linter

* add edited_at field to apimodel status

* remove the choice of paging on the timeline public filtered test (otherwise it needs updating every time you add statuses ...)

* ensure that status.updated_at always fits chronologically

* fix more serialization tests ...

* add more code comments

* fix envparsing

* update swagger file

* properly handle media description changes during status edits

* slight formatting tweak

* code comment
2024-12-05 13:35:07 +00:00
kim
cac9d65029
[performance] convert enum strings to ints ()
* convert statuses.visibility and notifications.notification_type columns from type string -> int for performance / space savings

* fix test trying to compare string to int

* fix instance count query using string literal instead of gtsmodel const type

* ensure a default value is always set

* also migrate the account settings and sin bin status tables

* initialize maps outside loops and place into singular enum mapping creation func

* use int16 for enum types

* update sinbinstatus creation to be from a snapshot at initial creation

* add snapshot of poll type at creation time
2024-11-25 14:48:59 +01:00
tobi
1e421cb912
[feature] Distribute + ingest Accepts to followers () 2024-10-08 08:51:13 +00:00
tobi
95614fb298
[bugfix] Fix incorrect policy value parsing () 2024-09-17 21:22:45 +02:00
kim
5212a1057e
[bugfix] relax missing preferred_username, instead using webfingered username ()
* support no preferred_username, instead using webfingered username

* add tests for the new preferred_username behaviour
2024-08-13 09:01:50 +00:00
tobi
8ab2b19a94
[feature] Federate interaction policies + Accepts; enforce policies ()
* [feature] Federate interaction policies + Accepts; enforce policies

* use Acceptable type

* fix index

* remove appendIRIStrs

* add GetAccept federatingdb function

* lock on object IRI
2024-07-26 12:04:28 +02:00
tobi
611f9de39b
[bugfix] Deref stats async, serve stub collections if handshaking ()
* [bugfix] Deref stats async, allow peek if handshaking

* don't return totalItems when handshaking or hiding collections

* use GetLimit()

* use StubAccountStats
2024-06-11 11:54:59 +02:00
tobi
3cceed11b2
[feature/performance] Store account stats in separate table ()
* [feature/performance] Store account stats in separate table, get stats from remote

* test account stats

* add some missing increment / decrement calls

* change stats function signatures

* rejig logging a bit

* use lock when updating stats
2024-04-16 13:10:13 +02:00
tobi
4bbdef02f1
[chore] Try to parse public key as both Actor + bare key ()
* [chore] Try to parse public key as both Actor + bare key

* fix weird test fail
2024-04-02 11:30:10 +01:00
tobi
f05874be30
[feature] Option to hide followers/following () 2024-04-02 10:42:24 +01:00
tobi
ab2d063fcb
[feature] Process outgoing Move from clientAPI ()
* prevent moved accounts from taking create-type actions

* update move logic

* federate move out

* indicate on web profile when an account has moved

* [docs] Add migration docs section

* lock while checking + setting move state

* use redirectFollowers func for clientAPI as well

* comment typo

* linter? i barely know 'er!

* Update internal/uris/uri.go

Co-authored-by: Daenney <daenney@users.noreply.github.com>

* add a couple tests for move

* fix little mistake exposed by tests (thanks tests)

* ensure Move marked as successful

* attach shared util funcs to struct

* lock whole account when doing move

* move moving check to after error check

* replace repeated text with error func

* linterrrrrr!!!!

* catch self follow case

---------

Co-authored-by: Daenney <daenney@users.noreply.github.com>
2024-03-13 13:53:29 +01:00
tobi
f487fc5d4b
[bugfix] Sanitize incoming PropertyValue fields () 2024-03-04 11:46:59 +01:00
tobi
9cadc764b3
[feature] Add experimental instance-federation-spam-filter option ()
* [chore] Move `visibility` to `filter/visibility`

* [feature] Add experimental instance-federation-spam-filter option
2024-02-27 12:22:05 +00:00
kim
1d51e3c8d6
[bugfix] 2643 bug search for account url doesnt always work when redirected ()
* update activity library so dereferencer returns full response and checks *final* link to allow for redirects

* temporarily add bodged fixed library

* remove unused code

* update getAccountFeatured() to use dereferenceCollectionPage()

* make sure to release map

* perform a 2nd decode to ensure reader is empty after primary decode

* add comment explaining choice of using Decode() instead of Unmarshal()

* update embedded activity library to latest matching https://github.com/superseriousbusiness/activity/pull/21

* add checks to look for changed URI and re-check database if redirected

* update max iteration count to 512, add checks during dereferenceAncestors() for indirect URLs

* remove doubled-up code

* fix use of status instead of current

* use URIs for checking equality for security

* use the latest known URI for boost_of_uri in case original was an indirect

* add dereferenceCollection() function for dereferenceAccountFeatured()

* pull in latest github.com/superseriousbusiness/activity version (and remove the bodge!!)

* fix typo in code comments

* update decodeType() to accept a readcloser and handle body closing

* switch to checking using BoostOfID and add note why not using BoostOfURI

* ensure InReplyTo gets unset when deleting status parent in case currently stubbed

* add tests for Collection and CollectionPage iterators
2024-02-23 16:24:40 +01:00
tobi
aa396c78d3
[feature] serdes for moved/also_known_as ()
* [feature] serdes for moved/also_known_as

* document `alsoKnownAs` and `movedTo` properties

* only implicitly populate AKA uris from DB for local accounts

* don't let remotes store more than 20 AKA uris to avoid shenanigans
2024-02-06 09:45:46 +00:00
tobi
e3052e8c82
[bugfix] Don't return Account or Status if new and dereferencing failed, other small fixes ()
* tidy up account, status, webfingering logic a wee bit

* go fmt

* invert published check

* alter resp initialization

* get Published from account in typeutils

* don't instantiate error for no darn good reason

* shadow err

* don't repeat error codes in wrapped errors

* don't wrap error unnecessarily
2024-01-26 14:17:10 +01:00
tobi
d9729e7d28
[bugfix] Don't return Internal Server Error when searching for URIs that don't return AP JSON ()
* [bugfix] Don't return Internal Server Error when searching for URIs that don't return AP JSON

* don't pass map pointer
2024-01-22 14:38:45 +00:00
tobi
5ca86b1c57
[chore] Harden up boolptr logic on Accounts, warn if not set () 2024-01-19 13:02:04 +00:00
kim
67e11a1a61
[chore] chore rationalise http return codes for activitypub handlers ()
* some small code fixups and changes

* add check in ResolveIncomingActivity for transient activity types (i.e. activity ID is nil)

* update test to handle new transient behaviour
2024-01-18 17:11:13 +01:00
kim
ac48192562
[bugfix] poll vote count fixes ()
* don't drop all vote counts if hideCounts is set, refactors poll option extraction slightly

* omit voters_count when not set

* make voters_count a ptr to ensure it is omit unless definitely needed

* handle case of expires_at, voters_count and option.votes_count being nilable

* faster isNil check

* remove omitempty tags since mastodon API marks things as nullable but still sets them in outgoing json
2023-12-12 13:47:07 +00:00
tobi
d60edf7ec6
[bugfix] Ensure pre renders as expected, fix orderedCollectionPage () 2023-12-10 12:36:00 +01:00
kim
eb170003b8
[bugfix] return 400 Bad Request on more cases of malformed AS data () 2023-11-30 16:22:34 +00:00
tobi
cfefbc08d8
[feature] Federate status language in and out ()
* [feature] Federate status language in + out

* go fmt

* tests, little fix

* improve comments

* unnest a bit

* avoid unnecessary nil check

* use more descriptive variable for contentMap

* prefer instance languages when selecting from contentMap

* update docs to reflect lang selection

* rename rdfLangString -> rdfLangs

* update comments to mention Pollable

* iter through slice instead of map
2023-11-21 15:13:30 +01:00
kim
16275853eb
[bugfix] self-referencing collection pages for status replies () 2023-11-20 12:22:28 +00:00
kim
deaea100c3
[bugfix] support endless polls, and misskey's' method of inferring expiry in closed polls () 2023-11-11 10:15:04 +00:00
kim
e9e5dc5a40
[feature] add support for polls + receiving federated status edits () 2023-11-08 14:32:17 +00:00
kim
41435a6c4e
[feature] support canceling scheduled tasks, some federation API performance improvements () 2023-11-04 20:21:20 +00:00
tobi
51d0a0bba5
[bugfix] Relax Mention parsing, allowing either href or name () 2023-10-31 11:05:17 +00:00
tobi
0b978f2c56
[bugfix] Extract description as summary first, fall back to name () 2023-10-26 11:59:10 +02:00
kim
c6e00afc7c
[feature] tentatively start adding polls support () 2023-10-04 13:09:42 +01:00
kim
297b6eeaaa
[chore] internal/ap: add pollable AS types, code reformatting, general niceties () 2023-10-03 14:59:30 +01:00
kim
9f9fcf743d
[bugfix] support both CollectionPage AND OrderedCollectionPage in status replies () 2023-09-23 18:28:12 +01:00
kim
fc11deeb83
[feature] add paging to AP following / followers endpoints () 2023-09-20 16:49:46 +01:00
tobi
dc96562b40
[bugfix] Use custom bluemonday policy to disallow inline img tags () 2023-08-11 14:40:11 +02:00
tobi
2796a2e82f
[feature] Hashtag federation (in/out), hashtag client API endpoints ()
* update go-fed

* do the things

* remove unused columns from tags

* update to latest lingo from main

* further tag shenanigans

* serve stub page at tag endpoint

* we did it lads

* tests, oh tests, ohhh tests, oh tests (doo doo doo doo)

* swagger docs

* document hashtag usage + federation

* instanceGet

* don't bother parsing tag href

* rename whereStartsWith -> whereStartsLike

* remove GetOrCreateTag

* dont cache status tag timelineability
2023-07-31 15:47:35 +02:00
tobi
d98b6318ac
[bugfix] Use gtserror package for WrongType errs ()
* [bugfix] Use gtserror package for WrongType errs

* test
2023-06-27 11:37:42 +02:00
tobi
d8e16a226a
[chore/bugfix] Refactor ap/extract.go functions, return URIs more reliably () 2023-06-17 16:49:11 +01:00
tobi
24fbdf2b0a
[chore] Refactor AP authentication, other small bits of tidying up () 2023-06-13 15:47:56 +01:00
tobi
0e29f1f5bb
[feature] Enable federation in/out of profile PropertyValue fields ()
Co-authored-by: kim <grufwub@gmail.com>
Co-authored-by: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>
2023-05-09 11:16:10 +01:00
tobi
6b4f6dc755
[bugfix] Fix remaining mangled URI escaping issues in statuses + accounts ()
* start fiddling with normalize + extract functions

* normalize attachment name (image description)

* NormalizeAccountableSummary

* normalize summary + name
2023-04-26 16:17:22 +01:00
tobi
c54510bc74
[bugfix] Normalize status content (don't parse status content as IRI) ()
* start fannying about

* finish up Normalize

* tidy up

* pin to tag

* move errors about just a little bit
2023-04-06 12:19:55 +01:00
tobi
4f322f527f
[bugfix] Always serialize orderedItems as array () 2023-04-06 12:16:53 +01:00
Daenney
5e2bf0bdca
[chore] Improve copyright header handling ()
* [chore] Remove years from all license headers

Years or year ranges aren't required in license headers. Many projects
have removed them in recent years and it avoids a bit of yearly toil.

In many cases our copyright claim was also a bit dodgy since we added
the 2021-2023 header to files created after 2021 but you can't claim
copyright into the past that way.

* [chore] Add license header check

This ensures a license header is always added to any new file. This
avoids maintainers/reviewers needing to remember to check for and ask
for it in case a contribution doesn't include it.

* [chore] Add missing license headers

* [chore] Further updates to license header

* Use the more common // indentend comment format
* Remove the hack we had for the linter now that we use the // format
* Add SPDX license identifier
2023-03-12 16:00:57 +01:00
tobi
24cec4e7aa
[feature] Federate pinned posts (aka featuredCollection) in and out ()
* start fiddling

* the ol' fiddle + update

* start working on fetching statuses

* poopy doopy doo where r u uwu

* further adventures in featuring statuses

* finishing up

* fmt

* simply status unpin loop

* move empty featured check back to caller function

* remove unnecessary log.WithContext calls

* remove unnecessary IsIRI() checks

* add explanatory comment about status URIs

* change log level to error

* better test names
2023-03-01 17:52:44 +00:00
Sam Lade
f559d46261
[bugfix] Fix failure to look up remote profiles with duplicate emojis in some cases ()
* Tidy up emoji parsing on profile submission

Don't bother reparsing for emoji unless one of the fields that can have
emoji in it has changed.
Deduplicate emoji between the display name and profile note - I'm not
sure whether this was hurting anything, but better safe.

* Deduplicate emoji when parsing remote accounts

Some servers - Misskey at least - don't deduplicate emoji, so it's
possible to get an account which has the same emoji used in both the
display name and note and therefore includes that emoji twice in its
metadata. When we start trying to put those into our database, we run
into a uniqueness constraint and fall over.

This change just deduplicates at the point of construction of an
account.
2023-02-20 16:27:41 +01:00
tobi
271da016b9
[bugfix] Read Bookwyrm Articles more thoroughly () 2023-02-02 16:41:02 +01:00
tobi
3283900b0d
[feature] Federate reports to remote instance as Flag (if desired) ()
* reports federate out, we did it lxds

* fix optional line start (should be optional slash)
2023-01-27 14:48:11 +01:00
tobi
993aae5e48
[feature] Accept incoming federated Flag activity ()
* start working on handling incoming Flag activity

* interim commit

* federate Flag in successfully
2023-01-25 11:12:27 +01:00
tobi
0dbe6c514f
[chore] Update/add license headers for 2023 () 2023-01-05 12:43:00 +01:00
Sigrid Solveig Haflínudóttir
5a0e418281
[feature] Support PKCS1 "RSA PUBLIC KEY" pem block type ()
* 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 23:13:13 +01:00