forked from mirror/misskey
fix(backend): 名前を空白文字列だけにできる問題を修正
This commit is contained in:
parent
a6edd50a5d
commit
df4a63812e
@ -257,7 +257,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||||||
|
|
||||||
const profile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id });
|
const profile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id });
|
||||||
|
|
||||||
if (ps.name !== undefined) updates.name = ps.name;
|
if (ps.name !== undefined) {
|
||||||
|
if (ps.name === null) {
|
||||||
|
updates.name = null;
|
||||||
|
} else {
|
||||||
|
const trimmedName = ps.name.trim();
|
||||||
|
updates.name = trimmedName === '' ? null : trimmedName;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (ps.description !== undefined) profileUpdates.description = ps.description;
|
if (ps.description !== undefined) profileUpdates.description = ps.description;
|
||||||
if (ps.lang !== undefined) profileUpdates.lang = ps.lang;
|
if (ps.lang !== undefined) profileUpdates.lang = ps.lang;
|
||||||
if (ps.location !== undefined) profileUpdates.location = ps.location;
|
if (ps.location !== undefined) profileUpdates.location = ps.location;
|
||||||
|
@ -409,6 +409,9 @@ describe('ユーザー', () => {
|
|||||||
{ parameters: () => ({ name: 'x'.repeat(50) }) },
|
{ parameters: () => ({ name: 'x'.repeat(50) }) },
|
||||||
{ parameters: () => ({ name: 'x' }) },
|
{ parameters: () => ({ name: 'x' }) },
|
||||||
{ parameters: () => ({ name: 'My name' }) },
|
{ parameters: () => ({ name: 'My name' }) },
|
||||||
|
{ parameters: () => ({ name: '' }), expect: { name: null } },
|
||||||
|
{ parameters: () => ({ name: ' name with spaces ' }), expect: { name: 'name with spaces' } },
|
||||||
|
{ parameters: () => ({ name: ' ' }), expect: { name: null } },
|
||||||
{ parameters: () => ({ description: null }) },
|
{ parameters: () => ({ description: null }) },
|
||||||
{ parameters: () => ({ description: 'x'.repeat(1500) }) },
|
{ parameters: () => ({ description: 'x'.repeat(1500) }) },
|
||||||
{ parameters: () => ({ description: 'x' }) },
|
{ parameters: () => ({ description: 'x' }) },
|
||||||
@ -465,9 +468,9 @@ describe('ユーザー', () => {
|
|||||||
{ parameters: () => ({ notificationRecieveConfig: {} }) },
|
{ parameters: () => ({ notificationRecieveConfig: {} }) },
|
||||||
{ parameters: () => ({ emailNotificationTypes: ['mention', 'reply', 'quote', 'follow', 'receiveFollowRequest'] }) },
|
{ parameters: () => ({ emailNotificationTypes: ['mention', 'reply', 'quote', 'follow', 'receiveFollowRequest'] }) },
|
||||||
{ parameters: () => ({ emailNotificationTypes: [] }) },
|
{ parameters: () => ({ emailNotificationTypes: [] }) },
|
||||||
] as const)('を書き換えることができる($#)', async ({ parameters }) => {
|
] as const)('を書き換えることができる($#)', async ({ parameters, expect }) => {
|
||||||
const response = await successfulApiCall({ endpoint: 'i/update', parameters: parameters(), user: alice });
|
const response = await successfulApiCall({ endpoint: 'i/update', parameters: parameters(), user: alice });
|
||||||
const expected = { ...meDetailed(alice, true), ...parameters() };
|
const expected = { ...meDetailed(alice, true), ...parameters(), ...expect };
|
||||||
assert.deepStrictEqual(response, expected, inspect(parameters()));
|
assert.deepStrictEqual(response, expected, inspect(parameters()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user