added a queue for posting activities
This commit is contained in:
parent
c0ad0c46d6
commit
7e3b868a90
17
README.md
17
README.md
@ -202,13 +202,28 @@ php artisan storage:link
|
||||
php artisan install:broadcasting
|
||||
```
|
||||
|
||||
Now, we need to create two services to handle the jobs that OurSpace needs to run and another one to run Laravel Reverb. So run something `emacs /lib/systemd/system/ourspace-queue.service` and `emacs /lib/systemd/system/ourspace-ws.service` and add the following content:
|
||||
Now, we need to create three services to handle the jobs that OurSpace needs to run, another to handle the notifications' queue and another one to run Laravel Reverb. So run something `emacs /lib/systemd/system/ourspace-queue.service`, `emacs /lib/systemd/system/ourspace-notifications.service`, `emacs /lib/systemd/system/ourspace-ws.service` and add the following content:
|
||||
|
||||
```ini
|
||||
# /lib/systemd/system/ourspace-queue.service
|
||||
[Unit]
|
||||
Description=OurSpace queue worker
|
||||
|
||||
[Service]
|
||||
User=www-data
|
||||
Group=www-data
|
||||
Restart=on-failure
|
||||
ExecStart=/usr/bin/php /var/www/html/ourspace/artisan queue:work --daemon --env=production --queue=ap
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
```ini
|
||||
# /lib/systemd/system/ourspace-notifications.service
|
||||
[Unit]
|
||||
Description=OurSpace notifications worker
|
||||
|
||||
[Service]
|
||||
User=www-data
|
||||
Group=www-data
|
||||
|
@ -18,6 +18,9 @@ class PostController extends Controller
|
||||
{
|
||||
$actor = $note->get_actor ()->first ();
|
||||
|
||||
if (!$actor)
|
||||
return redirect ()->back ();
|
||||
|
||||
return view ("posts.show", compact ("note", "actor"));
|
||||
}
|
||||
|
||||
|
@ -170,8 +170,9 @@ class ProfileController extends Controller
|
||||
return redirect ()->route ("login");
|
||||
|
||||
$user = auth ()->user ();
|
||||
$unread_notifications = $user->notifications;
|
||||
$notifications = PaginationHelper::paginate (collect ($unread_notifications), 20);
|
||||
$user_notifications = $user->notifications;
|
||||
$notifications = PaginationHelper::paginate (collect ($user_notifications), 20);
|
||||
$unread_notifications = $user->unreadNotifications->count ();
|
||||
$processed_notifications = [];
|
||||
|
||||
foreach ($notifications as $notification)
|
||||
@ -212,6 +213,6 @@ class ProfileController extends Controller
|
||||
$notification->markAsRead ();
|
||||
}
|
||||
|
||||
return view ("users.notifications", compact ("user", "notifications", "processed_notifications"));
|
||||
return view ("users.notifications", compact ("user", "notifications", "processed_notifications", "unread_notifications"));
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,11 @@ namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\BroadcastMessage;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class UserNotification extends Notification
|
||||
class UserNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
|
@ -237,7 +237,7 @@ class TypeActivity {
|
||||
|
||||
public static function post_activity (Activity $activity, Actor $source, $target, $should_sign = false)
|
||||
{
|
||||
PostActivityJob::dispatch ($activity, $source, $target, $should_sign);
|
||||
PostActivityJob::dispatch ($activity, $source, $target, $should_sign)->onQueue ("ap");
|
||||
|
||||
return [
|
||||
"success" => "activity posted"
|
||||
|
@ -3,6 +3,7 @@
|
||||
@section ("title", "View Post")
|
||||
|
||||
@section ("content")
|
||||
|
||||
<div class="row article blog-entry">
|
||||
<div class="col w-20 left">
|
||||
<div class="edit-info">
|
||||
|
@ -5,8 +5,7 @@
|
||||
@section ("content")
|
||||
<div class="simple-container">
|
||||
<h1>Notifications</h1>
|
||||
<p>You have <b>{{ count ($user->unreadNotifications) }}</b> unread notifications</p>
|
||||
<br>
|
||||
<p>You have <b>{{ $unread_notifications }}</b> unread notifications</p>
|
||||
|
||||
<table border="1" width="100%">
|
||||
<tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user