OSDN Git Service

Controller::API::Jounal: fix to work
authorhylom <hylom@users.sourceforge.jp>
Thu, 10 Nov 2016 17:49:17 +0000 (02:49 +0900)
committerhylom <hylom@users.sourceforge.jp>
Thu, 10 Nov 2016 17:49:17 +0000 (02:49 +0900)
src/newslash_web/lib/Newslash/Web/Controller/API/Journal.pm

index 0fa05da..18a1a88 100644 (file)
@@ -54,14 +54,13 @@ EOT
     my $message = "";
 
     $params->{description} = $util->escape_html({}, $data->{title});
-    $message = "no title!" if !$params->{title};
+    $message = "no title!" if !$params->{description};
 
-    # check author is valid
-    my $author = $users->select(nickname => $data->{author});
-    if (!defined $author || !$author->{login}) {
+    # check user is valid
+    if (!defined $user || !$user->{login}) {
         $message = "invalid author";
     }
-    $params->{uid} = $author->{uid};
+    $params->{uid} = $user->{uid};
     $params->{article} = $data->{journal};
     $params->{commentstatus} = $data->{comment_status};
     $params->{action} = $data->{action} || 'preview';
@@ -75,7 +74,6 @@ EOT
     #$extra_params->{createheaders} = $c->req->headers->to_string;
 
     if (length($message) > 0) {
-        #warn $message;
         $c->render(json => { err => 1, message => $message });
         $c->rendered(400);
         return;