Commit Graph

502 Commits

Author SHA1 Message Date
Igor Galić
bf1673dda1
start exploring some ideas for domain validation 2019-08-14 23:51:28 +02:00
Igor Galić
ff0c82efc1
review by @fdb-hiroshima
Co-Authored-By: fdb-hiroshima <35889323+fdb-hiroshima@users.noreply.github.com>
2019-08-14 23:51:27 +02:00
Ana Gelez
da6757c55c
Basic domain validation
The actual DNS check still needs to be written
2019-08-14 23:51:27 +02:00
Igor Galić
60270121dc
fix clippy warning
Co-Authored-By: fdb-hiroshima <35889323+fdb-hiroshima@users.noreply.github.com>
2019-08-14 23:51:26 +02:00
Ana Gelez
fdc7da0edf
Strings have to be cloned 2019-08-14 23:51:25 +02:00
Igor Galić
2dedcdbc53
start modifying /blogs/new to add custom_domain to the form 2019-08-14 23:51:24 +02:00
Trinity Pointard
b172a80e35
finally fix url!
also please a bit clippy
2019-08-14 23:51:23 +02:00
Trinity Pointard
c5f6b88b1d
make url! work better
there is still some issue with `None`, and an error making no sense at
some place
2019-08-14 23:51:23 +02:00
Trinity Pointard
cdc919e308
allow more syntaxes for url
allow for params that are used only by one of normal/custom routes
2019-08-14 23:51:21 +02:00
Igor Galić
f635dcf6c3
move custom_ route functions into a custom namespace
this way, we can actually use the url! macro
2019-08-14 23:51:20 +02:00
Trinity Pointard
7139119b8f
add url! macro for custom domain path uri creation
see doc-comment for limitations
2019-08-14 23:51:20 +02:00
Igor Galić
203da23cf2
follow up on @fdb-hiroshima & @BaptisteGelez review 2019-08-14 23:51:19 +02:00
Igor Galić
f73fba583a
custom_domainify posts::details 2019-08-14 23:51:18 +02:00
Igor Galić
fe110b5d8a
fix issues pointed out by @BaptisteGelez in review 2019-08-14 23:51:17 +02:00
Igor Galić
cc0df4ecb2
redirect blog urls to custom_domain if it exists 2019-08-14 23:51:16 +02:00
Igor Galić
8e7f789969
Allow searching from custom_domain 2019-08-14 23:51:15 +02:00
Igor Galić
92fbd174eb
extend 404 handler to handle all the requests our custom_ routes dont 2019-08-14 23:51:14 +02:00
Igor Galić
6253adf768
simplify / unify error handling
We want to return a Result<Blog>, instead of a QueryResult<Blog>.
We can use map_err() to map it to the desired error type.

thanks to review from @BaptisteGelez & @fdb-hiroshima.
2019-08-14 23:51:13 +02:00
Igor Galić
a0aef50674
extract common routing code into private "_guts()" functions 2019-08-14 23:51:13 +02:00
Igor Galić
8e6b1ab86e
simplify retrieval in find_by_host()
we can use "first()" instead of limit(1).load().etc…
since on a UNIQUE field, we only expect 1 result.

first() returns QueryResult, which is Result<T, diesel::Error>, so we
need to implement a converter for that error type.

This commit addresses @fdb-hiroshima's review.
2019-08-14 23:51:12 +02:00
Igor Galić
468e663344
Add custom_details and custom_activity_details as first routes
how this works: we use find_by_host() to find the Host in question, the
defer to the existing function!

Caveat: Currently, we, in that function, we do another lookup DB lookup
for the Blog, even thou we already know it.
It might be wise, to have both of those another wrapper here?!
2019-08-14 23:51:10 +02:00
Igor Galić
0645f7e253
CustomDomainFairing must not match /static/ and /api/
thanks, again, @fdb-hiroshima for helping with this code, when i got
stuck in lifetime-hecc.
2019-08-14 23:51:10 +02:00
Igor Galić
b09b51c74b
normalize URLs before setting them 2019-08-14 23:51:08 +02:00
Igor Galić
e6747de998
cache custom_domains list
follow #572 and cache the list of custom domains.
2019-08-14 23:51:07 +02:00
Igor Galić
3a4c2f2cf9
create & attach an AdHoc Fairing for dealing with Custom Domains
this rewrites the URL to /custom_domain/<url>
(we have no route handlers for this path yet)

