From 5205ccecd5d245d5d0c67c28339cf3e84c7a5fde Mon Sep 17 00:00:00 2001 From: Rory& Date: Mon, 7 Jul 2025 20:40:38 +0200 Subject: [PATCH] Add endpoint to get account standing --- assets/schemas.json | Bin 27067718 -> 27237704 bytes src/api/routes/safety-hub/@me/index.ts | 58 ++++++++++++++++++ .../responses/AccountStandingResponse.ts | 38 ++++++++++++ src/util/schemas/responses/index.ts | 1 + 4 files changed, 97 insertions(+) create mode 100644 src/api/routes/safety-hub/@me/index.ts create mode 100644 src/util/schemas/responses/AccountStandingResponse.ts diff --git a/assets/schemas.json b/assets/schemas.json index b208b4cf687cfd424094cb39ec2756bbfd48bb0d..f098d0157220949dac03f4804686bee95c44f83b 100755 GIT binary patch delta 2090 zcmaLX2~d=E9LDik`*&QJ4{nM%)C0RJhHO8tmn~b#%7w{neS(I{_p$#XZQD?*~6=E1|HdeE3gz6 zc%c@&;R9dzp*HHk9{~tNT?8Q*A*hG?2t@-lL?bjt6NI5Dnjsv`5rIe;XaOr)q7_=B z4cej|+M@$HA_~#ygwE)K7<5H9bVm>LL@)G4AM`~(^v3`UL@eSEk3krW1SDbzhGH0o zV+2NG6h>nV#v%#hFdh>y5tA?($(Vwvn1&RjVmf9Z4e78U1DVKz9WyZtv*AECa*&HW zIFXM6%t0YsaH9xwQH*&g!F(*hLM+<5IHxiwGc&))>7L-WIkOzjS!R6x(NR8`xi*)p zYQw5Xvmmjig_(Y?zQ36?+$YF9e`-XCXHTPGi|_wG6JWcuZJNt%Gs`ZeH#LolGefIN zTX~x`JA)(5PFr^Pd0G3K@t(Bs+SWYVJV#zpo_VOotG(w&LY$@Ayt%~^YS!%XjR-wU|wrg>saO1SB{8XJ<7Y&Wv-yqX@v19VTMs(s>NP~9PyS|kp!;$N7msq3xjk_-E?SnC6E{BA94)DhY zn{n5?gFL%=Abxia_PSrdzd}K9%YZQ$JrC?Nw%BqVNbEA*)wb}dzL-N_Oa*L3v54o zk-fxTX0NaV>>xYDUS+Sb*V!BFFng07VMp0p>}~cAdzT$!@3G_T1bd&IWT)6^_5u5l zeZ)RyXV@p~Ec=w5W9Qigc9C6TpRv!`7wk)RnSI5+X5X+Y>?*s)uCs614fY-Tp8ddX zvLD$`>}U21`<4C1erJEMKiMtzS4DQEWjzyKqL%O$KEhY{iQ1x$@D~9hP}CJcB3Oio zdZNAv6%9l~(MU8FO+=VzDw>IK(Og7`NMVQ;!YW#dR-(0NBif2~qP^%KI*KR}Ejo$L zqKk+TT}3z1UGxw=MK94?^bvhUKha+d5CcW5h!gQ*kQgiyM4}iXhKgZgxELWuicw;; z7$e4tBr#5m7Zb!pF-c4o$zqC_DyE4Pkt(K(86r)j3!BIgnIcQr#Y{0v%oYxjEpkMz z$P-SHFABsQQ7Bx(EsDfkQ7q<(5;0#a5DUd3u~;k-rJ_tM70U#~a2V m8nITa6YE8#*dR8FDzQmy7F&cVs>N2ZO>DOu;9ryFtov`$8*n)Q delta 1572 zcmW;MRag)P6o%mk3j@0gTTsOA!cG(u1?*PD#02|S6jW@*S{O@XQy1#y(z)JrVQsqU zW^8sX(f{+}d!KW2F3!z4aX2&Rc-u>i$b{E`5_lx`0U2>P*Z|-+@#a(sR+;#Vd`_tWUH{C6F z+ud<@-92~TJ#Y`*Blnm4+x_GIb^p2lU8Z}SmJk|{?jQ?fg=~-=azG&Dgj|pt@<0&e zg?x}73P3?91cjjp6oq0?97;e*COwuJ4-KFpG=j#^1e!uKXbvr)B}70gXbo+kEwqF7&;dF^C+G}apesZ| zH|P#g&;xoxFX#<@pf5y2Kj;rJ5DRfI00zP!7z{&TC=7$)Fak!xC>RZ6U@VM-co+`} zFaajQB$y0SU@9cSG?)%EU?$9h*^mUuFbC$sJeUs)U?D65!D3hfDX. +*/ + +import { route } from "@spacebar/api"; +import { User, AccountStandingResponse } from "@spacebar/util"; +import { Request, Response, Router } from "express"; + +const router = Router(); + +router.get( + "/", + route({ + responses: { + 200: { + body: "AccountStandingResponse", + }, + 401: { + body: "APIErrorResponse", + }, + }, + }), + async (req: Request, res: Response) => { + const user = await User.findOneOrFail({ + where: { id: req.user_id }, + select: ["data"], + }); + + res.send({ + classifications: [], + guild_classifications: [], + account_standing: { + state: 100, + }, + is_dsa_eligible: true, + username: user.username, + discriminator: user.discriminator, + is_appeal_eligible: true, + appeal_eligibility: [1, 2], + } as AccountStandingResponse); + }, +); + +export default router; diff --git a/src/util/schemas/responses/AccountStandingResponse.ts b/src/util/schemas/responses/AccountStandingResponse.ts new file mode 100644 index 00000000..cee00741 --- /dev/null +++ b/src/util/schemas/responses/AccountStandingResponse.ts @@ -0,0 +1,38 @@ +/* + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2025 Spacebar and Spacebar Contributors + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +export interface AccountStandingResponse { + classifications: unknown[]; // TODO: We don't know what this is yet + guild_classifications: unknown[]; // TODO: We don't know what this is yet + account_standing: { + /** + * @defaultValue 100 + * @minimum 0 + * @maximum 100 + */ + state: number; + }; + is_dsa_eligible: boolean; + username: string; + discriminator: string; // Not sure if this is even valid, we don't have any examples of pre-pomelo users + is_appeal_eligible: boolean; + /** + * @description We don't yet know what these mean, but Discord appears to return "1" and "2". + */ + appeal_eligibility: number[]; +} diff --git a/src/util/schemas/responses/index.ts b/src/util/schemas/responses/index.ts index 856b4a3e..67daaddc 100644 --- a/src/util/schemas/responses/index.ts +++ b/src/util/schemas/responses/index.ts @@ -16,6 +16,7 @@ along with this program. If not, see . */ +export * from "./AccountStandingResponse"; export * from "./APIErrorOrCaptchaResponse"; export * from "./APIErrorResponse"; export * from "./BackupCodesChallengeResponse";