summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/admin/show-user.ts
diff options
context:
space:
mode:
authorJulia <julia@insertdomain.name>2025-05-29 00:07:38 +0000
committerJulia <julia@insertdomain.name>2025-05-29 00:07:38 +0000
commit6b554c178b81f13f83a69b19d44b72b282a0c119 (patch)
treef5537f1a56323a4dd57ba150b3cb84a2d8b5dc63 /packages/backend/src/server/api/endpoints/admin/show-user.ts
parentmerge: Security fixes (!970) (diff)
parentbump version for release (diff)
downloadsharkey-6b554c178b81f13f83a69b19d44b72b282a0c119.tar.gz
sharkey-6b554c178b81f13f83a69b19d44b72b282a0c119.tar.bz2
sharkey-6b554c178b81f13f83a69b19d44b72b282a0c119.zip
merge: release 2025.4.2 (!1051)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1051 Approved-by: Hazelnoot <acomputerdog@gmail.com> Approved-by: Marie <github@yuugi.dev> Approved-by: Julia <julia@insertdomain.name>
Diffstat (limited to 'packages/backend/src/server/api/endpoints/admin/show-user.ts')
-rw-r--r--packages/backend/src/server/api/endpoints/admin/show-user.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/packages/backend/src/server/api/endpoints/admin/show-user.ts b/packages/backend/src/server/api/endpoints/admin/show-user.ts
index 669bffe2dc..1579719246 100644
--- a/packages/backend/src/server/api/endpoints/admin/show-user.ts
+++ b/packages/backend/src/server/api/endpoints/admin/show-user.ts
@@ -12,6 +12,7 @@ import { RoleEntityService } from '@/core/entities/RoleEntityService.js';
import { IdService } from '@/core/IdService.js';
import { notificationRecieveConfig } from '@/models/json-schema/user.js';
import { isSystemAccount } from '@/misc/is-system-account.js';
+import { CacheService } from '@/core/CacheService.js';
export const meta = {
tags: ['admin'],
@@ -111,6 +112,7 @@ export const meta = {
receiveFollowRequest: { optional: true, ...notificationRecieveConfig },
followRequestAccepted: { optional: true, ...notificationRecieveConfig },
roleAssigned: { optional: true, ...notificationRecieveConfig },
+ chatRoomInvitationReceived: { optional: true, ...notificationRecieveConfig },
achievementEarned: { optional: true, ...notificationRecieveConfig },
app: { optional: true, ...notificationRecieveConfig },
test: { optional: true, ...notificationRecieveConfig },
@@ -185,6 +187,36 @@ export const meta = {
},
},
},
+ followStats: {
+ type: 'object',
+ optional: false, nullable: false,
+ properties: {
+ totalFollowing: {
+ type: 'number',
+ optional: false, nullable: false,
+ },
+ totalFollowers: {
+ type: 'number',
+ optional: false, nullable: false,
+ },
+ localFollowing: {
+ type: 'number',
+ optional: false, nullable: false,
+ },
+ localFollowers: {
+ type: 'number',
+ optional: false, nullable: false,
+ },
+ remoteFollowing: {
+ type: 'number',
+ optional: false, nullable: false,
+ },
+ remoteFollowers: {
+ type: 'number',
+ optional: false, nullable: false,
+ },
+ },
+ },
},
},
} as const;
@@ -212,6 +244,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private roleService: RoleService,
private roleEntityService: RoleEntityService,
private idService: IdService,
+ private readonly cacheService: CacheService,
) {
super(meta, paramDef, async (ps, me) => {
const [user, profile] = await Promise.all([
@@ -236,6 +269,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const roleAssigns = await this.roleService.getUserAssigns(user.id);
const roles = await this.roleService.getUserRoles(user.id);
+ const followStats = await this.cacheService.getFollowStats(user.id);
+
return {
email: profile.email,
emailVerified: profile.emailVerified,
@@ -268,6 +303,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
expiresAt: a.expiresAt ? a.expiresAt.toISOString() : null,
roleId: a.roleId,
})),
+ followStats: {
+ ...followStats,
+ totalFollowers: Math.max(user.followersCount, followStats.localFollowers + followStats.remoteFollowers),
+ totalFollowing: Math.max(user.followingCount, followStats.localFollowing + followStats.remoteFollowing),
+ },
};
});
}