just a guess from looking at the code, but perhaps it may be because you are using topic_id instead of post_id? because first post is the topic in Discourse, more or less?
just a guess from looking at the code, but perhaps it may be because you are using topic_id instead of post_id? because first post is the topic in Discourse, more or less?