mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Let field limits be configurable
This commit is contained in:
parent
39cb1ec0c9
commit
81780bec72
3 changed files with 25 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue