Update Direct Messages, fix api endpoint

This commit is contained in:
Daniel Supernault 2023-06-02 06:45:14 -06:00
parent eaff1a7607
commit fe8728c0ba
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -2447,14 +2447,17 @@ class ApiV1Controller extends Controller
'id' => $dm->id, 'id' => $dm->id,
'unread' => false, 'unread' => false,
'accounts' => [ 'accounts' => [
AccountService::getMastodon($from) AccountService::getMastodon($from, true)
], ],
'last_status' => StatusService::getDirectMessage($dm->status_id) 'last_status' => StatusService::getDirectMessage($dm->status_id)
]; ];
return $res; return $res;
}) })
->filter(function($dm) { ->filter(function($dm) {
return isset($dm['accounts']) && count($dm['accounts']) && !empty($dm['last_status']); if(!$dm || empty($dm['last_status']) || !isset($dm['accounts']) || !count($dm['accounts']) || !isset($dm['accounts'][0]) || !isset($dm['accounts'][0]['id'])) {
return false;
}
return true;
}) })
->unique(function($item, $key) { ->unique(function($item, $key) {
return $item['accounts'][0]['id']; return $item['accounts'][0]['id'];