Version of Python you are running
# python --version
Python 3.6.4
Version of steem-python you are running
# steempy --version
steempy 1.0.0
Expected Behavior
steem.blog.take()
should return top-level posts for Blog(comments_only=False)
and comments for Blog(comments_only=True)
. The distinction between post and comment internally uses steem.utils.is_comment()
. This should returns False
for root posts, True
or others for comments.
Actual Behavior
steem.utils.is_comment()
returns False
if the post is a comment but the permlink doesn't start with "re-". As a result, the Blog().take()
results may be lacking comments or list comments as root posts.
Steps to reproduce
Reply to a post with a custom permlink that doesn't start with "re-".
Example:
- root post: https://steemit.com/python/@stmdev/steem-utils-is-comment-root-post
- regular reply: https://steemit.com/python/@stmdev/re-steem-utils-is-comment-root-post-20180427t113939
- reply without "re-" in permlink: https://steemit.com/python/@stmdev/lorem-ipsum-dolor-sit-amet
>>> from steem.post import Post
>>> from steem.utils import is_comment
>>> is_comment(Post("stmdev/steem-utils-is-comment-root-post"))
False
>>> is_comment(Post("stmdev/re-steem-utils-is-comment-root-post-20180427t113939"))
'stmdev'
>>> is_comment(Post("stmdev/lorem-ipsum-dolor-sit-amet"))
False
steem.utils.is_comment
is used in steem.blog.take()
and therefore possibly returns wrong results for Blog(comments_only=True)
and Blog(comments_only=False)
:
>>> from steem.blog import Blog
>>> b = Blog("stmdev", comments_only=False)
>>> b.take(5)
[<Post-stmdev/utils-iscomment-should-not-rely-on-re-in-permlink>, <Post-stmdev/lorem-ipsum-dolor-sit-amet>, <Post-stmdev/steem-utils-is-comment-root-post>, <Post-stmdev/difftest>, <Post-stmdev/clicking-tag-in-body-exceeding-1169-chars-triggers-a-502-bad-gateway>]
The second result in this example is actually a comment.
Stack Trace
none.
Possible fixes:
diff --git a/steem/utils.py b/steem/utils.py
index 856ebb8..8842fef 100755
--- a/steem/utils.py
+++ b/steem/utils.py
@@ -186,7 +186,7 @@ def is_comment(item):
The item can be a Post object or just a raw comment object from the
blockchain.
"""
- return item['permlink'][:3] == "re-" and item['parent_author']
+ return item['parent_author'] != ""
def time_elapsed(posting_time):
This would also avoid the inconsistency of returning False
for root posts but the parent author as string for comments.
Alternatively: remove steem.utils.is_comment()
and use steem.post.is_comment()
instead?
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you, I can confirm this is a potential problem. I thought all comments permlink start with
re
so the question is how do you get the comment withoutre
in the first place?Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
You can set any permlink for replies as long as
parent_author
andparent_perlink
point to the according parent. See the example comment for code how to achieve that with steem-python.Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Ok, i see, only programatically. luckily the comments are following re- patterns if you are using busy.org or steemit.com
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey @justyy, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey @stmdev! Thank you for the great work you've done!
We're already looking forward to your next contribution!
Fully Decentralized Rewards
We hope you will take the time to share your expertise and knowledge by rating contributions made by others on Utopian.io to help us reward the best contributions together.
Utopian Witness!
Vote for Utopian Witness! We are made of developers, system administrators, entrepreneurs, artists, content creators, thinkers. We embrace every nationality, mindset and belief.
Want to chat? Join us on Discord https://discord.me/utopian-io
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit