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

[ljcom] r10375: LJSUP-8547 (Add ability to post an entry...

Committer: ailyin
LJSUP-8547 (Add ability to post an entry to community for identity accounts): QOTD
U   trunk/cgi-bin/LJ/Hooks/QotD.pm
Modified: trunk/cgi-bin/LJ/Hooks/QotD.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/QotD.pm	2011-04-12 06:34:28 UTC (rev 10374)
+++ trunk/cgi-bin/LJ/Hooks/QotD.pm	2011-04-12 07:08:29 UTC (rev 10375)
@@ -247,8 +247,27 @@
 
     return if 'lj_bot' eq $opts->{req}->{user}; # Don't count autoposted entry from 'lj_bot'.
 
+    # repost to the QOTD answers community, unless this already goes there
+    unless ( $entry->journal->username eq $LJ::QOTD_COMMUNITY ) {
+        # clone the request hashref; a little bit hacky, but yay perl
+        my $repost_req = {
+            %{ $opts->{'req'} },
+            'props' => { %{ $opts->{'req'}->{'props'} } }
+        };
+
+        # now, alter it to post to the community as appropriate
+        $repost_req->{'usejournal'} = $LJ::QOTD_COMMUNITY;
+        $repost_req->{'qotd_xpost'} = 1;
+
+        LJ::Protocol::do_request( 'postevent', $repost_req,
+                                  \'', { 'noauth' => 1 } );
+    }
+
     # add to queue
-    LJ::queue("latest_qotd_$qid", $LJ::RECENT_QOTD_SIZE)->add(join(',', $entry->journalid, $entry->jitemid));
+    unless ( $opts->{'req'}->{'qotd_xpost'} ) {
+        my $queue = LJ::queue("latest_qotd_$qid", $LJ::RECENT_QOTD_SIZE);
+        $queue->add(join(',', $entry->journalid, $entry->jitemid));
+    }
 });
 
 LJ::register_hook("expand_template_qotd", sub {

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