Merge branch 'set-lightning-address' into 'main'

Allow users to set their lightning address and website

Closes #1662 and #1664

See merge request soapbox-pub/soapbox!3032
environments/review-main-yi2y9f/deployments/4637
Alex Gleason 2024-05-23 19:52:57 +00:00
commit 9c01fc41f2
4 zmienionych plików z 32 dodań i 3 usunięć

Wyświetl plik

@ -56,6 +56,7 @@ const messages = defineMessages({
websitePlaceholder: { id: 'edit_profile.fields.website_placeholder', defaultMessage: 'Display a Link' }, websitePlaceholder: { id: 'edit_profile.fields.website_placeholder', defaultMessage: 'Display a Link' },
locationPlaceholder: { id: 'edit_profile.fields.location_placeholder', defaultMessage: 'Location' }, locationPlaceholder: { id: 'edit_profile.fields.location_placeholder', defaultMessage: 'Location' },
nip05Placeholder: { id: 'edit_profile.fields.nip05_placeholder', defaultMessage: 'user@{domain}' }, nip05Placeholder: { id: 'edit_profile.fields.nip05_placeholder', defaultMessage: 'user@{domain}' },
lud16Placeholder: { id: 'edit_profile.fields.lud16_placeholder', defaultMessage: 'user@example.com' },
cancel: { id: 'common.cancel', defaultMessage: 'Cancel' }, cancel: { id: 'common.cancel', defaultMessage: 'Cancel' },
}); });
@ -128,6 +129,11 @@ interface AccountCredentials {
birthday?: string; birthday?: string;
/** Nostr NIP-05 identifier. */ /** Nostr NIP-05 identifier. */
nip05?: string; nip05?: string;
/**
* Lightning address.
* https://github.com/lnurl/luds/blob/luds/16.md
*/
lud16?: string;
} }
/** Convert an account into an update_credentials request object. */ /** Convert an account into an update_credentials request object. */
@ -151,6 +157,7 @@ const accountToCredentials = (account: Account): AccountCredentials => {
location: account.location, location: account.location,
birthday: account.pleroma?.birthday ?? undefined, birthday: account.pleroma?.birthday ?? undefined,
nip05: account.source?.nostr?.nip05 ?? '', nip05: account.source?.nostr?.nip05 ?? '',
lud16: account?.nostr?.lud16 ?? '',
}; };
}; };
@ -354,12 +361,25 @@ const EditProfile: React.FC = () => {
</FormGroup> </FormGroup>
)} )}
{features.lightning && (
<FormGroup
labelText={<FormattedMessage id='edit_profile.fields.lud16_label' defaultMessage='Lightning Address' />}
>
<Input
type='email'
value={data.lud16}
onChange={handleTextChange('lud16')}
placeholder={intl.formatMessage(messages.lud16Placeholder)}
/>
</FormGroup>
)}
{features.accountWebsite && ( {features.accountWebsite && (
<FormGroup <FormGroup
labelText={<FormattedMessage id='edit_profile.fields.website_label' defaultMessage='Website' />} labelText={<FormattedMessage id='edit_profile.fields.website_label' defaultMessage='Website' />}
> >
<Input <Input
type='text' type='url'
value={data.website} value={data.website}
onChange={handleTextChange('website')} onChange={handleTextChange('website')}
placeholder={intl.formatMessage(messages.websitePlaceholder)} placeholder={intl.formatMessage(messages.websitePlaceholder)}

Wyświetl plik

@ -658,6 +658,8 @@
"edit_profile.fields.location_label": "Location", "edit_profile.fields.location_label": "Location",
"edit_profile.fields.location_placeholder": "Location", "edit_profile.fields.location_placeholder": "Location",
"edit_profile.fields.locked_label": "Lock account", "edit_profile.fields.locked_label": "Lock account",
"edit_profile.fields.lud16_label": "Lightning Address",
"edit_profile.fields.lud16_placeholder": "user@example.com",
"edit_profile.fields.meta_fields.content_placeholder": "Content", "edit_profile.fields.meta_fields.content_placeholder": "Content",
"edit_profile.fields.meta_fields.label_placeholder": "Label", "edit_profile.fields.meta_fields.label_placeholder": "Label",
"edit_profile.fields.meta_fields_label": "Profile fields", "edit_profile.fields.meta_fields_label": "Profile fields",

Wyświetl plik

@ -63,6 +63,7 @@ const baseAccountSchema = z.object({
]).catch(null), ]).catch(null),
nostr: coerceObject({ nostr: coerceObject({
pubkey: n.id().optional().catch(undefined), pubkey: n.id().optional().catch(undefined),
lud16: z.string().email().optional().catch(undefined),
}), }),
note: contentSchema, note: contentSchema,
/** Fedibird extra settings. */ /** Fedibird extra settings. */

Wyświetl plik

@ -184,7 +184,7 @@ const getInstanceFeatures = (instance: Instance) => {
* Ability to set one's website on their profile. * Ability to set one's website on their profile.
* @see PATCH /api/v1/accounts/update_credentials * @see PATCH /api/v1/accounts/update_credentials
*/ */
accountWebsite: v.software === TRUTHSOCIAL, accountWebsite: v.software === TRUTHSOCIAL || v.software === DITTO,
/** /**
* Ability to manage announcements by admins. * Ability to manage announcements by admins.
@ -701,6 +701,12 @@ const getInstanceFeatures = (instance: Instance) => {
v.software === PLEROMA && v.build === REBASED && gte(v.version, '2.5.54'), v.software === PLEROMA && v.build === REBASED && gte(v.version, '2.5.54'),
]), ]),
/**
* Ability to set one's lightning address on their profile.
* @see PATCH /api/v1/accounts/update_credentials
*/
lightning: v.software === DITTO,
/** /**
* Can create, view, and manage lists. * Can create, view, and manage lists.
* @see {@link https://docs.joinmastodon.org/methods/lists/} * @see {@link https://docs.joinmastodon.org/methods/lists/}