updateCredentials: allow setting nip05 through the API, remove restrictions on update_credentials

This commit is contained in:
Alex Gleason
2024-03-24 16:42:19 -05:00
parent cfc2f02104
commit 75c277e7e8
4 changed files with 10 additions and 7 deletions

View File

@@ -181,11 +181,11 @@ const updateCredentialsSchema = z.object({
locked: z.boolean().optional(),
bot: z.boolean().optional(),
discoverable: z.boolean().optional(),
nip05: z.string().optional(),
});
const updateCredentialsController: AppController = async (c) => {
const pubkey = c.get('pubkey')!;
const user = c.get('user')!;
const body = await parseBody(c.req.raw);
const result = updateCredentialsSchema.safeParse(body);
@@ -201,6 +201,7 @@ const updateCredentialsController: AppController = async (c) => {
header: headerFile,
display_name,
note,
nip05,
} = result.data;
const [avatar, header] = await Promise.all([
@@ -212,7 +213,7 @@ const updateCredentialsController: AppController = async (c) => {
meta.about = note ?? meta.about;
meta.picture = avatar?.url ?? meta.picture;
meta.banner = header?.url ?? meta.banner;
meta.nip05 = `${user.username}@${Conf.url.host}` ?? meta.nip05;
meta.nip05 = nip05 ?? meta.nip05;
const event = await createEvent({
kind: 0,