diff --git a/src/config.ts b/src/config.ts index 68175a46..68bf3ed8 100644 --- a/src/config.ts +++ b/src/config.ts @@ -350,6 +350,17 @@ class Conf { }; }, }; + static profileFields = { + get maxFields(): number { + return Number(Deno.env.get('PROFILE_FIELDS_MAX_FIELDS') || 10); + }, + get nameLength(): number { + return Number(Deno.env.get('PROFILE_FIELDS_NAME_LENGTH') || 255); + }, + get valueLength(): number { + return Number(Deno.env.get('PROFILE_FIELDS_VALUE_LENGTH') || 2047); + }, + }; } const optionalBooleanSchema = z diff --git a/src/controllers/api/instance.ts b/src/controllers/api/instance.ts index fe8f76ae..92e517c3 100644 --- a/src/controllers/api/instance.ts +++ b/src/controllers/api/instance.ts @@ -50,7 +50,9 @@ const instanceV1Controller: AppController = async (c) => { metadata: { features, fields_limits: { - max_fields: 10, + max_fields: Conf.profileFields.maxFields, + name_length: Conf.profileFields.nameLength, + value_length: Conf.profileFields.valueLength, }, }, }, @@ -145,7 +147,9 @@ const instanceV2Controller: AppController = async (c) => { metadata: { features, fields_limits: { - max_fields: 10, + max_fields: Conf.profileFields.maxFields, + name_length: Conf.profileFields.nameLength, + value_length: Conf.profileFields.valueLength, }, }, }, diff --git a/src/views/mastodon/accounts.ts b/src/views/mastodon/accounts.ts index 4845304e..9b13efbf 100644 --- a/src/views/mastodon/accounts.ts +++ b/src/views/mastodon/accounts.ts @@ -60,7 +60,14 @@ async function renderAccount( } } const { html } = parseNoteContent(about || '', []); - const fields = _fields?.slice(0, 10).map(([name, value]) => ({ name, value, verified_at: null })) ?? []; + + const fields = _fields + ?.slice(0, Conf.profileFields.maxFields) + .map(([name, value]) => ({ + name: name.slice(0, Conf.profileFields.nameLength), + value: value.slice(0, Conf.profileFields.valueLength), + verified_at: null, + })) ?? []; return { id: pubkey,