Commit graph

24 commits

Author SHA1 Message Date
Vincent Ambo
705097dab9 feat(handlers/render): Display edit form for user's own posts
Displays an edit form for posts that are owned by a user (which is
currently defined as "email addresses match").
2018-04-15 23:09:44 +02:00
Vincent Ambo
ec712cc4c0 refactor(templates/render): Add generic post editing template
Adds a generic template that can be used for submitting, responding to
and editing posts.
2018-04-15 21:13:20 +02:00
Vincent Ambo
aeaa497a62 fix(handlers): Trim leading/trailing whitespace from new threads 2018-04-15 13:01:06 +02:00
Vincent Ambo
9cee48f2da feat(handlers): Determine whether current user can edit a post 2018-04-15 12:38:12 +02:00
Vincent Ambo
ba33efd772 refactor(handlers): Receive search terms via query parameters
There are several reasons for this, but one important one is that
people expect to be able to share search links.
2018-04-14 23:28:34 +02:00
Vincent Ambo
4132869277 feat: Implement search result view & enable search
Implements a very simple and currently kinda broken-looking search
result view.
2018-04-14 22:21:55 +02:00
Vincent Ambo
ea68bac427 refactor(handlers): Improve error handling in post creation 2018-04-14 22:21:55 +02:00
Vincent Ambo
a326e1ea2e feat: License project under GPLv3 2018-04-14 16:40:56 +02:00
Vincent Ambo
8c30ef92f6 refactor(db): Store thread body in the posts table
This is a simplification over the previous approach. The OP of a
thread is just a normal post like any other in this model, which
allows some code simplifications (and future query convenience).
2018-04-14 16:33:45 +02:00
Vincent Ambo
bf02c70f74 feat(handlers/main): Add 'anonymous' mode for forum
Adds a `REQUIRE_LOGIN` environment variable which, if set to anything
other than true, will let users post anonymously on the forums.
2018-04-12 01:28:37 +02:00
Vincent Ambo
e7a54a5aff feat(handler): Perform basic input validation on new thread view 2018-04-12 01:07:25 +02:00
Vincent Ambo
0ec214423e fix(handlers): Fix chained error handling in actors
This took me some time to figure out so it's useful to document in the
commit message.

When chaining messages from actors, the result type of a message (i.e.
the actual `<M as Message>::Result`) is sometimes itself a
`Result<T, E>`.

In many cases this leads to a situation where the return type of a
message sending process is something like (simplified):

    Future<Item=Result<Foo, ConverseError>, Error=actix::MailboxError>

Due to the implementation of
`From<actix::MailboxError> for ConverseError` it is possible to use
`.from_err()` on these futures to convert the future's `Error` to
`ConverseError`.

The type `Result` apparently implements `IntoFuture`, which means that
due to some trait magic that's been applied somewhere in the futures
API a call to `flatten()` can "lift" the contained error if the error
types match and give us a "simple"

    Future<Item=Foo, Error=ConverseError>

From that point on chaining becomes easy.
2018-04-12 00:04:37 +02:00
Vincent Ambo
a9917d54a8 chore(handlers): Remove unused code 2018-04-11 23:34:49 +02:00
Vincent Ambo
918c2726b4 fix(templates/handlers): Fix post anchors
- ensure users are correctly linked to a post actor after replying
- ensure timestamps are clickable to get post IDs
2018-04-11 16:35:40 +02:00
Vincent Ambo
b781a1fe57 chore: Clean up unused imports 2018-04-11 16:35:26 +02:00
Vincent Ambo
1cce37446b refactor(handlers): Use rendering actor for page renders
This currently breaks error handling in page render flows. To fix it
properly, the database actor should return failable futures instead of
`Result<T>` wrapped in a future.
2018-04-11 12:18:33 +02:00
Vincent Ambo
103a59485f feat(handlers/templates): Add "New Thread" handler and template 2018-04-09 23:37:41 +02:00
Vincent Ambo
7c73949066 feat(handlers): Extract & add author to thread and post information 2018-04-09 09:20:27 +02:00
Vincent Ambo
ef5e8ec8bd feat(handlers): Add RequireLogin middleware
Adds a middleware that automatically redirects users to the login page
if they don't have an active session (i.e. 'author' set).
2018-04-09 09:11:23 +02:00
Vincent Ambo
9eb8501fae feat(handlers): Use cookie session backend to store author info 2018-04-08 22:56:29 +02:00
Vincent Ambo
a63bc782b0 feat(handler): Implement OIDC login & callback handlers 2018-04-08 22:37:36 +02:00
Vincent Ambo
cf636077e6 feat(handlers): Add reply_thread handler for posts 2018-04-08 20:20:05 +02:00
Vincent Ambo
094b1e0722 feat(handlers): Add thread submission handler 2018-04-08 20:01:32 +02:00
Vincent Ambo
c8cee945c5 refactor(main): Move handlers into separate handler module 2018-04-08 19:21:41 +02:00