kopia lustrzana https://github.com/jointakahe/takahe
Merge branch 'main' into feat/pinned-posts
commit
3eb8cd22eb
|
@ -81,15 +81,31 @@ class TimelineService:
|
|||
.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 (
|
||||
PostService.queryset()
|
||||
.filter(author=identity)
|
||||
.unlisted(include_replies=True)
|
||||
.order_by("-id")
|
||||
self.event_queryset()
|
||||
.filter(
|
||||
filter,
|
||||
identity=identity,
|
||||
)
|
||||
.order_by("-created")
|
||||
)
|
||||
|
||||
def identity_pinned(self) -> models.QuerySet[Post]:
|
||||
|
|
|
@ -280,7 +280,7 @@ class Notification(Schema):
|
|||
class Tag(Schema):
|
||||
name: str
|
||||
url: str
|
||||
history: dict
|
||||
history: list
|
||||
following: bool | None
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -39,7 +39,7 @@ def search(
|
|||
for i in search_result["identities"]
|
||||
]
|
||||
if type is None or type == "hashtag":
|
||||
result["hashtag"] = [
|
||||
result["hashtags"] = [
|
||||
schemas.Tag.from_hashtag(h) for h in search_result["hashtags"]
|
||||
]
|
||||
if type is None or type == "statuses":
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
{% load activity_tags %}
|
||||
|
||||
{% block title %}{{ identity }}{% endblock %}
|
||||
|
||||
|
@ -96,8 +97,20 @@
|
|||
</div>
|
||||
{% include "activities/_post.html" %}
|
||||
{% endfor %}
|
||||
{% for post in page_obj %}
|
||||
{% include "activities/_post.html" %}
|
||||
{% for event in page_obj %}
|
||||
{% 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 %}
|
||||
<span class="empty">
|
||||
{% if identity.local %}
|
||||
|
|
|
@ -165,7 +165,12 @@ class IdentityFeed(Feed):
|
|||
return {"image": image}
|
||||
|
||||
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):
|
||||
return item.safe_content_remote()
|
||||
|
|
Ładowanie…
Reference in New Issue