1
0
mirror of https://github.com/flarum/core.git synced 2025-10-22 20:26:15 +02:00

Notifications into the queue

Forces notifications into a dedicated SendNotificationsJob and passed
to the queue.

- One static method re-used in the job ::getAttributes, is that okay or
  use a trait?
- Do we want to use this solution and refactor into a better Hub after
  stable, postpone this implementation or use it in b11?
This commit is contained in:
Daniël Klabbers
2019-11-13 11:58:52 +01:00
committed by Franz Liedke
parent 6b3d634917
commit cd8a8e9dd7
7 changed files with 174 additions and 79 deletions

View File

@@ -0,0 +1,23 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Notification\Blueprint;
abstract class AbstractBlueprint implements BlueprintInterface
{
public function getAttributes(): array
{
return [
'type' => static::getType(),
'from_user_id' => ($fromUser = $this->getFromUser()) ? $fromUser->id : null,
'subject_id' => ($subject = $this->getSubject()) ? $subject->getKey() : null,
'data' => ($data = $this->getData()) ? json_encode($data) : null
];
}
}

View File

@@ -9,6 +9,9 @@
namespace Flarum\Notification\Blueprint;
use Flarum\Database\AbstractModel;
use Flarum\User\User;
/**
* A notification BlueprintInterface, when instantiated, represents a notification about
* something. The blueprint is used by the NotificationSyncer to commit the
@@ -19,14 +22,14 @@ interface BlueprintInterface
/**
* Get the user that sent the notification.
*
* @return \Flarum\User\User|null
* @return User|null
*/
public function getFromUser();
/**
* Get the model that is the subject of this activity.
*
* @return \Flarum\Database\AbstractModel|null
* @return AbstractModel|null
*/
public function getSubject();