Commit graph

132 commits

Author SHA1 Message Date
Felix Ableitner
7f4a773b88 Create and Note always need to tag parent creator, for mastodon notifications 2021-11-16 18:07:47 +01:00
Felix Ableitner
c1f1b8aa0f Activities in community should also be sent to actors in cc 2021-11-16 18:07:45 +01:00
Felix Ableitner
252d87d332 Fix clippy error 2021-11-08 13:16:14 +01:00
Felix Ableitner
888e683856 For verify_is_public() we also need to check cc field 2021-11-06 18:44:34 +01:00
Felix Ableitner
a5a674a270 Add method ApubObject.verify() 2021-11-06 18:35:14 +01:00
Felix Ableitner
02ce7bdc7d Remove unused ActorType methods 2021-11-06 15:01:00 +01:00
Felix Ableitner
8ea21c39b7 Reduce stack memory usage in apub code
- use our own, smaller Endpoints struct
- wrap ObjectId.url in Box
- adjust usage of Box in different places
2021-11-06 14:53:39 +01:00
Felix Ableitner
c725514841 Change to_apub and from_apub to take by value and avoid cloning 2021-11-06 14:47:58 +01:00
Felix Ableitner
2edf8ba157 Move ObjectId to library 2021-11-05 21:37:46 +01:00
Felix Ableitner
969a7f2d1b Refactoring apub code 2021-11-05 21:12:10 +01:00
Dessalines
a83113935d
Check if post or comment are deleted first. Fixes #1864 (#1867)
* Check if post or comment are deleted first. Fixes #1864

* Refactoring delete apub.

* Revert "Refactoring delete apub."

