Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[ljcom] r8138: LJSV-902 (ESN refactoring, part 1 // Def...

Committer: ailyin
LJSV-902 (ESN refactoring, part 1 // Default settings for new users: Inbox column is not checked at all):

- fetch ntypeids earlier
- fix code working with references, whoops

U   trunk/cgi-bin/LJ/Hooks/CreatePage.pm
Modified: trunk/cgi-bin/LJ/Hooks/CreatePage.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/CreatePage.pm	2010-01-26 08:47:10 UTC (rev 8137)
+++ trunk/cgi-bin/LJ/Hooks/CreatePage.pm	2010-01-26 09:50:00 UTC (rev 8138)
@@ -235,6 +235,9 @@
         my $set = LJ::Subscription::GroupSet->fetch_for_user($u);
         my $newset = $set->clone;
 
+        my @ntypeids = map { LJ::NotificationMethod->method_to_ntypeid($_) }
+            qw(Inbox Email);
+
         foreach my $subcode (@subs) {
             my $journalid = 0;
 
@@ -243,7 +246,7 @@
                 $subcode =~ s/\-u$//;
             }
 
-            my $sub = bless({
+            my %sub = (
                 'userid' => $u->id,
                 'journalid' => $journalid,
                 'etypeid' => LJ::Event->event_to_etypeid($subcode),
@@ -254,13 +257,11 @@
                 'createtime' => time,
                 'expiretime' => 0,
                 'flags' => 0,
-            }, 'LJ::Subscription');
+            );
 
-            foreach my $ntype (qw(Inbox Email)) {
-                my $ntypeid = LJ::NotificationMethod->method_to_ntypeid($ntype);
-                $sub->{'ntypeid'} = $ntypeid;
-
-                $newset->insert_sub($sub);
+            foreach my $ntypeid (@ntypeids) {
+                $sub{'ntypeid'} = $ntypeid;
+                $newset->insert_sub(bless({%sub}, 'LJ::Subscription'));
             }
         }
 

Tags: andy, 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