Skip to content

Commit

Permalink
fix: from_feed didn't set unikey, curkey, islike from FeedData
Browse files Browse the repository at this point in the history
  • Loading branch information
JamzumSum committed Mar 23, 2023
1 parent 8f788e0 commit d772f97
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aioqzone-feed"
version = "0.13.2.dev3"
version = "0.13.2.dev4"
description = "aioqzone plugin providing higher level api for processing feed."
authors = ["aioqzone <[email protected]>"]
license = "AGPL-3.0"
Expand Down
20 changes: 11 additions & 9 deletions src/aioqzone_feed/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class BaseFeed:
.. versionadded:: 0.9.2a1
"""
islike: bool = False

def __hash__(self) -> int:
return hash((self.uin, self.abstime))
Expand Down Expand Up @@ -180,9 +181,19 @@ def _(cls, obj: FeedData, **kwds):
abstime=obj.abstime,
uin=obj.userinfo.uin,
nickname=obj.userinfo.nickname,
unikey=obj.common.orgkey,
curkey=obj.common.curkey,
islike=obj.like.isliked,
**kwds,
)

def set_frominfo(self, info: HtmlInfo):
self.curkey = info.curkey
self.unikey = info.unikey
self.islike = bool(info.islike)
self.topicId = info.topicid
self.nickname = self.nickname or info.nickname


@dataclass
class BaseDetail:
Expand Down Expand Up @@ -273,18 +284,9 @@ class FeedContent(BaseDetail, BaseFeed):
"""FeedContent is feed with contents. This might be the common structure to
represent a feed as what it's known."""

islike: int = 0

def __hash__(self) -> int:
media_hash = hash(tuple(i.raw for i in self.media)) if self.media else 0
return hash((self.uin, self.abstime, self.forward, media_hash))

def set_frominfo(self, info: HtmlInfo):
self.curkey = info.curkey
self.unikey = info.unikey
self.islike = info.islike
self.topicId = info.topicid
self.nickname = self.nickname or info.nickname

def __repr__(self) -> str:
return super().__repr__() + f'(content="{self.entities}",#media={len(self.media or "0")})'

0 comments on commit d772f97

Please sign in to comment.