mirror of
https://github.com/flarum/framework.git
synced 2024-12-11 21:43:38 +08:00
Notification API tweaks
This commit is contained in:
parent
8cc47c77de
commit
efbe46f7a9
|
@ -19,7 +19,7 @@ class NotificationMailer
|
|||
compact('notification', 'user'),
|
||||
function ($message) use ($notification, $user) {
|
||||
$message->to($user->email, $user->username)
|
||||
->subject('['.$this->forum->title.'] '.$notification->getEmailSubject());
|
||||
->subject($notification->getEmailSubject());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -33,12 +33,7 @@ class NotificationSyncer
|
|||
*/
|
||||
public function sync(NotificationInterface $notification, array $users)
|
||||
{
|
||||
$attributes = [
|
||||
'type' => $notification::getType(),
|
||||
'sender_id' => $notification->getSender()->id,
|
||||
'subject_id' => $notification->getSubject()->id,
|
||||
'data' => ($data = $notification->getData()) ? json_encode($data) : null
|
||||
];
|
||||
$attributes = $this->getAttributes($notification);
|
||||
|
||||
$toDelete = Notification::where($attributes)->get();
|
||||
$toUndelete = [];
|
||||
|
@ -83,6 +78,16 @@ class NotificationSyncer
|
|||
}
|
||||
}
|
||||
|
||||
public function delete(NotificationInterface $notification)
|
||||
{
|
||||
Notification::where($this->getAttributes($notification))->update(['is_deleted' => true]);
|
||||
}
|
||||
|
||||
public function restore(NotificationInterface $notification)
|
||||
{
|
||||
Notification::where($this->getAttributes($notification))->update(['is_deleted' => false]);
|
||||
}
|
||||
|
||||
public function onePerUser(Closure $callback)
|
||||
{
|
||||
$this->sentTo = [];
|
||||
|
@ -92,4 +97,14 @@ class NotificationSyncer
|
|||
|
||||
$this->onePerUser = false;
|
||||
}
|
||||
|
||||
protected function getAttributes(NotificationInterface $notification)
|
||||
{
|
||||
return [
|
||||
'type' => $notification::getType(),
|
||||
'sender_id' => $notification->getSender()->id,
|
||||
'subject_id' => $notification->getSubject()->id,
|
||||
'data' => ($data = $notification->getData()) ? json_encode($data) : null
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user