updateCredentialsController: delete empty fields from metadata
This commit is contained in:
parent
5dee6450ec
commit
4f32972d85
|
@ -1,4 +1,4 @@
|
||||||
import { NostrFilter, NSchema as n } from '@nostrify/nostrify';
|
import { NostrFilter, NostrMetadata, NSchema as n } from '@nostrify/nostrify';
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
@ -220,8 +220,8 @@ const accountStatusesController: AppController = async (c) => {
|
||||||
const updateCredentialsSchema = z.object({
|
const updateCredentialsSchema = z.object({
|
||||||
display_name: z.string().optional(),
|
display_name: z.string().optional(),
|
||||||
note: z.string().optional(),
|
note: z.string().optional(),
|
||||||
avatar: fileSchema.optional(),
|
avatar: fileSchema.or(z.literal('')).optional(),
|
||||||
header: fileSchema.optional(),
|
header: fileSchema.or(z.literal('')).optional(),
|
||||||
locked: z.boolean().optional(),
|
locked: z.boolean().optional(),
|
||||||
bot: z.boolean().optional(),
|
bot: z.boolean().optional(),
|
||||||
discoverable: z.boolean().optional(),
|
discoverable: z.boolean().optional(),
|
||||||
|
@ -269,6 +269,12 @@ const updateCredentialsController: AppController = async (c) => {
|
||||||
meta.website = website ?? meta.website;
|
meta.website = website ?? meta.website;
|
||||||
meta.bot = bot ?? meta.bot;
|
meta.bot = bot ?? meta.bot;
|
||||||
|
|
||||||
|
if (avatarFile === '') delete meta.picture;
|
||||||
|
if (headerFile === '') delete meta.banner;
|
||||||
|
if (nip05 === '') delete meta.nip05;
|
||||||
|
if (lud16 === '') delete meta.lud16;
|
||||||
|
if (website === '') delete meta.website;
|
||||||
|
|
||||||
const event = await createEvent({
|
const event = await createEvent({
|
||||||
kind: 0,
|
kind: 0,
|
||||||
content: JSON.stringify(meta),
|
content: JSON.stringify(meta),
|
||||||
|
|
Loading…
Reference in New Issue