Fix forum posts API
This commit is contained in:
parent
8b8fb1a7d4
commit
e410bd9f15
|
@ -29,26 +29,4 @@ class ForumThreadsTask(WowletTask):
|
||||||
from wowlet_backend.factory import app
|
from wowlet_backend.factory import app
|
||||||
|
|
||||||
blob = await httpget(self._http_endpoint, json=True)
|
blob = await httpget(self._http_endpoint, json=True)
|
||||||
|
return blob
|
||||||
users = {z['id']: z for z in blob["users"]}
|
|
||||||
|
|
||||||
topics = []
|
|
||||||
for topic in blob['topic_list']['topics']:
|
|
||||||
if topic.get("pinned_globally", True):
|
|
||||||
continue
|
|
||||||
|
|
||||||
try:
|
|
||||||
u = next(z for z in topic["posters"] if "original poster" in z['description'].lower())['user_id']
|
|
||||||
href = f"https://forum.wownero.com/t/{topic['slug']}"
|
|
||||||
topics.append({
|
|
||||||
"id": topic["id"],
|
|
||||||
"title": topic["title"],
|
|
||||||
"comments": topic["posts_count"] - 1,
|
|
||||||
"created_at": parse(topic["created_at"]).strftime("%Y-%m-%d %H:%M"),
|
|
||||||
"author": users[u]['username'],
|
|
||||||
"permalink": href
|
|
||||||
})
|
|
||||||
except Exception as ex:
|
|
||||||
app.logger.error(f"skipping a forum topic; {ex}")
|
|
||||||
|
|
||||||
return topics[:25]
|
|
||||||
|
|
Loading…
Reference in New Issue