Big refactoring of the Inbox (#443)

* Big refactoring of the Inbox

We now have a type that routes an activity through the registered handlers
until one of them matches.

Each Actor/Activity/Object combination is represented by an implementation of AsObject

These combinations are then registered on the Inbox type, which will try to deserialize
the incoming activity in the requested types.

Advantages:
- nicer syntax: the final API is clearer and more idiomatic
- more generic: only two traits (`AsActor` and `AsObject`) instead of one for each kind of activity
- it is easier to see which activities we handle and which one we don't

* Small fixes

- Avoid panics
- Don't search for AP ID infinitely
- Code style issues

* Fix tests

* Introduce a new trait: FromId

It should be implemented for any AP object.

It allows to look for an object in database using its AP ID, or to dereference it if it was not present in database

Also moves the inbox code to plume-models to test it (and write a basic test for each activity type we handle)

* Use if let instead of match

* Don't require PlumeRocket::intl for tests

* Return early and remove a forgotten dbg!

* Add more tests to try to understand where the issues come from

* Also add a test for comment federation

* Don't check creation_date is the same for blogs

* Make user and blog federation more tolerant to errors/missing fields

* Make clippy happy

* Use the correct Accept header when dereferencing

* Fix follow approval with Mastodon

* Add spaces to characters that should not be in usernames

And validate blog names too

* Smarter dereferencing: only do it once for each actor/object

* Forgot some files

* Cargo fmt

* Delete plume_test

* Delete plume_tests

* Update get_id docs + Remove useless : Sized

* Appease cargo fmt

* Remove dbg! + Use as_ref instead of clone when possible + Use and_then instead of map when possible

* Remove .po~

* send unfollow to local instance

* read cover from update activity

* Make sure "cc" and "to" are never empty

and fix a typo in a constant name

* Cargo fmt
This commit is contained in:
Baptiste Gelez
2019-04-17 18:31:47 +01:00
committed by GitHub
parent c19c094e0c
commit 12efe721cc
49 changed files with 2883 additions and 1521 deletions
+17 -13
View File
@@ -42,6 +42,9 @@ msgstr "الصورة الرمزية لـ {0}"
msgid "To create a new blog, you need to be logged in"
msgstr ""
msgid "A blog with the same name already exists."
msgstr "هناك مدونة تحمل نفس التسمية."
#, fuzzy
msgid "You are not allowed to delete this blog."
msgstr "لست مِن محرري هذه المدونة."
@@ -213,8 +216,8 @@ msgid "Allow anyone to register here"
msgstr "السماح للجميع بتسجيل حساب"
#, fuzzy
msgid "Short description - byline"
msgstr "وصف قصير"
msgid "Short description"
msgstr "الوصف الطويل"
#, fuzzy
msgid "Markdown syntax is supported"
@@ -234,7 +237,8 @@ msgstr "حفظ التعديلات"
msgid "About {0}"
msgstr "عن {0}"
msgid "Home to <em>{0}</em> users"
#, fuzzy
msgid "Home to <em>{0}</em> people"
msgstr "يستضيف <em>{0}</em> مستخدمين"
msgid "Who wrote <em>{0}</em> articles"
@@ -372,7 +376,7 @@ msgid "Subscribe"
msgstr ""
#, fuzzy
msgid "{0}'s subscriptions'"
msgid "{0}'s subscriptions"
msgstr "الوصف"
#, fuzzy
@@ -396,7 +400,7 @@ msgid "Plume is a decentralized blogging engine."
msgstr "بلوم محرك لامركزي للمدونات."
#, fuzzy
msgid "Authors can manage various blogs, each as an unique website."
msgid "Authors can manage multiple blogs, each as its own website."
msgstr "يمكن للمدونين إدارة عدة مدونات مِن موقع ويب وحيد."
#, fuzzy
@@ -407,10 +411,6 @@ msgstr ""
"ستكون المقالات معروضة كذلك على مواقع بلوم الأخرى، و يمكنكم التفاعل معها "
"مباشرة عبر أية منصة أخرى مثل ماستدون."
#, fuzzy
msgid "Home to <em>{0}</em> people"
msgstr "يستضيف <em>{0}</em> مستخدمين"
msgid "Read the detailed rules"
msgstr "إقرأ القواعد بالتفصيل"
@@ -647,7 +647,7 @@ msgstr "أعجبني"
#, fuzzy
msgid "One boost"
msgid_plural "{0} boost"
msgid_plural "{0} boosts"
msgstr[0] "بدون مشاركة"
msgstr[1] "مشاركة واحدة"
msgstr[2] "مشاركتان"
@@ -841,6 +841,13 @@ msgstr "قم بنسخه و إلصاقه في محتوى مقالك لعرض ال
msgid "Use as an avatar"
msgstr "استخدمها كصورة رمزية"
#, fuzzy
#~ msgid "Short description - byline"
#~ msgstr "وصف قصير"
#~ msgid "Home to <em>{0}</em> users"
#~ msgstr "يستضيف <em>{0}</em> مستخدمين"
#~ msgid "Login"
#~ msgstr "تسجيل الدخول"
@@ -948,9 +955,6 @@ msgstr "استخدمها كصورة رمزية"
#~ msgid "Invalid name"
#~ msgstr "اسم غير صالح"
#~ msgid "A blog with the same name already exists."
#~ msgstr "هناك مدونة تحمل نفس التسمية."
#~ msgid "Your comment can't be empty"
#~ msgstr "لا يمكن ترك التعليق فارغا"