strictNullChecks (#4666)

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
This commit is contained in:
syuilo 2019-04-13 01:43:22 +09:00 committed by GitHub
parent 4ee40c3345
commit 987168b863
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
214 changed files with 939 additions and 785 deletions

View file

@ -9,14 +9,15 @@ import renderEmoji from './emoji';
import { IIdentifier } from '../models/identifier';
import renderHashtag from './hashtag';
import { DriveFiles, UserProfiles, UserKeypairs } from '../../../models';
import { ensure } from '../../../prelude/ensure';
export async function renderPerson(user: ILocalUser) {
const id = `${config.url}/users/${user.id}`;
const [avatar, banner, profile] = await Promise.all([
DriveFiles.findOne(user.avatarId),
DriveFiles.findOne(user.bannerId),
UserProfiles.findOne({ userId: user.id })
user.avatarId ? DriveFiles.findOne(user.avatarId) : Promise.resolve(undefined),
user.bannerId ? DriveFiles.findOne(user.bannerId) : Promise.resolve(undefined),
UserProfiles.findOne({ userId: user.id }).then(ensure)
]);
const attachment: {
@ -76,9 +77,7 @@ export async function renderPerson(user: ILocalUser) {
...hashtagTags,
];
const keypair = await UserKeypairs.findOne({
userId: user.id
});
const keypair = await UserKeypairs.findOne(user.id).then(ensure);
return {
type: user.isBot ? 'Service' : 'Person',
@ -94,8 +93,8 @@ export async function renderPerson(user: ILocalUser) {
preferredUsername: user.username,
name: user.name,
summary: toHtml(parse(profile.description)),
icon: user.avatarId && renderImage(avatar),
image: user.bannerId && renderImage(banner),
icon: avatar ? renderImage(avatar) : null,
image: banner ? renderImage(banner) : null,
tag,
manuallyApprovesFollowers: user.isLocked,
publicKey: renderKey(user, keypair),