Commit Graph

54 Commits (375d9a2a3cf9c023ac6ac832d98f1b456fb9e2ce)

Author SHA1 Message Date
phiresky 375d9a2a3c
Persistent, performant, reliable federation queue (#3605)
* persistent activity queue

* fixes

* fixes

* make federation workers function callable from outside

* log federation instances

* dead instance detection not needed here

* taplo fmt

* split federate bin/lib

* minor fix

* better logging

* log

* create struct to hold cancellable task for readability

* use boxfuture for readability

* reset submodule

* fix

* fix lint

* swap

* remove json column, use separate array columns instead

* some review comments

* make worker a struct for readability

* minor readability

* add local filter to community follower view

* remove separate lemmy_federate entry point

* fix remaining duration

* address review comments mostly

* fix lint

* upgrade actitypub-fed to simpler interface

* fix sql format

* increase delays a bit

* fixes after merge

* remove selectable

* fix instance selectable

* add comment

* start federation based on latest id at the time

* rename federate process args

* dead instances in one query

* filter follow+report activities by local

* remove synchronous federation

remove activity sender queue

* lint

* fix federation tests by waiting for results to change

* fix fed test

* fix comment report

* wait some more

* Apply suggestions from code review

Co-authored-by: SorteKanin <sortekanin@gmail.com>

* fix most remaining tests

* wait until private messages

* fix community tests

* fix community tests

* move arg parse

* use instance_id instead of domain in federation_queue_state table

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
Co-authored-by: SorteKanin <sortekanin@gmail.com>
8 months ago
Dessalines 56e26fc3d4
Adding a post_view mode. Fixes #3730 (#3731)
* Adding a post_view mode. Fixes #3730

* Fix test.

* Addressing PR comments.

* Adding a post_view mode. Fixes #3730

* Fix test.

* Addressing PR comments.

* Fixing column order.

* Fix default Ok returns.

* Removing return Err(... where feasible.
9 months ago
RocketDerp 21a87ebaf2
Federation tests replication round1 - demonstrate absent replication of comment deletes (#3657)
* more robust test of unlike a comment, confirm replication to instance downstream from community home

* more robust 'delete a comment' test, confirm replication

* Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report

* typo and actually have Gamma comment check use gamma, not alpha

* prepare-drone-federation-test.sh has some more echo output and note about the LEMMY_DATABASE_URL format (#3651)

* Add http cache for webfingers (#3317)

* Add http cache for webfingers

* Remove the outgoing cache middleware & adjust the cache headers directive

* Use 1h & 3day cache header

* Update routes and adjust the cache headers location

* revert apub caching

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
Co-authored-by: Felix Ableitner <me@nutomic.com>

* Rewrite activity lists to fix delete federation (fixes #3625)

* Revert "typo and actually have Gamma comment check use gamma, not alpha"

This reverts commit 7dfb6ee0f4.

* Revert "Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report"

This reverts commit 7bd3b20ae0.

* prettier TypeScript

* revised comments, as ResolveObject isn't using routine replication

* fmt

* fix api tests

* remove comment

---------

Co-authored-by: cetra3 <cetra3@hotmail.com>
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
Co-authored-by: Felix Ableitner <me@nutomic.com>
10 months ago
Nutomic e9e76549a8
Split activity table into sent and received parts (fixes #3103) (#3583)
* Split activity table into sent and received parts (fixes #3103)

The received activities are only stored in order to avoid processing
the same incoming activity multiple times. For this purpose it is
completely unnecessary to store the data. So we can split the
table into sent_activity and received_activity parts, where
only sent_activity table needs to store activity data. This should
reduce storage use significantly.

Also reduces activity storage duration to three months, we can reduce
this further if necessary.

Additionally the id columns of activity tables are removed because
they are completely unused and risk overflowing (fixes #3560).

* address review

* move insert_received_activity() methods to verify handlers

* remove unnecessary conflict line

* clippy

* use on conflict, add tests
10 months ago
Nutomic 93225e5ddf
Error enum fixed (#3487)
* Create error type enum

* Replace magic string slices with LemmyErrorTypes

* Remove unused enum

* Add rename snake case to error enum

* Rename functions

* clippy

* Fix merge errors

* Serialize in PascalCase instead of snake_case

* Revert src/lib

* Add serialization tests

* Update translations

* Fix compilation error in test

* Fix another compilation error

* Add code for generating typescript types

* Various fixes to avoid breaking api

* impl From<LemmyErrorType> for LemmyError

* with_lemmy_type

* trigger ci

---------

Co-authored-by: SleeplessOne1917 <abias1122@gmail.com>
11 months ago
Nutomic 6f513793cb
Activitypub crate rewrite (#2782)
* update activitypub-federation crate to 0.4.0

* fixes

* apub compiles!

* everything compiling!

* almost done, federated follow failing

* some test fixes

* use release

* add code back in
1 year ago
Felix Ableitner c6c52ab9cc Add SendActivity trait so that api crates compile in parallel with lemmy_apub 1 year ago
Felix Ableitner 030afbc2e7 Merge websocket crate into api_common 1 year ago
Nutomic bcf5c91f81
Use audience field to federate items in groups (fixes #2464) (#2584) 1 year ago
Felix Ableitner 0b86ffbdbd Remove unwrap 2 years ago
Nutomic a0fed24cee
When announcing incoming activities, keep extra fields (#2550) 2 years ago
Nutomic b0c3185663
Make verify apub url function async (#2514)
* Make verify apub url function async

* cleanup

* use dep from crates.io

* dont use unwrap
2 years ago
Dessalines 235cc8b228
Moving settings to Database. (#2492)
* Moving settings to Database.

- Moves many settings into the database. Fixes #2285
- Adds a local_site and instance table. Fixes #2365 . Fixes #2368
- Separates SQL update an insert forms, to avoid runtime errors.
- Adds TypedBuilder to all the SQL forms, instead of default.

* Fix weird clippy issue.

* Removing extra lines.

* Some fixes from suggestions.

* Fixing apub tests.

* Using instance creation helper function.

* Move forms to their own line.

* Trying to fix local_site_data, still broken.

* Fixing federation tests.

* Trying to fix check features 1.

* Addressing PR comments.

* Adding check_apub to all verify functions.
2 years ago
Nutomic fcaf7a084c
Upgrade activitypub_federation to 0.2.0, add setting federation.debug (#2300) 2 years ago
Nutomic a2a594b763
Extract Activitypub logic into separate library (#2288)
* Create example for apub lib

* some rewriting of apub lib

* Add LocalInstance struct for apub lib to avoid using Lemmy Settings

* Move ActorType trait to lemmy_apub, because its not needed in library

* Use reqwest_retry instead of custom impl, dont specify timeout on every send()

* Some improvements to example

* Moved inbox handling to library

* bug fixes

* Move context and serde helpers into library

* wip: example changes

* Add lemmy_utils feature to build only LemmyError

* Rename to activitypub_federation

* Remove lemmy_utils dep from activitypub_federation using generic error type

* Finish activitypub example

* Cleanup and fix tests

* Reorganize library files

* Remove ApubObject.to_tombstone()

* Extract activitypub library into separate git repository
2 years ago
Nutomic 7b86441bab
Federate with Peertube (#2244) 2 years ago
Nutomic b406342a14
Dont log error if duplicate activity is received (fixes #2146) (#2148) 2 years ago
Nutomic 7d61616dff
Revert "Add logging to debug federation issues (ref #2096) (#2099)" (#2130)
This reverts commit e094989a4c.
2 years ago
Nutomic e094989a4c
Add logging to debug federation issues (ref #2096) (#2099) 2 years ago
Riley 35cbae61bc
Don't drop error context when adding a message to errors (#1958)
* Respond directly with LemmyError

Instrument Perform implementations for more precise traces
Use ApiError to format JSON errors when messages are present
Keep SpanTrace output in LemmyError Display impl

* Hide SpanTrace debug output from LemmyError

* Don't log when entering spans, only when leaving

* Update actix-web

* Update actix-rt

* Add newline after error info in LemmyError Display impl

* Propogate span information to blocking operations

* Instrument apub functions

* Use skip_all for more instrument attributes, don't skip 'self' in some api actions

* Make message a static string

* Send proper JSON over websocket

* Add 'message' to LemmyError display if present

* Use a quieter root span builder, don't pretty-print logs

* Keep passwords and emails out of logs

* Re-enable logging Login

* Instrument feeds

* Emit our own errors

* Move error log after status code recording

* Make Sensitive generic over the inner type

* Remove line that logged secrets
2 years ago
Dessalines 3d08e6c1fc
Adding unique constraint for activity ap_id. Fixes #1878 (#1935)
* Adding unique constraint for activity ap_id. Fixes #1878

* Removing is_activity_already_known
3 years ago
Felix Ableitner afccd5cf69 Replace activitystreams crate with activitystreams-kinds 3 years ago
Felix Ableitner 3e4fe89a45 Fix build error in #1914 3 years ago
Dessalines 6d35508f08
Merge pull request #1914 from LemmyNet/dont-announce-note
Dont announce comments, edited posts to Pleroma/Mastodon followers
3 years ago
Felix Ableitner aeb34199f5 Dont announce comments, edited posts to Pleroma/Mastodon followers 3 years ago
Felix Ableitner a2707e1c56 Community outbox should only contain activities sent by community (fixes #1916) 3 years ago
Felix Ableitner c1f1b8aa0f Activities in community should also be sent to actors in cc 3 years ago
Dessalines 23641fcd06 Use serde_json::to_value 3 years ago
Nutomic 1b9414f292
More federation compat (#1894)
* Make HTTP signatures compatible with Pleroma

* Send Announce/Page, Announce/Note for Pleroma compatibility

* remove unused code
3 years ago
Felix Ableitner 888e683856 For verify_is_public() we also need to check cc field 3 years ago
Felix Ableitner 2edf8ba157 Move ObjectId to library 3 years ago
Felix Ableitner bd3352423a Remove ActivityFields trait, deserialize into another struct instead 3 years ago
Felix Ableitner b396344eae Merge two functions into one 3 years ago
Felix Ableitner 03d8ac75ef Move activity structs to protocol folder 3 years ago
Felix Ableitner d89156810d Move @context out of object/activity definitions 3 years ago
Felix Ableitner 271785b7fb When receiving activity, dont read community from cc (for pleroma compat and better verification) 3 years ago
Felix Ableitner 03b8ae7215 Activity.to should always be a vec (and unspecified size for public activities) 3 years ago
Nutomic 149a4e0de8
Breaking apub changes (#1859)
* Remove CommentInReplyToMigration

* Remove compat for RemovePostCommentOrCommunity

* Remove PublicUrlMigration

* Change type of pm to ChatMessage from Pleroma, make pm.to array

* Use person.summary instead of person.content for pleroma compat

* Also change group.content to summary

* Rewrite apub object test json to serve as nice examples

* Also add test case for parsing pleroma private message
3 years ago
Nutomic dd0ba10b44
Pleroma federation2 (#1855)
* Allow fetching person from Pleroma, including test case (ref #1461)

* Added test case for parsing community from apub json

- fixed a bug with objectid (de)serialization
- fixed a bug with outbox fetching (ref #1582)

* Added apub test for post

* Ignore errors when reading community outbox (fixes #1582)

* Dont fetch community outbox/moderators during tests

* added test for lemmy comment

* Added federation test for pleroma comment

* Added html2md crate to parse comment html from pleroma (fixes #1461)

* some fixes for update_apub_test_files.sh

* Add tests for ToApub, private message, remove update script

* Delete objects from db at the end of each test
3 years ago
Felix Ableitner 1aa0e1997b Major refactor, adding newtypes for apub crate
- this allows moving FromApub/ToApub traits into apub lib
3 years ago
Nutomic b96ce81f89
Move code to apub library (#1795)
* Remove dependency of apub_lib on LemmyContext

* Move ApubObject trait to library

* Reorganize files in apub lib

* Move ActorType, signatures, activity_queue to apub library
3 years ago
Dessalines 8708ad1b44 Moving settings and secrets to context. 3 years ago
Nutomic 527eefbe92
Rewrite fetcher (#1792)
* Use new fetcher implementation for post/comment

* rewrite person fetch to use new fetcher

* rewrite community to use new fetcher

* rename new_fetcher to dereference_object_id

* make ObjectId a newtype

* handle deletion in new fetcher

* rewrite apub object search to be generic

* move upsert() method out of ApubObject trait

* simplify ObjectId::new (and fix clippy)
3 years ago
Nutomic 2822f5a126
Change public activities to field to array (#1739) 3 years ago
Nutomic f6f169b4eb
Rewrite remaining activities (#1712)
* Limit type/method visibility in apub code

* Simplify db_queries traits by removing generics

* Simplify delete activity implementation

* Rewrite delete activities

* Implement helper functions for websocket message sending

* When receiving delete reason as empty string, change to none

* Rewrite remaining activities

* Simplify inbox

* Remove struct ActivityCommonFields, derive ActivityFields trait instead

* Community should announce received activities to followers
3 years ago
Nutomic 28d6370c35
Rewrite delete activities (#1699)
* Limit type/method visibility in apub code

* Simplify db_queries traits by removing generics

* Simplify delete activity implementation

* Rewrite delete activities

* Implement helper functions for websocket message sending

* When receiving delete reason as empty string, change to none
3 years ago
Nutomic 353a1fe0a0
Rewrite activitypub following, person, community, pm (#1692)
* Rewrite following activities

* Rewrite person apub

* Rewrite community apub

* Rewrite private message activity sending
3 years ago
Nutomic b8d7f00d58
Rewrite voting (#1685)
* Merge like/dislike activity handlers into vote

* Rewrite vote sending code

* Remove old send_create, send_update functions
3 years ago
Felix Ableitner dc363c8f35 Merge logic for post create and update 3 years ago
Felix Ableitner 3eb46868ff Merge logic for comment create and update 3 years ago