mirror of
https://github.com/flarum/core.git
synced 2025-07-30 13:10:24 +02:00
More powerful/extensible notifications
- Notifications can be delivered in multiple ways (alert, email) - Different notification types can implement interfaces to allow themselves to be delivered in these various ways - User preferences for each notification type/method combination are automatically registered
This commit is contained in:
@@ -356,7 +356,7 @@ class User extends Model
|
||||
$defaults[$k] = $v['default'];
|
||||
}
|
||||
|
||||
return array_merge($defaults, (array) json_decode($value, true));
|
||||
return array_merge($defaults, array_only((array) json_decode($value, true), array_keys(static::$preferences)));
|
||||
}
|
||||
|
||||
public function setPreferencesAttribute($value)
|
||||
@@ -372,6 +372,16 @@ class User extends Model
|
||||
];
|
||||
}
|
||||
|
||||
public static function notificationPreferenceKey($type, $sender)
|
||||
{
|
||||
return 'notify_'.$type.'_'.$sender;
|
||||
}
|
||||
|
||||
public function shouldNotify($type, $method)
|
||||
{
|
||||
return $this->preference(static::notificationPreferenceKey($type, $method));
|
||||
}
|
||||
|
||||
public function preference($key, $default = null)
|
||||
{
|
||||
return array_get($this->preferences, $key, $default);
|
||||
|
Reference in New Issue
Block a user