fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-11-23 07:57 am

[dw-free] New community left out of default reading filter of creator

[commit: http://hg.dwscoalition.org/dw-free/rev/2a4c15c49485]

http://bugs.dwscoalition.org/show_bug.cgi?id=4022

Automatically add to default view when we're doing a join action that
assumes watch (membership requests, comm creation, etc)

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/LJ/Community.pm
  • t/content-filters.t
--------------------------------------------------------------------------------
diff -r 1562746f926c -r 2a4c15c49485 cgi-bin/LJ/Community.pm
--- a/cgi-bin/LJ/Community.pm	Wed Nov 23 13:30:37 2011 +0800
+++ b/cgi-bin/LJ/Community.pm	Wed Nov 23 15:54:38 2011 +0800
@@ -120,9 +120,6 @@
     $joined = $u->join_community( $cu, 1, 0, moderated_add => 1 ) or return undef
         if $args->{member};
 
-    # we watch the community; now automatically add to default view, as most useful behavior
-    $u->add_to_default_filters( $cu ) if $joined;
-
     # now grant necessary abilities
     my %edgelist = (
         post => 'P',
@@ -328,6 +325,11 @@
     # watch the comm
     $u->add_edge( $cu, watch => {} );
 
+    # also automatically add to default view, as most useful behavior
+    # this only applies if we are doing a quick / easy join, so it won't affect
+    # things if the user is joining + watching communities the long way
+    $u->add_to_default_filters( $cu );
+
     # done
     return 1;
 }
diff -r 1562746f926c -r 2a4c15c49485 t/content-filters.t
--- a/t/content-filters.t	Wed Nov 23 13:30:37 2011 +0800
+++ b/t/content-filters.t	Wed Nov 23 15:54:38 2011 +0800
@@ -8,7 +8,7 @@
 
 use LJ::Community;
 
-plan tests => 14;
+plan tests => 15;
 
 my $u1 = temp_user();
 my $u2 = temp_user();
@@ -83,7 +83,6 @@
     my $invite_u = temp_user();
 
     LJ::set_rel( $comm_u, $admin_u, 'A' );
-
     LJ::start_request();
 
     $invite_u->create_content_filter( name => 'default' );
@@ -92,10 +91,29 @@
     $filter = $invite_u->content_filters( name => 'default' );
 
     $invite_u->send_comm_invite( $comm_u, $admin_u, [qw ( member )] );
-    ok( ! $filter->contains_userid( $comm_u->userid ) );
+    ok( ! $filter->contains_userid( $comm_u->userid ), "not in filter yet because invite hasen't been accepted" );
 
     $invite_u->accept_comm_invite( $comm_u );
-    ok( $filter->contains_userid( $comm_u->userid ) );
+    ok( $filter->contains_userid( $comm_u->userid ), "accepted invite, now in filter" );
 }
 
 ################################################################################
+note( "in default filter after creating a community");
+{
+    my $admin_u = temp_user();
+    LJ::set_remote( $admin_u );
+
+    $admin_u->create_content_filter( name => 'default' );
+
+    my $filter;
+    $filter = $admin_u->content_filters( name => 'default' );
+
+    my $comm_u = LJ::User->create_community(
+        user        => "t_". LJ::rand_chars( 15 - 2 ),
+        membership  => 'open',
+        postlevel   => 'members',
+    );
+    ok( $filter->contains_userid( $comm_u->userid ), "newly created community should go into the admin's default filters" );
+}
+
+################################################################################
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
No Subject Icon Selected
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org