fix: fix potential null exception (#1765)

This commit is contained in:
Nolan Lawson 2020-05-03 10:45:32 -07:00 committed by GitHub
parent 4b4cee3662
commit 5c4b44e3dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -29,8 +29,16 @@ function tryInitBlurhash () {
}
}
function getActualStatus (statusOrNotification) {
return get(statusOrNotification, ['status']) ||
get(statusOrNotification, ['notification', 'status'])
}
async function decodeAllBlurhashes (statusOrNotification) {
const status = statusOrNotification.status || statusOrNotification.notification.status
const status = getActualStatus(statusOrNotification)
if (!status) {
return
}
const mediaWithBlurhashes = get(status, ['media_attachments'], [])
.concat(get(status, ['reblog', 'media_attachments'], []))
.filter(_ => _.blurhash)
@ -48,7 +56,7 @@ async function decodeAllBlurhashes (statusOrNotification) {
}
async function calculatePlainTextContent (statusOrNotification) {
const status = statusOrNotification.status || statusOrNotification.notification.status
const status = getActualStatus(statusOrNotification)
if (!status) {
return
}