summaryrefslogtreecommitdiff
path: root/app/Jobs
diff options
context:
space:
mode:
Diffstat (limited to 'app/Jobs')
-rw-r--r--app/Jobs/AddNewCalUser.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/app/Jobs/AddNewCalUser.php b/app/Jobs/AddNewCalUser.php
new file mode 100644
index 0000000..dfb74fe
--- /dev/null
+++ b/app/Jobs/AddNewCalUser.php
@@ -0,0 +1,66 @@
+<?php
+
+# TODO Implement ShouldBeUnique after upgrading to Laravel 8.x
+
+namespace App\Jobs;
+
+use Illuminate\Bus\Queueable;
+#use Illuminate\Contracts\Queue\ShouldBeUnique;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+use romanzipp\QueueMonitor\Traits\IsMonitored;
+
+use App\MALUser;
+use App\Libraries\Helper;
+
+#class AddNewCalUser implements ShouldQueue, ShouldBeUnique
+class AddNewCalUser implements ShouldQueue
+{
+ use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, IsMonitored;
+
+ protected $username;
+
+ public $tries = 1;
+
+ /**
+ * Create a new job instance.
+ *
+ * @return void
+ */
+ public function __construct($username)
+ {
+ $this->username = $username;
+ }
+
+ /**
+ * Execute the job.
+ *
+ * @return void
+ */
+ public function handle()
+ {
+ $helper = new Helper();
+ $helper->createUser( $this->username );
+ if ( false === $helper->setIsWatching( $this->username ) ) {
+ echo "fail!!!";
+ #$this->setOutput(["status" => "fail", "reason" => "user does not exist", "username" => $this->username]);
+ $this->queueData(["status" => "fail", "reason" => "user does not exist", "username" => $this->username]);
+
+ } else {
+ $helper->setCalendar( $this->username );
+ #$this->setOutput(["status" => "okay", "reason" => "", "username" => $this->username]);
+ $this->queueData(["status" => "okay", "reason" => "", "username" => $this->username]);
+ }
+
+ $this->fail();
+ }
+
+ /*
+ public function uniqueId() {
+ #return $this->username;
+ }
+ */
+}