避免“添加好友”的最佳实践虐待

发布于 2024-09-02 10:38:27 字数 492 浏览 2 评论 0原文

我有一个具有基本社交功能的 PHP / CodeIgniter 网站,其中显然包含“添加朋友”链接。单击此链接时,会在后台进行 AJAX 调用,从而将与该链接关联的用户添加为已登录用户的好友。此外,该链接会转换为“删除朋友”,其作用与罐头上所说的一样,就像“添加朋友”一样。

单击“添加朋友”后,添加为朋友的用户会收到电子邮件通知,告知他或她已被添加为朋友。这就是我的问题所在:如果登录用户不断单击添加/删除/添加/删除/等,我想避免向用户发送垃圾邮件这些通知电子邮件。

我的想法是设置某种添加历史记录表它记录了 2 个用户 ID 和一个时间戳。如果(当前时间 - 时间戳)大于设定值,我只会发送电子邮件。每次用户重新添加朋友时,我都会将时间戳更新为当前时间,以便“扩展”垃圾邮件控制的有效性。通过这种方法,我还可以控制用户是否想在给定的时间间隔内添加太多朋友。

该表会不时地被清除,以查找时间戳比给定值更早的记录。

这是我的想法,如果您有其他想法或使用不同的方法,请分享。

感谢您的阅读。

I have a PHP / CodeIgniter site with basic social functionality which obviously includes an "Add friend" link. When clicking this link an AJAX call is made in the background, which adds the user associated with the link as a friend of the logged in user. Also the link transforms into "Remove friend" which does what it says on the tin, just the way "Add friend" does.

When "Add friend" is clicked the user who's added as a friend is notified via e-mail that he or she has been added as a friend. This is where my question comes in: I want to avoid spamming the user with these notification e-mails if the logged in user keeps clicking add / remove / add / remove / etc.

My idea is to set up sort of an add history table which records the 2 user ids and a timestamp. And I'd only send out an e-mail if the (current time - timestamp) is bigger than a set value. And every time a user would re-add a friend I'd update the timestamp to the current time so it "extends" the valability of the spam control. With this method I could also control if a user wants to add too many friends in a given interval.

This table would be cleared from time to time for records with the timestamp farther away in the past than a given value.

This is my idea, if you have other ones or used different methods please share.

Thanks for reading.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

空气里的味道 2024-09-09 10:38:27

对我来说听起来是最好的选择。为了简化,如果记录存在的话我可能会发送电子邮件(而不是根据时间戳进行检查),然后设置一个 cron 来系统地处理旧记录 - 这样你就可以有更多的控制权超过时间限制(您的“限制”逻辑将进入 cron 脚本,因此您可以根据比时间戳更复杂的参数来决定是否删除记录 - 例如,如果特定用户有,则不要删除记录大量的活动,以阻止垃圾邮件发送者。您甚至可以针对特定用户或帐户类型,但我确实有过度的倾向...)

据我所知,Facebook 有“添加朋友”功能。 -> “待处理的请求”。从那里开始,在对方回复之前你不能做任何事情,所以你根本不能发送垃圾邮件请求,但我想这取决于你是否需要另一端的确认,并且取决于你自己的品味。

Sounds to me like the best option. To simplify, I'd probably send out the email if the record exists at all (instead of checking based on a timestamp), and then set up a cron to systematically dispose of the old ones - that way you can have a bit more control over the time limits (your "limiting" logic would go into the cron script, so you could decide whether to remove the records or not based on more complicated parameters than just a timestamp - e.g. don't remove the record if a particular user has a large amount of activity, to stop spammers. You could even be user or account-type specific, but I do have a tendency to go overboard...)

As far as I can tell, Facebook has "Add Friend" -> "Pending request". From there, you can't do anything until the other person responds, so you can't spam requests at all, but I guess that depends if you require confirmation on the other end, and it's subject to your own tastes.

生死何惧 2024-09-09 10:38:27

我认为最好将添加好友选项设为双向。因此,第一个用户邀请其他人成为他/她的朋友(将“添加朋友”链接更改为“邀请”之类的内容,这不是链接)。然后另一个人必须接受第一个用户作为朋友。之后,两个用户都可以删除好友关系,但之后,如果其中一个用户决定再次成为好友,他可以再次邀请另一个用户。当然,您可以为此邀请设置某种有效期,或一些限制(即一个人只能邀请其他人三次)...

这样您就不会向用户发送垃圾邮件(至少因为某些点击 )链接太频繁),而且人们对与谁成为朋友有更多的控制权。当然,这种方法确实有一些缺点(例如如何处理被忽略的邀请等)。

我认为您在问题中描述的方式也是对抗垃圾邮件的好方法,您还可以做一些事情,例如限制某人可以将其他用户添加为朋友的次数(即每天一次,每周三次,我不知道)不知道,类似的东西)..

I think it's best that you make the add friend option a two way thing. So the first user invites someone else to be his/her friend (changing the "add friend"-link into something like "invited" which is not a link). The other person then has to accept the first user as a friend. After that both of the users can delete the friendship, but after that, if one of them decides to be friends again he can invite the other one again. You can put some sort of validity-period to this invitation of course, or some limitations (ie. one can only invite someone else three times)...

This way you won't be spamming users with emails (at least because some clicks a link too often), and people have a bit more control over who they are friends with. Of course, this approach does have some downsides (like what to do with ignored invitations, etc..).

The way you describe in your question I think is also a good way of fighting spam, you can also do something like limiting the number of times someone can add another user as a friend (ie once per day, three times a week, I don't know, something like that)..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文