Clean up
This commit is contained in:
@ -22,27 +22,28 @@ export type IApp = {
|
||||
|
||||
/**
|
||||
* Pack an app for API response
|
||||
*
|
||||
* @param {any} app
|
||||
* @param {any} me?
|
||||
* @param {any} options?
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
export const pack = (
|
||||
app: any,
|
||||
me?: any,
|
||||
options?: {
|
||||
detail?: boolean,
|
||||
includeSecret?: boolean,
|
||||
includeProfileImageIds?: boolean
|
||||
}
|
||||
) => new Promise<any>(async (resolve, reject) => {
|
||||
const opts = options || {
|
||||
const opts = Object.assign({
|
||||
detail: false,
|
||||
includeSecret: false,
|
||||
includeProfileImageIds: false
|
||||
};
|
||||
}, options);
|
||||
|
||||
let _app: any;
|
||||
|
||||
const fields = opts.detail ? {} : {
|
||||
name: true
|
||||
};
|
||||
|
||||
// Populate the app if 'app' is ID
|
||||
if (isObjectId(app)) {
|
||||
_app = await App.findOne({
|
||||
@ -51,7 +52,7 @@ export const pack = (
|
||||
} else if (typeof app === 'string') {
|
||||
_app = await App.findOne({
|
||||
_id: new mongo.ObjectID(app)
|
||||
});
|
||||
}, { fields });
|
||||
} else {
|
||||
_app = deepcopy(app);
|
||||
}
|
||||
|
@ -223,33 +223,16 @@ export const pack = (
|
||||
|
||||
let _user: any;
|
||||
|
||||
const fields = opts.detail ? {
|
||||
} : {
|
||||
usernameLower: false,
|
||||
bannerColor: false,
|
||||
bannerUrl: false,
|
||||
description: false,
|
||||
notesCount: false,
|
||||
followersCount: false,
|
||||
followingCount: false,
|
||||
lastUsedAt: false,
|
||||
settings: false,
|
||||
clientSettings: false,
|
||||
profile: false,
|
||||
keywords: false,
|
||||
domains: false,
|
||||
pinnedNoteIds: false,
|
||||
wallpaperColor: false,
|
||||
wallpaperId: false,
|
||||
wallpaperUrl: false,
|
||||
twitter: false,
|
||||
pendingReceivedFollowRequestsCount: false,
|
||||
featured: false,
|
||||
sharedInbox: false,
|
||||
endpoints: false,
|
||||
inbox: false,
|
||||
twoFactorTempSecret: false,
|
||||
twoFactorSecret: false
|
||||
const fields = opts.detail ? {} : {
|
||||
name: true,
|
||||
username: true,
|
||||
host: true,
|
||||
avatarColor: true,
|
||||
avatarUrl: true,
|
||||
isCat: true,
|
||||
isBot: true,
|
||||
isAdmin: true,
|
||||
isVerified: true
|
||||
};
|
||||
|
||||
// Populate the user if 'user' is ID
|
||||
|
Reference in New Issue
Block a user