gingbug / Drupal-for-The-Synaptic-Leap

Drupal 7
http://thesynapticleap.org
GNU General Public License v2.0
3 stars 0 forks source link

Notifications sending emails on unapproved comments #12

Open gingbug opened 11 years ago

gingbug commented 11 years ago

The notify module is sending notifications to users for comments before our moderator, Matt Todd, has approved them. Unfortunately these comments are often spam. Users getting spam emails is going to turn them off the site.

I'm open to a variety of options - fix this module or try a new one - to make this work properly.

CORE NOTIFICATIONS REQUIREMENTS

We don't need fancy content type / tag level subscriptions. We simply want users to be notified of all new PUBLISHED posts and PUBLISHED comments.

Ideally the email can batch up changes over a 24 hour period. Ideally users can opt out without leaving the site.

The Comment Notify module has other cool features: http://drupal.org/project/comment_notify - allowing users who haven't officially registered to subscribe. I think that might be valuable to this site. But unfortunately it doesn't notify users of new posts.

marklindsey commented 11 years ago

I have solved this issue with a few changes. I added an enhancement to the current vanilla notify module so that unpublished comments do not notify users. Instead, these unpublished comments are queued so that after they have been published, notifications will be sent out for the comment.

I tested this update script and enhancement locally on a vanilla Drupal 7 installation as well as on a TSL Dev installation. I saved a backup of the master branch before my changes (master-backup-before-patch-11may2013) as well as a backup db (tsl_2013-05-11_22-46.sql.gz) in Production directory ~/sql-backup/. All seems to be holding together.

Commits: (1) Backup of forked notify module (c59b719a) (2) Removal of forked notify module (4216ee26) (3) Addition of vanilla notify module 7.x-1.x-dev (532db123) (4) Addition of unpublished comment queue enhancement to the notify module. (ef255d7f) (5) Added case so when comments are deleted, they are also deleted from the queue (6f05393)

I removed the extra column send_last added by the old fork in the notify table via a SQL query (ALTER TABLE notify DROP COLUMN send_last).

I also created an issue for this bug fix for the notify module maintainers (http://drupal.org/node/1992788).

marklindsey commented 11 years ago

With regard to the Anonymous users who are potentially commenting, this query shows that there appears to be a pattern with some IP addresses (possible spammers?)

SELECT COUNT(1), DATE_FORMAT(FROM_UNIXTIME(s.timestamp), '%b %d %Y %h:%i:%s %p'), s.*
FROM sessions s
GROUP BY s.hostname
ORDER BY s.timestamp DESC

Anytime a user visits the site, they have a session id and Drupal adds them to the session table. The session table clears itself out pretty frequently (it clears out any session rows not updated for 1440 seconds, 24 minutes), but these IPs have visited often. Each of the following IP addresses visited the site very recently and have unique entries in the session table ranging between 5 and 12 rows: 150.70.172.205 150.70.172.200 150.70.97.42 150.70.172.102 150.70.75.28 150.70.172.108

There are several others that follow this same pattern as well, these are just some of the more recent (from visiting today). The last message for many of these IP addresses is an Access denied message.