BotKit by Fedify :botkit:'s avatar
BotKit by Fedify :botkit:

@[email protected]

We are designing an API to support manual accept/reject of follow requests in . Which of the below two approaches seems better?

Returning true or false in the onFollow event

bot.onFollow = async (session, follower) => {
  // Accept follows requests from non-bot accounts:
  return follower instanceof Person;
};

Accepting a followRequest object as the third parameter in the onFollow event and calling the accept() or reject() method

bot.onFollow = async (session, follower, followRequest) => {
  // Accept follows requests from non-bot accounts:
  if (follower instanceof Person) await followRequest.accept();
  else await followRequest.reject();
};
OptionVoters
Returning true or false in the onFollow event5 (63%)
Accepting a followRequest object as the third parameter in the onFollow event3 (38%)
Jorijn Schrijvershof's avatar
Jorijn Schrijvershof

@[email protected] · Reply to BotKit by Fedify :botkit:'s post

@botkit

Option A: keeping it simple :)

Chris​‌​‬ Hayes‌​​​'s avatar
Chris​‌​‬ Hayes‌​​​

@[email protected] · Reply to BotKit by Fedify :botkit:'s post

@botkit I like option B because in my mind a follow accept/reject is an operation that can fail and something you would want to handle. Also, if these are events that can be queued, a follow Request object feels convenient to work with here. Lastly, having used Slack's Bolt framework to build Slack bots, option B feels more the type of thing I would expect.