Add the self-view timeline event on post
Makes it show up for you immediately
This commit is contained in:
parent
7b867b229d
commit
e52c7df498
|
@ -50,6 +50,7 @@ class PostStates(StateGraph):
|
||||||
subject_post=post,
|
subject_post=post,
|
||||||
)
|
)
|
||||||
# And one for themselves if they're local
|
# And one for themselves if they're local
|
||||||
|
# (most views will do this at time of post, but it's idempotent)
|
||||||
if post.author.local:
|
if post.author.local:
|
||||||
await FanOut.objects.acreate(
|
await FanOut.objects.acreate(
|
||||||
identity_id=post.author_id,
|
identity_id=post.author_id,
|
||||||
|
|
|
@ -3,7 +3,12 @@ from django.shortcuts import get_object_or_404, redirect, render
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.generic import FormView, TemplateView, View
|
from django.views.generic import FormView, TemplateView, View
|
||||||
|
|
||||||
from activities.models import Post, PostInteraction, PostInteractionStates
|
from activities.models import (
|
||||||
|
Post,
|
||||||
|
PostInteraction,
|
||||||
|
PostInteractionStates,
|
||||||
|
TimelineEvent,
|
||||||
|
)
|
||||||
from core.models import Config
|
from core.models import Config
|
||||||
from users.decorators import identity_required
|
from users.decorators import identity_required
|
||||||
from users.shortcuts import by_handle_or_404
|
from users.shortcuts import by_handle_or_404
|
||||||
|
@ -155,10 +160,12 @@ class Compose(FormView):
|
||||||
return form
|
return form
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
Post.create_local(
|
post = Post.create_local(
|
||||||
author=self.request.identity,
|
author=self.request.identity,
|
||||||
content=form.cleaned_data["text"],
|
content=form.cleaned_data["text"],
|
||||||
summary=form.cleaned_data.get("content_warning"),
|
summary=form.cleaned_data.get("content_warning"),
|
||||||
visibility=form.cleaned_data["visibility"],
|
visibility=form.cleaned_data["visibility"],
|
||||||
)
|
)
|
||||||
|
# Add their own timeline event for immediate visibility
|
||||||
|
TimelineEvent.add_post(self.request.identity, post)
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
|
|
Loading…
Reference in New Issue