nanka iroiro (#6853)
* wip * Update maps.ts * wip * wip * wip * wip * Update base.vue * wip * wip * wip * wip * Update link.vue * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update privacy.vue * wip * wip * wip * wip * Update range.vue * wip * wip * wip * wip * Update profile.vue * wip * Update a.vue * Update index.vue * wip * Update sidebar.vue * wip * wip * Update account-info.vue * Update a.vue * wip * wip * Update sounds.vue * wip * wip * wip * wip * wip * wip * wip * wip * Update account-info.vue * Update account-info.vue * wip * wip * wip * Update d-persimmon.json5 * wip
This commit is contained in:
parent
7660839e40
commit
0144408500
106 changed files with 4489 additions and 1734 deletions
|
@ -94,6 +94,14 @@ export const meta = {
|
|||
}
|
||||
},
|
||||
|
||||
backgroundImageUrl: {
|
||||
validator: $.optional.nullable.str,
|
||||
},
|
||||
|
||||
logoImageUrl: {
|
||||
validator: $.optional.nullable.str,
|
||||
},
|
||||
|
||||
name: {
|
||||
validator: $.optional.nullable.str,
|
||||
desc: {
|
||||
|
@ -473,6 +481,14 @@ export default define(meta, async (ps, me) => {
|
|||
set.iconUrl = ps.iconUrl;
|
||||
}
|
||||
|
||||
if (ps.backgroundImageUrl !== undefined) {
|
||||
set.backgroundImageUrl = ps.backgroundImageUrl;
|
||||
}
|
||||
|
||||
if (ps.logoImageUrl !== undefined) {
|
||||
set.logoImageUrl = ps.logoImageUrl;
|
||||
}
|
||||
|
||||
if (ps.name !== undefined) {
|
||||
set.name = ps.name;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ export default define(meta, async (ps, user) => {
|
|||
const instance = await fetchMeta(true);
|
||||
|
||||
// Calculate drive usage
|
||||
const usage = await DriveFiles.clacDriveUsageOf(user);
|
||||
const usage = await DriveFiles.calcDriveUsageOf(user);
|
||||
|
||||
return {
|
||||
capacity: 1024 * 1024 * instance.localDriveCapacityMb,
|
||||
|
|
|
@ -106,6 +106,13 @@ export const meta = {
|
|||
}
|
||||
},
|
||||
|
||||
noCrawle: {
|
||||
validator: $.optional.bool,
|
||||
desc: {
|
||||
'ja-JP': '検索エンジンによるインデックスを拒否するか否か'
|
||||
}
|
||||
},
|
||||
|
||||
isBot: {
|
||||
validator: $.optional.bool,
|
||||
desc: {
|
||||
|
@ -204,6 +211,7 @@ export default define(meta, async (ps, user, token) => {
|
|||
if (typeof ps.isBot === 'boolean') updates.isBot = ps.isBot;
|
||||
if (typeof ps.carefulBot === 'boolean') profileUpdates.carefulBot = ps.carefulBot;
|
||||
if (typeof ps.autoAcceptFollowed === 'boolean') profileUpdates.autoAcceptFollowed = ps.autoAcceptFollowed;
|
||||
if (typeof ps.noCrawle === 'boolean') profileUpdates.noCrawle = ps.noCrawle;
|
||||
if (typeof ps.isCat === 'boolean') updates.isCat = ps.isCat;
|
||||
if (typeof ps.injectFeaturedNote === 'boolean') profileUpdates.injectFeaturedNote = ps.injectFeaturedNote;
|
||||
if (typeof ps.alwaysMarkNsfw === 'boolean') profileUpdates.alwaysMarkNsfw = ps.alwaysMarkNsfw;
|
||||
|
|
|
@ -129,6 +129,8 @@ export default define(meta, async (ps, me) => {
|
|||
bannerUrl: instance.bannerUrl,
|
||||
errorImageUrl: instance.errorImageUrl,
|
||||
iconUrl: instance.iconUrl,
|
||||
backgroundImageUrl: instance.backgroundImageUrl,
|
||||
logoImageUrl: instance.logoImageUrl,
|
||||
maxNoteTextLength: Math.min(instance.maxNoteTextLength, DB_MAX_NOTE_TEXT_LENGTH),
|
||||
emojis: await Emojis.packMany(emojis),
|
||||
enableEmail: instance.enableEmail,
|
||||
|
|
144
src/server/api/endpoints/users/stats.ts
Normal file
144
src/server/api/endpoints/users/stats.ts
Normal file
|
@ -0,0 +1,144 @@
|
|||
import $ from 'cafy';
|
||||
import define from '../../define';
|
||||
import { ApiError } from '../../error';
|
||||
import { ID } from '../../../../misc/cafy-id';
|
||||
import { DriveFiles, Followings, NoteFavorites, NoteReactions, Notes, PageLikes, PollVotes, ReversiGames, Users } from '../../../../models';
|
||||
|
||||
export const meta = {
|
||||
tags: ['users'],
|
||||
|
||||
requireCredential: false as const,
|
||||
|
||||
params: {
|
||||
userId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchUser: {
|
||||
message: 'No such user.',
|
||||
code: 'NO_SUCH_USER',
|
||||
id: '9e638e45-3b25-4ef7-8f95-07e8498f1819'
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
export default define(meta, async (ps, me) => {
|
||||
const user = await Users.findOne(ps.userId);
|
||||
if (user == null) {
|
||||
throw new ApiError(meta.errors.noSuchUser);
|
||||
}
|
||||
|
||||
const [
|
||||
notesCount,
|
||||
repliesCount,
|
||||
renotesCount,
|
||||
repliedCount,
|
||||
renotedCount,
|
||||
pollVotesCount,
|
||||
pollVotedCount,
|
||||
localFollowingCount,
|
||||
remoteFollowingCount,
|
||||
localFollowersCount,
|
||||
remoteFollowersCount,
|
||||
sentReactionsCount,
|
||||
receivedReactionsCount,
|
||||
noteFavoritesCount,
|
||||
pageLikesCount,
|
||||
pageLikedCount,
|
||||
driveFilesCount,
|
||||
driveUsage,
|
||||
reversiCount,
|
||||
] = await Promise.all([
|
||||
Notes.createQueryBuilder('note')
|
||||
.where('note.userId = :userId', { userId: user.id })
|
||||
.getCount(),
|
||||
Notes.createQueryBuilder('note')
|
||||
.where('note.userId = :userId', { userId: user.id })
|
||||
.andWhere('note.replyId IS NOT NULL')
|
||||
.getCount(),
|
||||
Notes.createQueryBuilder('note')
|
||||
.where('note.userId = :userId', { userId: user.id })
|
||||
.andWhere('note.renoteId IS NOT NULL')
|
||||
.getCount(),
|
||||
Notes.createQueryBuilder('note')
|
||||
.where('note.replyUserId = :userId', { userId: user.id })
|
||||
.getCount(),
|
||||
Notes.createQueryBuilder('note')
|
||||
.where('note.renoteUserId = :userId', { userId: user.id })
|
||||
.getCount(),
|
||||
PollVotes.createQueryBuilder('vote')
|
||||
.where('vote.userId = :userId', { userId: user.id })
|
||||
.getCount(),
|
||||
PollVotes.createQueryBuilder('vote')
|
||||
.innerJoin('vote.note', 'note')
|
||||
.where('note.userId = :userId', { userId: user.id })
|
||||
.getCount(),
|
||||
Followings.createQueryBuilder('following')
|
||||
.where('following.followerId = :userId', { userId: user.id })
|
||||
.andWhere('following.followeeHost IS NULL')
|
||||
.getCount(),
|
||||
Followings.createQueryBuilder('following')
|
||||
.where('following.followerId = :userId', { userId: user.id })
|
||||
.andWhere('following.followeeHost IS NOT NULL')
|
||||
.getCount(),
|
||||
Followings.createQueryBuilder('following')
|
||||
.where('following.followeeId = :userId', { userId: user.id })
|
||||
.andWhere('following.followerHost IS NULL')
|
||||
.getCount(),
|
||||
Followings.createQueryBuilder('following')
|
||||
.where('following.followeeId = :userId', { userId: user.id })
|
||||
.andWhere('following.followerHost IS NOT NULL')
|
||||
.getCount(),
|
||||
NoteReactions.createQueryBuilder('reaction')
|
||||
.where('reaction.userId = :userId', { userId: user.id })
|
||||
.getCount(),
|
||||
NoteReactions.createQueryBuilder('reaction')
|
||||
.innerJoin('reaction.note', 'note')
|
||||
.where('note.userId = :userId', { userId: user.id })
|
||||
.getCount(),
|
||||
NoteFavorites.createQueryBuilder('favorite')
|
||||
.where('favorite.userId = :userId', { userId: user.id })
|
||||
.getCount(),
|
||||
PageLikes.createQueryBuilder('like')
|
||||
.where('like.userId = :userId', { userId: user.id })
|
||||
.getCount(),
|
||||
PageLikes.createQueryBuilder('like')
|
||||
.innerJoin('like.page', 'page')
|
||||
.where('page.userId = :userId', { userId: user.id })
|
||||
.getCount(),
|
||||
DriveFiles.createQueryBuilder('file')
|
||||
.where('file.userId = :userId', { userId: user.id })
|
||||
.getCount(),
|
||||
DriveFiles.calcDriveUsageOf(user),
|
||||
ReversiGames.createQueryBuilder('game')
|
||||
.where('game.user1Id = :userId', { userId: user.id })
|
||||
.orWhere('game.user2Id = :userId', { userId: user.id })
|
||||
.getCount(),
|
||||
]);
|
||||
|
||||
return {
|
||||
notesCount,
|
||||
repliesCount,
|
||||
renotesCount,
|
||||
repliedCount,
|
||||
renotedCount,
|
||||
pollVotesCount,
|
||||
pollVotedCount,
|
||||
localFollowingCount,
|
||||
remoteFollowingCount,
|
||||
localFollowersCount,
|
||||
remoteFollowersCount,
|
||||
followingCount: localFollowingCount + remoteFollowingCount,
|
||||
followersCount: localFollowersCount + remoteFollowersCount,
|
||||
sentReactionsCount,
|
||||
receivedReactionsCount,
|
||||
noteFavoritesCount,
|
||||
pageLikesCount,
|
||||
pageLikedCount,
|
||||
driveFilesCount,
|
||||
driveUsage,
|
||||
reversiCount,
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue