From 28050d61cd7c9a20ccd56b2ed23166ba72b501f1 Mon Sep 17 00:00:00 2001 From: Parziphal Date: Fri, 12 Dec 2014 18:18:37 -0500 Subject: [PATCH] Fix for #131. --- app/models/BatchUpload.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/models/BatchUpload.php b/app/models/BatchUpload.php index d31d714..b78cac5 100755 --- a/app/models/BatchUpload.php +++ b/app/models/BatchUpload.php @@ -31,31 +31,31 @@ class BatchUpload extends Rails\ActiveRecord\Base $this->active = true; $this->save(); - $this->post = Post::create(['source' => $this->url, 'tags' => $this->tags, 'updater_user_id' => $this->user_id, 'updater_ip_addr' => $this->ip, 'user_id' => $this->user_id, 'ip_addr' => $this->ip, 'status' => "active", 'is_upload' => false]); + $post = Post::create(['source' => $this->url, 'tags' => $this->tags, 'updater_user_id' => $this->user_id, 'updater_ip_addr' => $this->ip, 'user_id' => $this->user_id, 'ip_addr' => $this->ip, 'status' => "active", /*'is_upload' => false*/]); - if ($this->post->errors()->blank()) { - if (CONFIG()->dupe_check_on_upload && $this->post->image() && !$this->post->parent_id) { - $options = [ 'services' => SimilarImages::get_services("local"), 'type' => 'post', 'source' => $this->post ]; + if ($post->errors()->blank()) { + if (CONFIG()->dupe_check_on_upload && $post->image() && !$post->parent_id) { + $options = [ 'services' => SimilarImages::get_services("local"), 'type' => 'post', 'source' => $post ]; $res = SimilarImages::similar_images($options); if (!empty($res['posts'])) { - $this->post->tags = $this->post->tags() . " possible_duplicate"; - $this->post->save(); + $post->tags = $post->tags() . " possible_duplicate"; + $post->save(); } } $this->data->success = true; - $this->data->post_id = $this->post->id; - } elseif ($this->post->errors()->on('md5')) { - // $p = $this->post->errors(); - $p = Post::where(['md5' => $this->post->md5])->first(); + $this->data->post_id = $post->id; + } elseif ($post->errors()->on('md5')) { + // $p = $post->errors(); + $p = Post::where(['md5' => $post->md5])->first(); $this->data->success = false; $this->data->error = "Post already exists"; $this->data->post_id = $p->id; } else { - // p $this->post.errors + // p $post.errors $this->data->success = false; - $this->data->error = $this->post->errors()->fullMessages(", "); + $this->data->error = $post->errors()->fullMessages(", "); } if ($this->data->success) {