This reverts commit ba2c3d06cfb870efe792f4b2541036265b425156.
2021-11-03 17:47:24 +00:00
Felix Ableitner
41f7bcc0d2 Correctly use and document check_is_apub_id_valid() param use_strict_allowlist 2021-11-02 21:39:06 +01:00
Felix Ableitner
b396344eae Merge two functions into one 2021-11-02 21:39:06 +01:00
Felix Ableitner
1c6f74cad5 Convert note.content and chat_message.content to html (fixes #1871) 2021-11-02 21:39:02 +01:00
Felix Ableitner
0bde2d595e Add tests for parsing activities and collections 2021-11-02 12:44:51 +01:00
Felix Ableitner
aaaf039779 Move apub test files into tree structure 2021-10-29 16:54:19 +02:00
Felix Ableitner
5ff044346f Move object and collection structs to protocol folder 2021-10-29 12:50:32 +02:00
Felix Ableitner
d89156810d Move @context out of object/activity definitions 2021-10-29 12:50:32 +02:00
Felix Ableitner
271785b7fb When receiving activity, dont read community from cc (for pleroma compat and better verification) 2021-10-29 12:50:30 +02:00
Felix Ableitner
74523fb534 Make Note.context optional for pleroma compat (hack) 2021-10-29 12:45:54 +02:00
Felix Ableitner
6792e376b4 Rewrite community outbox to use new fetcher 2021-10-29 12:45:53 +02:00
Felix Ableitner
bb085189e0 Merge traits ToApub and FromApub into ApubObject 2021-10-29 12:45:53 +02:00
Nutomic
61189efe72
Rewrite collections to use new fetcher (#1861)
* Merge traits ToApub and FromApub into ApubObject

* Rewrite community outbox to use new fetcher

* Rewrite community moderators collection

* Rewrite tombstone
2021-10-27 12:03:07 -04:00
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
2021-10-22 12:21:26 -04:00
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
2021-10-21 13:25:35 -04:00
Felix Ableitner
1aa0e1997b Major refactor, adding newtypes for apub crate
- this allows moving FromApub/ToApub traits into apub lib
2021-10-20 12:28:09 +02:00
Felix Ableitner
f24999027e Merge crates db_schema and db_queries 2021-10-20 12:28:08 +02:00
Dessalines
2402515fcc
Dont allow posts to deleted / removed communities. Fixes #1827 (#1828)
* Dont allow posts to deleted / removed communities. Fixes #1827

* Fixing couldnt find community error.

* Adding check in createorupdate post and comment.

* make sure post wasn't deleted or removed.

* Adding a post not deleted or removed check to creatorupdatecomment.

* Using pub(crate)
2021-10-14 16:33:19 +00:00
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
2021-10-06 16:20:05 -04:00
Dessalines
8708ad1b44 Moving settings and secrets to context. 2021-09-27 11:25:26 +02:00
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)
2021-09-25 11:44:52 -04:00
Dessalines
6af75492a9
Swap out iframely (#1706)
* Replace Iframely. Fixes #1681

* Add post_link_tags to nginx

* Adding post_link_tags route

* Cleaning up post_link_tags

* Changing PostLink to SiteMetadata, adding it to the API.

* Fixing issue when local has no openssl certs.

* Fixing an issue with pictrs errors

* Revert "Fixing issue when local has no openssl certs."

This reverts commit dbf7d1b1ee03846e5ef7b7156e618424f1150e1d.

* Add ca-certs to dockerfile for volume mount.

* Cleaning up fetch_pictrs request

* Changing to fetch_site_data
2021-08-19 14:12:49 +00:00
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
2021-08-17 14:04:58 -04:00
Nutomic
353a1fe0a0
Rewrite activitypub following, person, community, pm (#1692)
* Rewrite following activities

* Rewrite person apub

* Rewrite community apub

* Rewrite private message activity sending
2021-08-12 08:48:09 -04:00
Felix Ableitner
b2937223df Migrate comment inReplyTo field to single value (ref #1454) 2021-08-05 13:00:29 +02:00
Dessalines
7b8cbbba85
Simplify config using macros (#1686)
Co-authored-by: Felix Ableitner <me@nutomic.com>
2021-08-04 21:13:51 +00:00
Felix Ableitner
6b57d716e1 Rewrite private message apub and merge create/update 2021-07-31 22:58:11 +02:00
Felix Ableitner
43ad99bbe8 Rewrite apub comment (de)serialization using structs (ref #1657) 2021-07-31 16:57:37 +02:00
Felix Ableitner
433ab1e78b Add docs for MediaType, PublicUrl values 2021-07-30 23:16:33 +02:00
Felix Ableitner
57b6ecaf40 Simplify lemmy_context() function (dont return errors) 2021-07-30 23:16:33 +02:00
Felix Ableitner
ff265c7ebc Rewrite apub post (de)serialization using structs (ref #1657) 2021-07-30 23:16:32 +02:00
Nutomic
c7de1fcf24
Apub inbox rewrite (#1652)
* start to implement apub inbox routing lib

* got something that almost works

* it compiles!

* implemented some more

* move library code to separate crate (most of it)

* convert private message handlers

* convert all comment receivers (except undo comment)

* convert post receiver

* add verify trait

* convert community receivers

* add cc field for all activities which i forgot before

* convert inbox functions, add missing checks

* convert undo like/dislike receivers

* convert undo_delete and undo_remove receivers

* move block/unblock activities

* convert remaining activity receivers

* reimplement http signature verification and other checks

* also use actor type for routing, VerifyActivity and SendActivity traits

* cleanup and restructure apub_receive code

* wip: try to fix activity routing

* implement a (very bad) derive macro for activityhandler

* working activity routing!

* rework pm verify(), fix tests and confirm manually

also remove inbox username check which was broken

* rework following verify(), fix tests and test manually

* fix post/comment create/update, rework voting

* Rewrite remove/delete post/comment, fix tests, test manually

* Rework and fix (un)block user, announce, update post

* some code cleanup

* rework delete/remove activity receivers (still quite messy)

* rewrite, test and fix add/remove mod, update community handlers

* add docs for ActivityHandler derive macro

* dont try to compile macro comments
2021-07-17 12:08:46 -04:00
Dessalines
f54209c451
Running clippy --fix (#1647) 2021-07-05 16:07:26 +00:00
Dessalines
f8cd6fd445 Making more fields optional in the API.
- Fixes #1569
2021-04-23 02:30:13 -04:00
Nutomic
efee2062dd
Mark accounts as bot nutomic (#1565)
* Mark account as bot. Fixes #1357

* Fix clippy

* Federate bot status using actor `type` field

* fix clippy

Co-authored-by: Dessalines <tyhou13@gmx.com>
2021-04-21 17:41:14 -04:00
Nutomic
8bb3ba4a16
Add option to disable strict allowlist (fixes #1486) (#1581)
* Add option to disable strict allowlist (fixes #1486)

* adjust docs
2021-04-21 09:36:07 -04:00
Felix Ableitner
c572dc0cc6 Remote mods can update/delete/undelete communities 2021-04-13 15:19:17 +02:00
Dessalines
c3d64f996e
Removing community.creator column. Fixes #1504 (#1541)
* Removing community.creator column. Fixes #1504

* Fixing unit tests.

* Fixing federation tests.
2021-04-08 11:29:08 +00:00
Dessalines
bf7558830f Changing preferred to display name. Fixes #1211 2021-04-01 13:57:45 -04:00
Felix Ableitner
722cdb78ba Split lemmy_apub crate into two parts apub and apub_receive 2021-03-30 22:29:16 +02:00
Dessalines
4c8f2e976e Merge remote-tracking branch 'yerba/split-api-crate' into test_merge_api_crates_reorg 2021-03-29 16:24:50 -04:00
Felix Ableitner
249fcc5066 Split api crate into api_structs and api 2021-03-25 20:19:40 +01:00
Felix Ableitner
34bdf4c7c5 Federate Matrix ID (fixes #1438) 2021-03-24 17:56:13 +01:00
Dessalines
3ca2453fc6 Merge branch 'main' into move_matrix_and_admin_to_person 2021-03-24 11:51:34 -04:00
Felix Ableitner
c7524d924b Fix federation tests 2021-03-24 16:33:04 +01:00
Dessalines
eb45bf2d0a Moving admin to person table. Fixes #1515 2021-03-22 10:28:00 -04:00
Felix Ableitner
d6bd072ea1 Make federation compatible with Lemmy v0.9.9 2021-03-22 15:08:06 +01:00
Felix Ableitner
a5a0d90349 Address review comments 2021-03-22 13:52:00 +01:00
Dessalines
c884510173 Creating default DB forms. Fixes #1511 2021-03-20 16:59:07 -04:00
Dessalines
1745b64ceb Moving matrix_user_id to person table. #1438 2021-03-20 15:21:51 -04:00
Felix Ableitner
4f54108a9c Merge branch 'main' into federated-moderation 2021-03-19 17:11:34 +01:00
Dessalines
c3efb9f7cf Strictly typing DB id fields. Fixes #1498 2021-03-18 16:25:21 -04:00
Felix Ableitner
4f7dca7c2b Fix three federation test cases 2021-03-18 17:02:15 +01:00
Felix Ableitner
71067a8cb5 For FromApub trait, use is_mod_action: bool instead 2021-03-16 18:26:19 +01:00
Felix Ableitner
de14636e10 Fix code to allow sticky/lock from remote moderators 2021-03-12 16:46:36 +01:00
Dessalines
9cb4dad4b4 A first pass. 2021-03-10 23:43:11 -05:00
Dessalines
ddf4a667b1 ~80% done 2021-03-10 17:33:55 -05:00
Felix Ableitner
dcf40db225 Update activitystreams to 0.7.0-alpha.11 2021-03-09 18:14:15 +01:00
Felix Ableitner
0c484e8c76 Move moderators collection to separate HTTP endpoint 2021-03-09 18:14:15 +01:00
Felix Ableitner
beb8b9fe69 Use collection for moderators, instead of attributedTo (ref #1061) 2021-03-09 18:14:15 +01:00
Andrew Yoon
e78ba38e94
Use URL type in most outstanding struct fields (#1468)
* Use URL type in most outstanding struct fields

This fixes all known remaining cases where url fields are stored as
plain strings, with the exception of form fields where empty strings
are used as sentinels (see `diesel_option_overwrite_to_url`).

Tested for regressions in the federated docker setup attempting to
exercise all changed fields, including through apub federation.

Fixes #1385

* Add migration to fix blank-string post.url values to be null

This also then fixes #602

* Address review feedback

- Fixed some unwraps and err message formatting
- Bumped the `url` library to 2.2.1 to fix a bug with serde error
  messages
- Add unit tests for the two diesel option override functions
- Fix migration teardown by adding a no-op

* Rename lemmy_db_queries::Url to lemmy_db_queries::DbUrl

* fix compile error

* box PostOrComment variants
2021-03-02 12:41:48 +00:00
Dessalines
462c4a2954
Rewrite settings implementation. Fixes #1270 (#1433)
* A first attempt at using deser-hjson. Fixes #1270

* Trying to fix tests, try 1

* Trying to fix tests, try 2

* A few fixes to deser_hjson

- Removing unwrap_or_defaults, using impl functions.
- Reorganized settings

* Make clippy happy

* hjson list strings must be quoted.

* Adding support for env vars.

* Moving to structs and defaults file.

* Moving settings default and struct.
2021-03-01 17:24:11 +00:00
Felix Ableitner
3bdd78f341 Rename lemmy_structs to lemmy_api_structs 2021-03-01 14:08:41 +01:00
Felix Ableitner
c618b4efaa Remove federation backward compatibility code (ref #1220) 2021-02-26 14:06:26 +01:00
Felix Ableitner
3141ad31de Remove categories (fixes #1429) 2021-02-25 13:22:37 +01:00
Felix Ableitner
92ea9b97dd Dont include community in comment to field (fixes #1446) 2021-02-23 19:00:47 +01:00
Felix Ableitner
8d5e9f865c Use name field for post titles instead of summary (ref #1220) 2021-02-22 19:34:41 +01:00
Felix Ableitner
63d9c0ee46 Explicitly mark posts and comments as public (ref #1220) 2021-02-10 14:01:02 +01:00
Felix Ableitner
105dfc93f1 Make apub extension fields optional (ref #1220) 2021-02-05 14:23:57 +01:00
nutomic
1a4e35eb50 Store activitypub endpoints in database (#162)
Address review comments

Store Activitypub urls in database (fixes #808)

Co-authored-by: Felix Ableitner <me@nutomic.com>
Reviewed-on: https://yerbamate.ml/LemmyNet/lemmy/pulls/162
Co-Authored-By: nutomic <nutomic@noreply.yerbamate.ml>
Co-Committed-By: nutomic <nutomic@noreply.yerbamate.ml>
2021-02-04 16:34:58 +00:00
Nutomic
3d578f9df2
Use Url type for ap_id fields in database (fixes #1364) (#1371) 2021-01-27 11:42:23 -05:00
Felix Ableitner
3b64c58198 Move most code into crates/ subfolder 2021-01-20 16:21:27 +01:00