Reputation: 147
I've had a look around on here, but I can't seem to find the answer I am looking for.
I'm creating a type of social network, that has similar functionality to the Twitter following system, whereby a user1 can follow user2.
Now the issue I've run into, is that if I have a user, who's an unsavoury character, that thinks it's fun to keep pressing the follow/unfollow button on a user's profile, resulting in the end user receiving a flood of emails saying "this user is following you". Obviously I don't want this to happen. The only thought I had was that when user1 follows user2, the row gets inserted into a database. Then if user1 wants to unfollow user2, the row won't be deleted from the table, but just have a field 'unfollowed' which will be set to true? Then if in the future user1 wants to follow user2 again, I will do a check to see if 'unfollowed' is set to true, which won't send another email or maybe send an e-mail if it's over a certain time frame.
Apologies if I've just confused the hell out of you all. But does anyone have any smarter ideas for this issue?
Upvotes: 1
Views: 90
Reputation: 332
You answered your own question. Set a flag to indicate if this user1 has already followed/unfollowed user2. If flag is true, don't send an email, if flag is false, send an email.
Upvotes: 0
Reputation: 1909
I'd recommend something similar to the solution you've proposed (tracking all follows rather than deleting), but also changing the wording so that your users can opt to receive emails when "new users start to follow them."
Upvotes: 1
Reputation: 31654
Simplest answer is to disable the button when it's clicked. Would prevent the user from clicking it again.
Upvotes: 2