Reduce potential for creepiness. (These events were meant to allow you
to track any comment/entry someone posted anywhere. Never exposed in any
interface; never enabled; get rid of them anyway).
Patch by fu.
diffs (448 lines):
diff -r f616643e7fdf -r 89fe44e3e37a cgi-bin/LJ/Event.pm
--- a/cgi-bin/LJ/Event.pm Wed Nov 10 09:49:22 2010 -0600
+++ b/cgi-bin/LJ/Event.pm Thu Nov 11 13:43:33 2010 +0800
@@ -30,14 +30,10 @@ foreach my $event (@EVENTS) {
# Guide to subclasses:
# LJ::Event::JournalNewEntry -- a journal (user/community) has a new
entry in it
# ($ju,$ditemid,undef)
-# LJ::Event::UserNewEntry -- a user posted a new entry in some journal
-# ($u,$journalid,$ditemid)
# LJ::Event::JournalNewComment -- a journal has a new comment in it
# ($ju,$jtalkid) # TODO: should probably
be ($ju,$jitemid,$jtalkid)
# LJ::Event::JournalNewComment::TopLevel -- a journal has a new top-level
comment in it
# ($ju,$jitemid)
-# LJ::Event::UserNewComment -- a user left a new comment somewhere
-# ($u,$journalid,$jtalkid)
# LJ::Event::AddedToCircle -- user $fromuserid added $u to their
circle; $actionid is 1 (trust) or 2 (watch)
# ($u,$fromuserid,$actionid)
# LJ::Event::RemovedFromCircle -- user $fromuserid removed $u to their
circle; $actionid is 1 (trust) or 2 (watch)
diff -r f616643e7fdf -r 89fe44e3e37a cgi-bin/LJ/Event/UserNewComment.pm
--- a/cgi-bin/LJ/Event/UserNewComment.pm Wed Nov 10 09:49:22 2010 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-# This code was forked from the LiveJournal project owned and operated
-# by Live Journal, Inc. The code has been modified and expanded by
-# Dreamwidth Studios, LLC. These files were originally licensed under
-# the terms of the license supplied by Live Journal, Inc, which can
-# currently be found at:
-#
-#
http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
-#
-# In accordance with the original license, this code and all its
-# modifications are provided under the GNU General Public License.
-# A copy of that license can be found in the LICENSE file included as
-# part of this distribution.
-
-package LJ::Event::UserNewComment;
-use strict;
-use Scalar::Util qw(blessed);
-use LJ::Comment;
-use Carp qw(croak);
-use base 'LJ::Event';
-
-sub new {
- my ($class, $comment) = @_;
- croak 'Not an LJ::Comment' unless blessed $comment &&
$comment->isa("LJ::Comment");
- return $class->SUPER::new($comment->poster,
- $comment->journal->{userid}, $comment->jtalkid);
-}
-
-sub is_common { 0 }
-
-# when was this comment left?
-sub eventtime_unix {
- my $self = shift;
- my $cmt = $self->comment;
- return $cmt ? $cmt->unixtime : $self->SUPER::eventtime_unix;
-}
-
-sub comment {
- my $self = shift;
- return LJ::Comment->new($self->journal, jtalkid => $self->arg1);
-}
-
-1;
diff -r f616643e7fdf -r 89fe44e3e37a cgi-bin/LJ/Event/UserNewEntry.pm
--- a/cgi-bin/LJ/Event/UserNewEntry.pm Wed Nov 10 09:49:22 2010 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-# This code was forked from the LiveJournal project owned and operated
-# by Live Journal, Inc. The code has been modified and expanded by
-# Dreamwidth Studios, LLC. These files were originally licensed under
-# the terms of the license supplied by Live Journal, Inc, which can
-# currently be found at:
-#
-#
http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
-#
-# In accordance with the original license, this code and all its
-# modifications are provided under the GNU General Public License.
-# A copy of that license can be found in the LICENSE file included as
-# part of this distribution.
-
-package LJ::Event::UserNewEntry;
-
-#
-# UserNewEntry Event: Fired when a 'poster' posts 'entry' in 'journal'
-#
-
-use strict;
-use Scalar::Util qw(blessed);
-use Carp qw(croak);
-use LJ::Entry;
-use base 'LJ::Event';
-
-############################################################################
-# constructor & property overrides
-#
-
-sub new {
- my ($class, $entry) = @_;
- croak 'Not an LJ::Entry' unless blessed $entry && $entry->isa("LJ::Entry");
- return $class->SUPER::new($entry->poster, $entry->journalid,
$entry->ditemid);
-}
-
-sub is_common { 0 }
-
-############################################################################
-# canonical accessors into the meaning of this event's arguments
-# * poster: user object who posted
-# * journal: journal u object where entry was posted
-# * entry: entry object which was posted (from journal, ditemid)
-#
-
-# user who posted the entry
-sub poster {
- my $self = shift;
- return $self->u;
-}
-
-sub posterid {
- my $self = shift;
- return $self->u->{userid};
-}
-
-# journal entry was posted in
-sub journal {
- my $self = shift;
- return LJ::load_userid($self->arg1);
-}
-
-sub journalid {
- my $self = shift;
- return $self->arg1+0;
-}
-
-# entry which was posted
-sub entry {
- my $self = shift;
- return LJ::Entry->new($self->journal, ditemid => $self->ditemid);
-}
-
-sub ditemid {
- my $self = shift;
- return $self->arg2;
-}
-
-############################################################################
-# subscription matching logic
-#
-
-sub matches_filter {
- my ($self, $subscr) = @_;
-
- # does the entry actually exist?
- return 0 unless $self->journalid && $self->ditemid; # TODO: throw error?
-
- # construct the entry so we can determine visibility
- my $entry = $self->entry;
- return 0 unless $entry && $entry->valid; # TODO: throw error?
- return 0 unless $entry->visible_to($subscr->owner);
-
- # journalid of 0 means 'all friends', so if the poster is
- # watched by the subscription owner, then they match
- return 1 if ! $subscr->journalid && $subscr->owner->watches( $self->poster
);
-
- # otherwise we have a journalid, see if it's the specific
- # journal that the subscription is watching
- return $subscr->journal->equals( $self->poster );
-}
-
-
-############################################################################
-# methods for rendering ->as_*
-#
-
-sub as_string {
- my $self = shift;
- my $entry = $self->entry;
- my $about = $entry->subject_text ? " titled '" . $entry->subject_text .
"'" : '';
- return sprintf("User '%s' made a new entry $about at: " .
$self->entry->url,
- $self->poster->{name});
-}
-
-sub as_html {
- my $self = shift;
-
- my $entry = $self->entry;
- return "(Invalid entry)" unless $entry && $entry->valid;
- my $url = $entry->url;
-
- my $ju = LJ::ljuser($self->journal);
- my $pu = LJ::ljuser($self->poster);
-
- return "User $pu has posted a new <a href=\"$url\">entry</a> in $ju.";
-}
-
-sub subscription_as_html {
- my ($class, $subscr) = @_;
-
- # journal is the 'watched journal' of the subscription
- # * 0 means the subscription is for posts by any friend
- my $journal = $subscr->journal;
-
- # non-zero journal means the subscription refers to
- # posts made by a specific user
-
- return $journal ?
- BML::ml('event.user_new_entry.user', { user =>
$journal->ljuser_display } ) : # $journaluser posts a new entry anywhere.
- BML::ml('event.user_new_entry.any'); # "Any of my friends posts a new
entry anywhere."
-}
-
-1;
diff -r f616643e7fdf -r 89fe44e3e37a cgi-bin/LJ/Talk.pm
--- a/cgi-bin/LJ/Talk.pm Wed Nov 10 09:49:22 2010 -0600
+++ b/cgi-bin/LJ/Talk.pm Thu Nov 11 13:43:33 2010 +0800
@@ -16,7 +16,6 @@ use strict;
use LJ::Constants;
use LJ::Event::JournalNewComment;
-use LJ::Event::UserNewComment;
use LJ::Comment;
use LJ::EventLogRecord::NewComment;
use LJ::OpenID;
@@ -2932,8 +2931,6 @@ sub enter_comment {
my @jobs;
push @jobs, LJ::Event::JournalNewComment->new($cmtobj)->fire_job;
- push @jobs, LJ::Event::UserNewComment->new($cmtobj)->fire_job
- if $cmtobj->poster && LJ::is_enabled('esn-userevents');
push @jobs, LJ::EventLogRecord::NewComment->new($cmtobj)->fire_job;
my $sclient = LJ::theschwartz();
@@ -3731,8 +3728,6 @@ sub edit_comment {
my @jobs;
push @jobs, LJ::Event::JournalNewComment->new($comment_obj)->fire_job;
- push @jobs, LJ::Event::UserNewComment->new($comment_obj)->fire_job
- if $comment_obj->poster && LJ::is_enabled('esn-userevents');
push @jobs,
LJ::EventLogRecord::NewComment->new($comment_obj)->fire_job;
my $sclient = LJ::theschwartz();
diff -r f616643e7fdf -r 89fe44e3e37a cgi-bin/ljdefaults.pl
--- a/cgi-bin/ljdefaults.pl Wed Nov 10 09:49:22 2010 -0600
+++ b/cgi-bin/ljdefaults.pl Thu Nov 11 13:43:33 2010 +0800
@@ -227,8 +227,6 @@ no strict "vars";
UserExpunged
UserMessageRecvd
UserMessageSent
- UserNewComment
- UserNewEntry
VgiftApproved
XPostFailure
XPostSuccess
diff -r f616643e7fdf -r 89fe44e3e37a cgi-bin/ljprotocol.pl
--- a/cgi-bin/ljprotocol.pl Wed Nov 10 09:49:22 2010 -0600
+++ b/cgi-bin/ljprotocol.pl Thu Nov 11 13:43:33 2010 +0800
@@ -20,7 +20,6 @@ use LJ::Constants;
use LJ::Constants;
use LJ::Console;
use LJ::Event::JournalNewEntry;
-use LJ::Event::UserNewEntry;
use LJ::Event::AddedToCircle;
use LJ::Entry;
use LJ::Poll;
@@ -352,8 +351,6 @@ sub getinbox
UserExpunged => 17,
UserMessageRecvd => 18,
UserMessageSent => 19,
- UserNewComment => 20,
- UserNewEntry => 21,
);
my %number_type = reverse %type_number;
@@ -1691,8 +1688,7 @@ sub postevent
# but still fire the logging events
unless ( $flags->{nonotify} ) {
push @jobs, LJ::Event::JournalNewEntry->new($entry)->fire_job;
- push @jobs, LJ::Event::UserNewEntry->new($entry)->fire_job if
LJ::is_enabled('esn-userevents') || $LJ::_T_FIRE_USERNEWENTRY;
- push @jobs, LJ::Event::OfficialPost->new($entry)->fire_job if
$uowner->is_official;
+ push @jobs, LJ::Event::OfficialPost->new($entry)->fire_job if
$uowner->is_official;
# PubSubHubbub Support
LJ::Feed::generate_hubbub_jobs( $uowner, \...@jobs ) unless
$uowner->is_syndicated;
diff -r f616643e7fdf -r 89fe44e3e37a t/esn-journalnewentry.t
--- a/t/esn-journalnewentry.t Wed Nov 10 09:49:22 2010 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,162 +0,0 @@
-# -*-perl-*-
-
-use strict;
-use Test::More;
-use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
-require 'ljprotocol.pl';
-
-use LJ::Community;
-use LJ::Event;
-use LJ::Test qw(memcache_stress temp_user temp_comm);
-use FindBin qw($Bin);
-
-plan tests => 48;
-
-# so this event firing isn't disabled:
-local $LJ::_T_FIRE_USERNEWENTRY = 1;
-
-# we want to test four major cases here, matching and not matching for
-# two types of subscriptions, all of subscr etypeid = JournalNewEntry
-#
-# jid sarg1 sarg2 meaning
-# S1: n 0 0 all new posts made by user 'n' (subject to
security)
-# S2: 0 0 0 all new posts made by friends (test security)
-# --- NOTE: S2 is currently disabled
-#
-
-my %got_email = (); # userid -> received email
-
-local $LJ::_T_EMAIL_NOTIFICATION = sub {
- my ($u, $body) = @_;
- $got_email{$u->userid}++;
- return 1;
-};
-
-my $proc_events = sub {
- %got_email = ();
- LJ::Event->process_fired_events;
-};
-
-my $got_notified = sub {
- my $u = shift;
- $proc_events->();
- return $got_email{$u->{userid}};
-};
-
-
-my $mem_round = 0;
-my $s1s2;
-
-# testing case S1 above:
-memcache_stress(sub {
- $mem_round++;
-
- test_esn_flow(sub {
- my ($u1, $u2, $ucomm) = @_;
-
- # subscribe $u1 to all posts by $u2
- my $subsc = $u1->subscribe(
- event => "UserNewEntry",
- method => "Email",
- journal => $u2,
- );
-
- ok($subsc, "made S1 subscription");
-
- $s1s2 = "S1";
- test_post($u1, $u2, $ucomm);
-
- ok($subsc->delete, "Deleted subscription");
-
- ###### S2:
- if (LJ::Event::JournalNewEntry->zero_journalid_subs_means eq
"trusted_or_watched") {
- # subscribe $u1 to all comments on all friends journals
- # subscribe $u1 to all posts on $u2
- my $subsc = $u1->subscribe(
- event => "JournalNewEntry",
- method => "Email",
- );
-
- ok($subsc, "made S2 subscription");
-
- $s1s2 = "S2";
- test_post($u1, $u2, $ucomm);
-
- # remove $u2 from $u1's friends list, post in $u2 and make sure
$u1 isn't notified
- $u1->remove_edge( $u2, watch => { nonotify => 1 }, trust => {
nonotify => 1 } );
- $u2->t_post_fake_entry;
- my $email = $got_notified->($u1);
- ok(! $email, "u1 did not get notified because u2 is no longer his
friend");
- ok($subsc->delete, "Deleted subscription");
- }
-
- });
-});
-
-# post an entry in $u2, by $u2 and make sure $u1 gets notified
-# post an entry in $u1, by $u2 and make sure $u1 doesn't get notified
-# post a friends-only entry in $u2, by $u2 and make sure $u1 doesn't get
notified
-# post an entry in $ucomm, by $u2 and make sure $u1 gets notified
-# post an entry in $u1, by $ucomm and make sure $u1 doesn't get notified
-# post a friends-only entry in $ucomm, by $u2 and make sure $u1 doesn't get
notified
-sub test_post {
- my ($u1, $u2, $ucomm) = @_;
- my $email;
-
- my $do_post = sub {
- my ( $u, $usejournal, %opts ) = @_;
- if ( $usejournal ) {
- return eval { $u->t_post_fake_comm_entry( $ucomm, %opts ) };
- } else {
- return eval { $u->t_post_fake_entry( %opts ) };
- }
- };
-
- # u2 must have membership for usemask posting
- die unless $u2->add_edge( $ucomm, member => {} );
- foreach my $usejournal (0..1) {
- my $suffix = $usejournal ? " in comm" : "";
-
- my $state = "(state:
mem=$mem_round,s1s2=$s1s2,usejournal=$usejournal)";
-
- # post an entry in $u2
- my $u2e1 = $do_post->( $u2, $usejournal );
- ok($u2e1, "made a post$suffix");
- is($@, "", "no errors");
-
- # S1 failing case:
- # post an entry on $u1, where nobody's subscribed
- my $u1e1 = $do_post->( $u1, $usejournal );
- ok($u1e1, "did a post$suffix");
-
- # make sure we did not get notification
- $email = $got_notified->($u2);
- ok(! $email, "got no email");
-
- # S1 failing case, posting to u2, due to security
- my $u2e2f = $do_post->( $u2, $usejournal, security => "friends" );
- ok($u2e2f, "did a post$suffix");
- is($u2e2f->security, "usemask", "is actually friends only");
-
- # make sure we didn't get notification
- $email = $got_notified->($u1);
- ok(! $email, "got no email, due to security (u2 doesn't trust u1)");
- }
-}
-
-
-sub test_esn_flow {
- my $cv = shift;
- my $u1 = temp_user();
- my $u2 = temp_user();
-
- # need a community for $u1 and $u2 to play in
- my $ucomm = temp_comm();
-
- $u1->add_edge( $u2, watch => { nonotify => 1 }, trust => { nonotify => 1 }
); # make u1 friend u2
- $cv->($u1, $u2, $ucomm);
-}
-
-1;
-
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog