Fix field name for hashtag following/followed boolean

pull/554/head
Christof Dorner 2023-04-06 22:48:54 +02:00
rodzic 24db2f2b9b
commit 860e03b0f8
3 zmienionych plików z 12 dodań i 12 usunięć

Wyświetl plik

@ -168,14 +168,14 @@ class Hashtag(StatorModel):
results[date(year, month, day)] = val
return dict(sorted(results.items(), reverse=True)[:num])
def to_mastodon_json(self, followed: bool | None = None):
def to_mastodon_json(self, following: bool | None = None):
value = {
"name": self.hashtag,
"url": self.urls.view.full(), # type: ignore
"history": [],
}
if followed is not None:
value["followed"] = followed
if following is not None:
value["following"] = following
return value

Wyświetl plik

@ -276,15 +276,15 @@ class Tag(Schema):
name: str
url: str
history: dict
followed: bool | None
following: bool | None
@classmethod
def from_hashtag(
cls,
hashtag: activities_models.Hashtag,
followed: bool | None = None,
following: bool | None = None,
) -> "Tag":
return cls(**hashtag.to_mastodon_json(followed=followed))
return cls(**hashtag.to_mastodon_json(following=following))
class FollowedTag(Tag):
@ -295,7 +295,7 @@ class FollowedTag(Tag):
cls,
follow: users_models.HashtagFollow,
) -> "FollowedTag":
return cls(id=follow.id, **follow.hashtag.to_mastodon_json(followed=True))
return cls(id=follow.id, **follow.hashtag.to_mastodon_json(following=True))
@classmethod
def map_from_follows(

Wyświetl plik

@ -15,13 +15,13 @@ def hashtag(request: HttpRequest, hashtag: str) -> schemas.Tag:
Hashtag,
pk=hashtag.lower(),
)
followed = None
following = None
if request.identity:
followed = tag.followers.filter(identity=request.identity).exists()
following = tag.followers.filter(identity=request.identity).exists()
return schemas.Tag.from_hashtag(
tag,
followed=followed,
following=following,
)
@ -63,7 +63,7 @@ def follow(
request.identity.hashtag_follows.get_or_create(hashtag=hashtag)
return schemas.Tag.from_hashtag(
hashtag,
followed=True,
following=True,
)
@ -80,5 +80,5 @@ def unfollow(
request.identity.hashtag_follows.filter(hashtag=hashtag).delete()
return schemas.Tag.from_hashtag(
hashtag,
followed=False,
following=False,
)