OSDN Git Service

Model::LegacyFirehose: fix to run 'createStory'
authorhylom <hylom@users.sourceforge.jp>
Tue, 25 Oct 2016 16:29:11 +0000 (01:29 +0900)
committerhylom <hylom@users.sourceforge.jp>
Tue, 25 Oct 2016 16:29:11 +0000 (01:29 +0900)
src/newslash_web/lib/Newslash/Model/LegacyFirehose.pm

index dbfb113..bfdea0d 100644 (file)
@@ -40,6 +40,7 @@ use File::Path qw(mkpath);
 #use Slash;
 #use Slash::Display;
 #use Slash::Utility;
+use Newslash::Model::SlashUtility;
 #use Slash::Slashboxes;
 #use Slash::Tags;
 #use Sphinx::Search 0.14;
@@ -67,6 +68,10 @@ sub createFireHose {
        $data->{mediatype} ||= "none";
        $data->{email} ||= '';
 
+        # added by hylom, 2016
+        $data->{name} ||= '';
+        $data->{sprite_info} ||= '';
+
        my $text_data = {};
        $text_data->{title} = delete $data->{title};
        $text_data->{introtext} = delete $data->{introtext};
@@ -1041,7 +1046,7 @@ sub updateItemFromStory {
 
        my $story = $slash_db->getStory($id, "", 1);
        if ($story) {
-               my $globjid = $globjs->getGlobjidCreate("stories", $story->{stoid});
+                my $globjid = $globjs->getGlobjidCreate("stories", $story->{stoid});
                my $id = $self->getFireHoseIdFromGlobjid($globjid);
                if ($id) {
                        # If a story is getting its primary skid to an ignored value set its firehose entry to non-public
@@ -1106,7 +1111,7 @@ sub setTopicsRenderedForStory {
                        foreach (@$the_tids) {
                                $self->sqlInsert("firehose_topics_rendered", { id => $id, tid => $_});
                        }
-                       my $tree = $self->getTopicTree();
+                       my $tree = $db->getTopicTree();
                        @nexus_topics = grep { $tree->{$_}->{nexus} } @$the_tids;
                        my $nexus_list = join ' ', @nexus_topics;
                        $nexus_list = " $nexus_list ";
@@ -1120,7 +1125,9 @@ sub createItemFromStory {
        my $constants = $self->getCurrentStatic();
        # If a story is created with an ignored primary skid it'll never be created as a firehose entry currently
        my %ignore_skids = map {$_ => 1 } @{$constants->{firehose_story_ignore_skids}};
-       my $story = $self->getStory($id, '', 1);
+        my $slash_db = $self->new_instance_of("Newslash::Model::SlashDB");
+        my $globjs = $self->new_instance_of("Newslash::Model::Globjs");
+       my $story = $slash_db->getStory($id, '', 1);
 
        my $popularity = $self->getEntryPopularityForColorLevel(2);
        if ($story->{story_topics_rendered}{$constants->{mainpage_nexus_tid}}) {
@@ -1128,7 +1135,7 @@ sub createItemFromStory {
        }
 
        if ($story && !$ignore_skids{$story->{primaryskid}}) {
-               my $globjid = $self->getGlobjidCreate("stories", $story->{stoid});
+               my $globjid = $globjs->getGlobjidCreate("stories", $story->{stoid});
                my $public = $story->{neverdisplay} ? "no" : "yes";
                my $data = {
                        title           => $story->{title},