SteemJs - How to programmatically verify that I correctly followed a user and resteemed his post

in stem •  3 months ago  (edited)



This is how I currently implemented this feature:

const steem = require('steem');
const { Client } = require('dsteem');
const client = new Client('https://api.steemit.com');

const myBotName = whoami();

// @returns whether my bot has already resteemed the target post
const resteemedPost = ({ history = 100, permlink = '' }) => new Promise((resolve) => {
  const query = {
    tag: myBotName, // This tag is used to filter the results by a specific post tag
    // TODO: figure out how to deal with more posts as the MAX here is 100 !
    limit: history, // This limit allows us to limit the overall results returned to N
  };
  // Gotta use the following because steem.api.getRebloggedBy stopped working 
  // and resteemed_by in client.database.getDiscussions is always [].
  client.database
    .getDiscussions('blog', query)
    .then((result) => {
      const isInMyHistory = result.filter(post => post.permlink === permlink)[0];
      resolve(!!isInMyHistory);
    });
});

// @returns whether my bot is already following the target user
const followedUser = targetUser => new Promise((resolve) => {
  const options = [
    targetUser,
    '',
    'blog',
    // TODO: figure out how to deal with more followers as the MAX here is 1000 !
    1000,
  ];
  client.call('follow_api', 'get_followers', options)
    .then((result) => {
      const hasMeAsFollower = result.filter(({ follower }) => follower === myBotName)[0];
      resolve(!!hasMeAsFollower);
    });
});



The problem is that both functions have limitations:

  • The one used to verify whether the post has correctly been resteemed can only check the last 100 posts on my blog.

  • The one used to verify whether my account correctly followed the user can only fetch 1000 users that are following the target user.

How can I resolve this?

Thanks, much appreciated =]

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Congratulations @gaottantacinque! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You received more than 50 as payout for your posts. Your next target is to reach a total payout of 100

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Vote for @Steemitboard as a witness to get one more award and increased upvotes!