Merge pull request #13 from Linus2punkt0/add-feed-post-handling

added handling of posts referencing feeds
This commit is contained in:
Linus Svensson
2023-08-27 17:34:24 +02:00
committed by GitHub

View File

@@ -61,10 +61,17 @@ def getPosts():
# both tweets that are not replies, and posts that are part of a thread.
replyToUser = bsky_handle
replyTo = ""
# Checking if post is a quote tweet
# Checking if post is a quote post. Posts with references to feeds look like quote posts but aren't, and so will fail on missing attribute.
# Since quote posts can give values in two different ways it's a bit of a hassle to double check if it is an actual quote post,
# so instead I just try to run the function and if it fails I'll set postType as an empty string to signify that this post should
# not be crossposted. If there is some reason you would want to crosspost a post referencing a bluesky-feed that I'm not
# seeing, I might update this in the future.
if feed_view.post.embed and hasattr(feed_view.post.embed, "record"):
replyToUser, replyTo = getQuotePost(feed_view.post.embed.record)
postType = "quote"
try:
replyToUser, replyTo = getQuotePost(feed_view.post.embed.record)
postType = "quote"
except:
postType = ""
# Checking if post is regular reply
elif feed_view.post.record.reply:
replyToUser = getReplyToUser(feed_view.post.record.reply)
@@ -73,7 +80,7 @@ def getPosts():
if not replyToUser:
continue
# Checking if post is by user (i.e. not a repost), withing the last 12 hours and either not a reply or a reply in a thread.
if feed_view.post.author.handle == bsky_handle and timestamp > datetime.now() - timedelta(hours = 12) and replyToUser == bsky_handle:
if postType and feed_view.post.author.handle == bsky_handle and timestamp > datetime.now() - timedelta(hours = 12) and replyToUser == bsky_handle:
# Fetching images if there are any in the post
imageData = ""
images = []