Lots of help from @fdb-hiroshima & @BaptisteGelez in dealing with the
borrow checker — thank you 💜
2019-08-14 23:51:06 +02:00
Igor Galić
351c01f71c
list custom_domains
thanks a lot to @fdb-hiroshima and @BaptisteGelez for helping with the
code.
2019-08-14 23:51:05 +02:00
fdb-hiroshima
4f7c20fc26 Fix some federation issue (#573)
* send scheme as part of webfinger remote follow template

fix tsileo/microblog.pub#49

* bump webfinger to 0.4.1

* cargo fmt

* revert translations

* Use group: prefix for blog webfinger queries
2019-07-31 11:38:49 +02:00
Mostafa Ahangarha
54c6d21fc5 WIP - initial RTL support #575 (#577)
* initial RTL support

* fix dir in template-util

* fix dir in blogs new

* fix dir in blogs details

* fix dir in posts new

* fix dir in posts details

* fix dir in posts remote

* Fix dir in partials

some parts should be recheck carefully in real usage
2019-07-11 09:34:27 +02:00
Wilfried OLLIVIER
c031804464 Add clap to plume in order to print help and version (#631)
* Add clap in order to print help and version

Related to https://github.com/Plume-org/Plume/issues/594

* Update after_help text message
2019-07-03 19:36:42 +01:00
fdb-hiroshima
5289fe872a
don't ignore dotenv errors (#630) 2019-07-03 09:30:44 +02:00
Igor Galić
3d27e283ad
add enum containing all successful route returns (#614)
* add enum containing all successful route returns

This enum derives `Responder`, so it can be used as route result.
We also implement `From`, so it can be converted

* disable clippy warning about this enum

There's no use trying to chase this warning.
The next warning will be about `Redirect`, which itself is 360 byte,
according to @fdb-hiroshima (thanks for the research!)

So, if anything, we can try to get Rocket to work on that!

* refactor routes/posts to only use one level of Result

* admin settings error is not an ErrorPage, so dont use Result<>

* refactor: use early return to remove indent of main logic

This diff is absolutely atrocious.
but the resulting readability is worth it

* refactor routes/post for early returns & RespondOrRedirect

* refactor routes/session for early returns & use RespondOrRedirect

* refactor routes/user -- add another field to enum

* refactor routes/blogs for early returns & RespondOrRedirect

* refactor routes/blogs for early returns & RespondOrRedirect

This is a final refactor of `pub fn update()` for readability.
We're removing at least one indentation level.
2019-06-14 09:33:30 +02:00
Rob Watson
4b205fa995 Store password reset requests in database (#610)
* Store password reset requests in database

Signed-off-by: Rob Watson <rfwatson@users.noreply.github.com>

* Refactor password reset request expiry handling

* Integrate sqlite

* Fix formatting
2019-06-04 19:55:17 +01:00
Marek Ľach
037674ae13 Direct follow-up to #578 (#603) 2019-05-29 12:26:37 +01:00
Igor Galić
8c59c822b6 refactor code to use Shrinkwraprs and diesel-derive-newtype (#598)
* add shrinkwraprs and implement Id thru it

This also means we can automatically convert Id to String without using
.into()!

* cleanup with the help of clippy!

* cleanup with the help of cargo fmt!

* remove extra block

* Shrinkwrap Page, ContentLen and RemoteForm

* translations
2019-05-25 19:23:45 +01:00
Baptiste Gelez
ad3a8b92d1
Theme update (#553)
* Start to update the theme

- Ligther colors
- No more border radius
- Buttons are now always colored
- Start to redesign the post page (according to the Figma mockups)

* Fix build script: it now recompiles everytime a scss file changed

* Make sure the article illustrations are not too big

* Make articles wider (70 characters)

* Better contrast between gray shades

* Various improvements

* Better mobile style

* New style for the footer

* Improve comment style

* Better responsiveness again

* Limit the size of the article cover

* Last details?

- Improve buttons on the media page
- Improve lists

* Pin the stdweb version that we use

It changed because I removed Cargo.lock to handle a merge conflict

I could have updated cargo web too, but it mean I should have re-built
the CI docker image and it was taking forever.

* Better contrast for links in the header of the article

* Add a basic privacy policy

* Remove "also"

* Fix a few issues

- Don't watch static/css in build.rs
- Another shade of white
- Remove useless margin rule for error messages
2019-05-18 13:09:51 +01:00
Marek Ľach
c67f65e684 Fix occurrences of 'have been' to 'has been' (#578)
* Update comments.rs

* Update medias.rs

* Update posts.rs

* Update user.rs

* Update posts.rs

* Update user.rs
2019-05-14 11:54:16 +01:00
fdb-hiroshima
773fbfe7c8 cache local instance (#572)
* cache local instance

fix #564

* don't use local instance cache for plm

* use instance cache for plm, but initialize it

* cargo fmt
2019-05-10 21:59:34 +01:00
fdb-hiroshima
c52aac012c
make hashtags work in profile summary (#562)
* make hashtags work in profile summary

fix #541

* cargo fmt
2019-05-04 17:33:50 +02:00
fdb-hiroshima
c9070930d2
Improve notification management (#561)
* Don't notify for comment when mentioned

fix #505

* Don't save notification for remote users

fix #472
2019-05-04 17:15:41 +02:00
Baptiste Gelez
8f1ab3485e
Add some feedback when performing some actions (#552)
* Add a way to display flash messages

* Make the flash messages look nice

* Add actual feedback messages

* cargo fmt

* Move flash messages to PlumeRocket

And add trait to convert PlumeRocket to BaseContext

* Remove useless lifetime
2019-04-30 11:04:25 +01:00
fdb-hiroshima
49bb8cb0bc
import migrations and don't require diesel_cli for admins (#555)
* import migrations via macro

* panic on database not to the latest migration

* add subcommand to plm

* create migration that run tantivy index creation

* remove diesel_cli from places it was

* use our migration system for tests

* create table __diesel_schema_migrations if needed
2019-04-29 16:30:20 +02:00
Baptiste Gelez
ec57f1e687
Remove Canapi (#540)
* Remove Canapi

It added more complexity than it helped.

* Fail if there are many blog, but none was specified

* cargo fmt
2019-04-28 22:17:21 +01:00
Baptiste Gelez
787eb7f399
Federate user deletion (#551)
* Federate user deletion

- When someone deletes their account
- When a local user is banned

Fixes #509

* cargo fmt
2019-04-28 18:01:41 +01:00
Baptiste Gelez
68dd8602b2
New Crowdin translations (#479)
Enjoy!
2019-04-19 13:59:03 +01:00
fdb-hiroshima
0d708e1639 Add support for remote interact (#519)
Add support for remote interaction ([this thing](https://eldritch.cafe/users/Barmaid/remote_follow) in mastodon)

- [x] create the endpoint dispatching remote interactions to local pages
- [x] add this endpoint to web-finger
- [x] propose remote interaction when following and not connected
- [x] propose remote interaction when liking/sharing and not connected
- [x] propose remote interaction when commenting and not connected
- [x] fetch posts/comments we don't know but remote interaction was requested for ?
2019-04-17 21:09:07 +01:00
Baptiste Gelez
12efe721cc
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
2019-04-17 18:31:47 +01:00
fdb-hiroshima
c19c094e0c
add diverse links and meta to head (#522) 2019-04-09 15:33:34 +02:00
fdb-hiroshima
12c2078c89
Hide cw pictures behind a summary/details (#483)
* Hide cw pictures behind a summary/details
* refactor md_to_html a bit and add cw support
* use random id for cw checkbox
2019-04-06 19:20:33 +02:00
fdb-hiroshima
eabe73ddc0
Add tests for plume webserver (#513)
* begin setup front-end test environment with selenium
* run migrations before tests
* use https for tests
2019-04-06 17:41:57 +02:00
Marek Ľach
723d2c4600 Grammar corrections followup to #510 (#512)
A very small commit, but let's do all the string corrections while I am already at it :-)

Wraps up #510
2019-04-02 14:08:07 +01:00