Skip to content

Commit

Permalink
Merge pull request #9 from weber-s/retrieve_only_last_real_content
Browse files Browse the repository at this point in the history
filter post_content only for post_type = 1
  • Loading branch information
RiwsPy authored Feb 23, 2024
2 parents 6ae6ffa + 016347b commit 629e0f7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dalec_discourse/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ def _fetch_latest_topics(self, nb, channel=None, channel_object=None):
post_url = "{}/t/{}/{}/{}".format(
settings.DALEC_DISCOURSE_BASE_URL, topic["slug"], topic["id"], topic["posts_count"]
)
post_content = client.post(topic_id=topic["id"], post_id=topic["posts_count"])[
"post_stream"
]["posts"][-1]
posts = client.post(topic_id=topic["id"], post_id=topic["posts_count"])["post_stream"][
"posts"
]
# Get latest post with post_type == 1 (i.e. real content, not update)
post_content = list(filter(lambda x: x["post_type"] == 1, posts))[-1]

topic["id"] = str(topic["id"])
if not topic["last_posted_at"]:
Expand Down

0 comments on commit 629e0f7

Please sign in to comment.