impr(server): trim consecutive newlines when updating user profile (theiereman) (#5538)

This commit is contained in:
theiereman 2024-07-01 12:30:27 +02:00 committed by GitHub
parent 2da6e555cc
commit 2714af1eeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 4 additions and 3 deletions

View file

@ -847,7 +847,7 @@ export async function updateProfile(
await UserDAL.updateProfile(uid, profileDetailsUpdates, user.inventory);
return new MonkeyResponse("Profile updated");
return new MonkeyResponse("Profile updated", profileDetailsUpdates);
}
export async function getInbox(

View file

@ -160,6 +160,7 @@ export function sanitizeString(str: string | undefined): string | undefined {
return str
.replace(/[\u0300-\u036F]/g, "")
.trim()
.replace(/\n{3,}/g, "\n\n")
.replace(/\s{3,}/g, " ");
}

View file

@ -221,7 +221,7 @@ export default class Users {
async updateProfile(
profileUpdates: Partial<SharedTypes.UserProfileDetails>,
selectedBadgeId?: number
): Ape.EndpointResponse<null> {
): Ape.EndpointResponse<SharedTypes.UserProfileDetails> {
return await this.httpClient.patch(`${BASE_PATH}/profile`, {
payload: {
...profileUpdates,

View file

@ -158,7 +158,7 @@ async function updateProfile(): Promise<void> {
return;
}
snapshot.details = updates;
snapshot.details = response.data ?? updates;
snapshot.inventory?.badges.forEach((badge) => {
if (badge.id === currentSelectedBadgeId) {
badge.selected = true;