Insert NIP-89 "client" tags when users post statuses

This commit is contained in:
Alex Gleason 2025-04-01 19:49:31 -05:00
parent c8b1c2050b
commit caf59f4078
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -17,6 +17,7 @@ import { languageSchema } from '@/schema.ts';
import { hydrateEvents } from '@/storages/hydrate.ts'; import { hydrateEvents } from '@/storages/hydrate.ts';
import { assertAuthenticated, createEvent, parseBody, updateListEvent } from '@/utils/api.ts'; import { assertAuthenticated, createEvent, parseBody, updateListEvent } from '@/utils/api.ts';
import { getCustomEmojis } from '@/utils/custom-emoji.ts'; import { getCustomEmojis } from '@/utils/custom-emoji.ts';
import { getInstanceMetadata } from '@/utils/instance.ts';
import { getInvoice, getLnurl } from '@/utils/lnurl.ts'; import { getInvoice, getLnurl } from '@/utils/lnurl.ts';
import { purifyEvent } from '@/utils/purify.ts'; import { purifyEvent } from '@/utils/purify.ts';
import { getZapSplits } from '@/utils/zap-split.ts'; import { getZapSplits } from '@/utils/zap-split.ts';
@ -25,6 +26,7 @@ import { accountFromPubkey, renderAccount } from '@/views/mastodon/accounts.ts';
import { renderReblog, renderStatus } from '@/views/mastodon/statuses.ts'; import { renderReblog, renderStatus } from '@/views/mastodon/statuses.ts';
const createStatusSchema = z.object({ const createStatusSchema = z.object({
disclose_client: z.boolean().nullish(),
in_reply_to_id: n.id().nullish(), in_reply_to_id: n.id().nullish(),
language: languageSchema.nullish(), language: languageSchema.nullish(),
media_ids: z.string().array().nullish(), media_ids: z.string().array().nullish(),
@ -265,6 +267,11 @@ const createStatusController: AppController = async (c) => {
content += mediaUrls.join('\n'); content += mediaUrls.join('\n');
} }
if (data.disclose_client) {
const { name } = await getInstanceMetadata(c.var);
tags.push(['client', name, `31990:${await conf.signer.getPublicKey()}:ditto`, conf.relay]);
}
const event = await createEvent({ const event = await createEvent({
kind: 1, kind: 1,
content, content,