mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +01:00
Notification API correctly handles invalid resources
This commit is contained in:
parent
5311577aa2
commit
d0b356be2c
3 changed files with 8 additions and 4 deletions
|
@ -42,7 +42,9 @@ class NotificationsController extends ApiControllerBase
|
|||
->take(20)
|
||||
->get();
|
||||
|
||||
return ['notifications' => $notifications->toArray()];
|
||||
$outputArray = $notifications->toArray();
|
||||
|
||||
return ['notifications' => array_values(array_filter($outputArray))];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -151,9 +151,6 @@ class Activity extends Model {
|
|||
|
||||
public function getThumbnailUrlAttribute()
|
||||
{
|
||||
if (is_null($this->resource))
|
||||
return "/images/icons/profile_small.png";
|
||||
|
||||
switch ($this->resource_type) {
|
||||
case User::class:
|
||||
return $this->resource->getAvatarUrl(Image::THUMBNAIL);
|
||||
|
@ -172,6 +169,7 @@ class Activity extends Model {
|
|||
}
|
||||
|
||||
public function getTitleFromActivityType() {
|
||||
|
||||
switch($this->activity_type) {
|
||||
case static::TYPE_PUBLISHED_TRACK:
|
||||
return "Pony.fm - New track";
|
||||
|
|
|
@ -76,6 +76,10 @@ class Notification extends Model {
|
|||
}
|
||||
|
||||
public function toArray() {
|
||||
if (is_null($this->activity->resource)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'date' => $this->activity->created_at->toAtomString(),
|
||||
|
|
Loading…
Reference in a new issue