[bluesky:likes] fix infinite loop (#7194 #7287)

at the end of 'feed.getActorLikes'
This commit is contained in:
Mike Fährmann
2025-04-16 08:58:15 +02:00
parent 397a795a17
commit 7d1321cbda
2 changed files with 14 additions and 2 deletions

View File

@@ -387,7 +387,7 @@ class BlueskyAPI():
"actor": self._did_from_actor(actor),
"limit": "100",
}
return self._pagination(endpoint, params)
return self._pagination(endpoint, params, check_empty=True)
def get_author_feed(self, actor, filter="posts_and_author_threads"):
endpoint = "app.bsky.feed.getAuthorFeed"
@@ -577,9 +577,13 @@ class BlueskyAPI():
self.extractor.log.debug("Server response: %s", response.text)
raise exception.StopExtraction(msg)
def _pagination(self, endpoint, params, key="feed", root=None):
def _pagination(self, endpoint, params,
key="feed", root=None, check_empty=False):
while True:
data = self._call(endpoint, params, root)
if check_empty and not data[key]:
return
yield from data[key]
cursor = data.get("cursor")

View File

@@ -128,6 +128,14 @@ __tests__ = (
"#urls" : "https://conocybe.us-west.host.bsky.network/xrpc/com.atproto.sync.getBlob?did=did:plc:cslxjqkeexku6elp5xowxkq7&cid=bafkreih2dn2xeyoayabgvpyutv5ldubcdxzfqipijasfzxyeez7fff5ymi",
},
{
"#url" : "https://bsky.app/profile/mikf.bsky.social/likes",
"#class" : bluesky.BlueskyLikesExtractor,
"#options" : {"endpoint": "getActorLikes"},
"#auth" : True,
"#urls" : "https://conocybe.us-west.host.bsky.network/xrpc/com.atproto.sync.getBlob?did=did:plc:cslxjqkeexku6elp5xowxkq7&cid=bafkreih2dn2xeyoayabgvpyutv5ldubcdxzfqipijasfzxyeez7fff5ymi",
},
{
"#url" : "https://bsky.app/profile/mikf.bsky.social/likes",
"#class" : bluesky.BlueskyLikesExtractor,