Skip to content

Instantly share code, notes, and snippets.

@vardanator
Created February 18, 2018 19:35
Show Gist options
  • Select an option

  • Save vardanator/913b8c0b663b4b9a3872e96a8f9a79cf to your computer and use it in GitHub Desktop.

Select an option

Save vardanator/913b8c0b663b4b9a3872e96a8f9a79cf to your computer and use it in GitHub Desktop.
// 'author' represents the User object, at this point we are interested only in author.id
//
// 'tw' is a Tweet object, at this point we are interested only in 'tw.id'
void DeliverATweet(User* author, Tweet* tw)
{
// we assume that 'tw' object is already stored in a database
// 1. Get the list of user's followers (author of the tweet)
vector<User*> user_followers = GetUserFollowers(author->id);
// 2. insert tweet into each timeline
for (auto follower : user_followers) {
InsertTweetIntoUserTimeline(follower->id, tw->id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment