lib/cosgrove/utils.rb in cosgrove-0.0.1rc9 vs lib/cosgrove/utils.rb in cosgrove-0.0.1rc10
- old
+ new
@@ -149,7 +149,32 @@
return [author_name, post.permlink]
end
[]
end
+
+ def find_comment(slug)
+ author_name, permlink = parse_slug slug
+ comment = nil
+
+ begin
+ comment = SteemData::Post.where(author: author_name, permlink: permlink).first
+ rescue => e
+ ap e
+ end
+
+ if comment.nil?
+ begin
+ # Fall back to RPC
+ response = api(:steem).get_content(author_name, permlink)
+ unless response.result.author.empty?
+ comment = response.result
+ end
+ rescue => e
+ ap e
+ end
+ end
+
+ comment
+ end
end
end