mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-22 07:10:59 +00:00
Show posts and boosts on an identity's profile view (#574)
This commit is contained in:
parent
b3b58df2b1
commit
744c2825d9
3 changed files with 43 additions and 9 deletions
|
@ -81,15 +81,31 @@ class TimelineService:
|
||||||
.order_by("-created")
|
.order_by("-created")
|
||||||
)
|
)
|
||||||
|
|
||||||
def identity_public(self, identity: Identity):
|
def identity_public(self, identity: Identity, include_boosts: bool = True):
|
||||||
"""
|
"""
|
||||||
Returns all publically visible posts for an identity
|
Returns timeline events with all of an identity's publicly visible posts
|
||||||
|
and their boosts
|
||||||
"""
|
"""
|
||||||
|
filter = models.Q(
|
||||||
|
type=TimelineEvent.Types.post,
|
||||||
|
subject_post__author=identity,
|
||||||
|
subject_post__visibility__in=[
|
||||||
|
Post.Visibilities.public,
|
||||||
|
Post.Visibilities.local_only,
|
||||||
|
Post.Visibilities.unlisted,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
if include_boosts:
|
||||||
|
filter = filter | models.Q(
|
||||||
|
type=TimelineEvent.Types.boost, subject_identity=identity
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
PostService.queryset()
|
self.event_queryset()
|
||||||
.filter(author=identity)
|
.filter(
|
||||||
.unlisted(include_replies=True)
|
filter,
|
||||||
.order_by("-id")
|
identity=identity,
|
||||||
|
)
|
||||||
|
.order_by("-created")
|
||||||
)
|
)
|
||||||
|
|
||||||
def likes(self) -> models.QuerySet[Post]:
|
def likes(self) -> models.QuerySet[Post]:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
{% load activity_tags %}
|
||||||
|
|
||||||
{% block title %}{{ identity }}{% endblock %}
|
{% block title %}{{ identity }}{% endblock %}
|
||||||
|
|
||||||
|
@ -90,8 +91,20 @@
|
||||||
{% block subcontent %}
|
{% block subcontent %}
|
||||||
|
|
||||||
<div class="page-content">
|
<div class="page-content">
|
||||||
{% for post in page_obj %}
|
{% for event in page_obj %}
|
||||||
{% include "activities/_post.html" %}
|
{% if event.type == "post" %}
|
||||||
|
{% include "activities/_post.html" with post=event.subject_post %}
|
||||||
|
{% elif event.type == "boost" %}
|
||||||
|
<div class="boost-banner">
|
||||||
|
<a href="{{ event.subject_identity.urls.view }}">
|
||||||
|
{{ event.subject_identity.html_name_or_handle }}
|
||||||
|
</a> boosted
|
||||||
|
<time>
|
||||||
|
{{ event.subject_post_interaction.published | timedeltashort }} ago
|
||||||
|
</time>
|
||||||
|
</div>
|
||||||
|
{% include "activities/_post.html" with post=event.subject_post %}
|
||||||
|
{% endif %}
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<span class="empty">
|
<span class="empty">
|
||||||
{% if identity.local %}
|
{% if identity.local %}
|
||||||
|
|
|
@ -164,7 +164,12 @@ class IdentityFeed(Feed):
|
||||||
return {"image": image}
|
return {"image": image}
|
||||||
|
|
||||||
def items(self, identity: Identity):
|
def items(self, identity: Identity):
|
||||||
return TimelineService(None).identity_public(identity)[:20]
|
return [
|
||||||
|
e.subject_post
|
||||||
|
for e in TimelineService(None).identity_public(
|
||||||
|
identity, include_boosts=False
|
||||||
|
)[:20]
|
||||||
|
]
|
||||||
|
|
||||||
def item_description(self, item: Post):
|
def item_description(self, item: Post):
|
||||||
return item.safe_content_remote()
|
return item.safe_content_remote()
|
||||||
|
|
Loading…
Reference in a new issue