Update show.ts

This commit is contained in:
syuilo 2018-03-29 21:44:39 +09:00 committed by GitHub
parent 6abb04ea12
commit 78f7464891
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 11 deletions

View File

@ -75,18 +75,17 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
// Lookup user // Lookup user
if (typeof host === 'string') { if (typeof host === 'string') {
const usernameLower = username.toLowerCase(); const usernameLower = username.toLowerCase();
const hostLower_ascii = toASCII(host).toLowerCase(); const hostLowerAscii = toASCII(host).toLowerCase();
const hostLower = toUnicode(hostLower_ascii); const hostLower = toUnicode(hostLowerAscii);
user = await findUser({ usernameLower, hostLower }); user = await findUser({ usernameLower, hostLower });
if (user === null) { if (user === null) {
const acct_lower = `${usernameLower}@${hostLower_ascii}`; const acctLower = `${usernameLower}@${hostLowerAscii}`;
let activityStreams; let activityStreams;
let finger; let finger;
let followersCount; let followersCount;
let followingCount; let followingCount;
let likes_count;
let postsCount; let postsCount;
if (!validateUsername(username)) { if (!validateUsername(username)) {
@ -94,7 +93,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
} }
try { try {
finger = await webFingerAndVerify(acct_lower, acct_lower); finger = await webFingerAndVerify(acctLower, acctLower);
} catch (exception) { } catch (exception) {
return rej('WebFinger lookup failed'); return rej('WebFinger lookup failed');
} }
@ -130,12 +129,11 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
} }
try { try {
[followersCount, followingCount, likes_count, postsCount] = await Promise.all([ [followersCount, followingCount, postsCount] = await Promise.all([
getCollectionCount(activityStreams.followers), getCollectionCount(activityStreams.followers),
getCollectionCount(activityStreams.following), getCollectionCount(activityStreams.following),
getCollectionCount(activityStreams.liked),
getCollectionCount(activityStreams.outbox), getCollectionCount(activityStreams.outbox),
webFingerAndVerify(activityStreams.id, acct_lower), webFingerAndVerify(activityStreams.id, acctLower),
]); ]);
} catch (exception) { } catch (exception) {
return rej('failed to fetch assets'); return rej('failed to fetch assets');
@ -153,10 +151,8 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
followingCount, followingCount,
name: activityStreams.name, name: activityStreams.name,
postsCount, postsCount,
likes_count,
liked_count: 0,
driveCapacity: 1024 * 1024 * 8, // 8MiB driveCapacity: 1024 * 1024 * 8, // 8MiB
username: username, username,
usernameLower, usernameLower,
host: toUnicode(finger.subject.replace(/^.*?@/, '')), host: toUnicode(finger.subject.replace(/^.*?@/, '')),
hostLower, hostLower,