holyandrew (holyandrew) wrote in changelog,
holyandrew
holyandrew
changelog

[ljcom] r12362: LJSUP-13122: Limit number of times a use...

Committer: akanashin
LJSUP-13122: Limit number of times a user can receive the same promo in notifications
U   trunk/cgi-bin/LJ/Hooks/ESN.pm
Modified: trunk/cgi-bin/LJ/Hooks/ESN.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/ESN.pm	2012-07-27 07:06:37 UTC (rev 12361)
+++ trunk/cgi-bin/LJ/Hooks/ESN.pm	2012-07-27 12:05:03 UTC (rev 12362)
@@ -47,8 +47,11 @@
     }
 
     if( $ev->show_promo && !$u->in_class('paid')) {
-        $html_body  .= LJ::run_hook('add_notificationpromo', $u, 'html');
-        $plain_body .= LJ::run_hook('add_notificationpromo', $u, 'plaintext');
+        if ( $u->{opt_htmlemail} eq 'Y' ) {
+            $html_body  .= LJ::run_hook('add_notificationpromo', $u, 'html');
+        } else {
+            $plain_body .= LJ::run_hook('add_notificationpromo', $u, 'plaintext');
+        }
     }
 
     if( $ev->need_standard_footer ) {
@@ -104,6 +107,16 @@
 
     $params = $object->get_template_params();
 
+    my $last_url = LJ::MemCache::get($u->user."_notification_last");
+    if ($last_url eq $params->{post_url}) {
+        LJ::MemCache::incr($u->user."_notification_count");
+    } else {
+        LJ::MemCache::set($u->user."_notification_count", 1, 60*60*24);
+        LJ::MemCache::set($u->user."_notification_last", $params->{post_url}, 60*60*24);
+    }
+
+    return if LJ::MemCache::get($u->user."_notification_count") > 5;
+
     $params->{country_style_ua} = $active_region eq 'ua';
     $params->{imgprefix} = $LJ::IMGPREFIX;
     $params->{ljuser} = [LJ::ljuser($promo->promoter, {raw => 1, inline_css => 1})]; 

Tags: akanashin, holyandrew, ljcom, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments