mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Revert "fix(updateCredentialsController): stop overwriting kind 0 unnecessarily"
This reverts commit 342ba7d4b1.
This commit is contained in:
parent
342ba7d4b1
commit
b45fcdde69
1 changed files with 44 additions and 63 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { NostrEvent, NostrFilter, NSchema as n } from '@nostrify/nostrify';
|
||||
import { NostrFilter, NSchema as n } from '@nostrify/nostrify';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
import { z } from 'zod';
|
||||
|
||||
|
|
@ -288,28 +288,12 @@ const updateCredentialsController: AppController = async (c) => {
|
|||
const pubkey = await signer.getPublicKey();
|
||||
const body = await parseBody(c.req.raw);
|
||||
const result = updateCredentialsSchema.safeParse(body);
|
||||
const store = await Storages.db();
|
||||
|
||||
if (!result.success) {
|
||||
return c.json(result.error, 422);
|
||||
}
|
||||
|
||||
const kind0fields = {
|
||||
avatar: result.data.avatar,
|
||||
header: result.data.header,
|
||||
display_name: result.data.display_name,
|
||||
fields_attributes: result.data.fields_attributes,
|
||||
note: result.data.note,
|
||||
nip05: result.data.nip05,
|
||||
lud16: result.data.lud16,
|
||||
website: result.data.website,
|
||||
bot: result.data.bot,
|
||||
};
|
||||
const values = Object.values(kind0fields).filter((value) => value !== undefined);
|
||||
let event: NostrEvent;
|
||||
|
||||
if (values.length) {
|
||||
event = await updateEvent(
|
||||
const event = await updateEvent(
|
||||
{ kinds: [0], authors: [pubkey], limit: 1 },
|
||||
async (prev) => {
|
||||
const meta = n.json().pipe(metadataSchema).catch({}).parse(prev.content);
|
||||
|
|
@ -323,7 +307,7 @@ const updateCredentialsController: AppController = async (c) => {
|
|||
lud16,
|
||||
website,
|
||||
bot,
|
||||
} = kind0fields;
|
||||
} = result.data;
|
||||
|
||||
const [avatar, header] = await Promise.all([
|
||||
avatarFile ? uploadFile(c, avatarFile, { pubkey }) : undefined,
|
||||
|
|
@ -357,9 +341,6 @@ const updateCredentialsController: AppController = async (c) => {
|
|||
},
|
||||
c,
|
||||
);
|
||||
} else {
|
||||
[event] = await store.query([{ kinds: [0], authors: [pubkey] }]);
|
||||
}
|
||||
|
||||
const settingsStore = result.data.pleroma_settings_store;
|
||||
const account = await renderAccount(event, { withSource: true, settingsStore });
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue