diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index c88a0d93855..bce574d47c1 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,132 +1,83 @@ -# Contributor Covenant Code of Conduct +# Contributor Covenant 3.0 Code of Conduct ## Our Pledge -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, caste, color, religion, or sexual -identity and orientation. +We pledge to make our community welcoming, safe, and equitable for all. -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. +We are committed to fostering an environment that respects and promotes the dignity, rights, and contributions of all individuals, regardless of characteristics including race, ethnicity, caste, color, age, physical characteristics, neurodiversity, disability, sex or gender, gender identity or expression, sexual orientation, language, philosophy or religion, national or social origin, socio-economic position, level of education, or other status. The same privileges of participation are extended to everyone who participates in good faith and in accordance with this Covenant. -## Our Standards +## Encouraged Behaviors -Examples of behavior that contributes to a positive environment for our -community include: +While acknowledging differences in social norms, we all strive to meet our community's expectations for positive behavior. We also understand that our words and actions may be interpreted differently than we intend based on culture, background, or native language. -- Demonstrating empathy and kindness toward other people -- Being respectful of differing opinions, viewpoints, and experiences -- Giving and gracefully accepting constructive feedback -- Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -- Focusing on what is best not just for us as individuals, but for the overall - community +With these considerations in mind, we agree to behave mindfully toward each other and act in ways that center our shared values, including: -Examples of unacceptable behavior include: +1. Respecting the **purpose of our community**, our activities, and our ways of gathering. +2. Engaging **kindly and honestly** with others. +3. Respecting **different viewpoints** and experiences. +4. **Taking responsibility** for our actions and contributions. +5. Gracefully giving and accepting **constructive feedback**. +6. Committing to **repairing harm** when it occurs. +7. Behaving in other ways that promote and sustain the **well-being of our community**. -- The use of sexualized language or imagery, and sexual attention or advances of - any kind -- Trolling, insulting or derogatory comments, and personal or political attacks -- Public or private harassment -- Publishing others' private information, such as a physical or email address, - without their explicit permission -- Other conduct which could reasonably be considered inappropriate in a - professional setting +## Restricted Behaviors -## Enforcement Responsibilities +We agree to restrict the following behaviors in our community. Instances, threats, and promotion of these behaviors are violations of this Code of Conduct. -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. +1. **Harassment.** Violating explicitly expressed boundaries or engaging in unnecessary personal attention after any clear request to stop. +2. **Character attacks.** Making insulting, demeaning, or pejorative comments directed at a community member or group of people. +3. **Stereotyping or discrimination.** Characterizing anyone’s personality or behavior on the basis of immutable identities or traits. +4. **Sexualization.** Behaving in a way that would generally be considered inappropriately intimate in the context or purpose of the community. +5. **Violating confidentiality**. Sharing or acting on someone's personal or private information without their permission. +6. **Endangerment.** Causing, encouraging, or threatening violence or other harm toward any person or group. +7. Behaving in other ways that **threaten the well-being** of our community. -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. +### Other Restrictions + +1. **Misleading identity.** Impersonating someone else for any reason, or pretending to be someone else to evade enforcement actions. +2. **Failing to credit sources.** Not properly crediting the sources of content you contribute. +3. **Promotional materials**. Sharing marketing or other commercial content in a way that is outside the norms of the community. +4. **Irresponsible communication.** Failing to responsibly present content which includes, links or describes any other restricted behaviors. + +## Reporting an Issue + +Tensions can occur between community members even when they are trying their best to collaborate. Not every conflict represents a code of conduct violation, and this Code of Conduct reinforces encouraged behaviors and norms that can help avoid conflicts and minimize harm. + +When an incident does occur, it is important to report it promptly. To report a possible violation, send an email describing the situation to hello@joinmastodon.org. + +Community Moderators take reports of violations seriously and will make every effort to respond in a timely manner. They will investigate all reports of code of conduct violations, reviewing messages, logs, and recordings, or interviewing witnesses and other participants. Community Moderators will keep investigation and enforcement actions as transparent as possible while prioritizing safety and confidentiality. In order to honor these values, enforcement actions are carried out in private with the involved parties, but communicating to the whole community may be part of a mutually agreed upon resolution. + +## Addressing and Repairing Harm + +If an investigation by the Community Moderators finds that this Code of Conduct has been violated, the following enforcement ladder may be used to determine how best to repair harm, based on the incident's impact on the individuals involved and the community as a whole. Depending on the severity of a violation, lower rungs on the ladder may be skipped. + +1. Warning + 1. Event: A violation involving a single incident or series of incidents. + 2. Consequence: A private, written warning from the Community Moderators. + 3. Repair: Examples of repair include a private written apology, acknowledgement of responsibility, and seeking clarification on expectations. +2. Temporarily Limited Activities + 1. Event: A repeated incidence of a violation that previously resulted in a warning, or the first incidence of a more serious violation. + 2. Consequence: A private, written warning with a time-limited cooldown period designed to underscore the seriousness of the situation and give the community members involved time to process the incident. The cooldown period may be limited to particular communication channels or interactions with particular community members. + 3. Repair: Examples of repair may include making an apology, using the cooldown period to reflect on actions and impact, and being thoughtful about re-entering community spaces after the period is over. +3. Temporary Suspension + 1. Event: A pattern of repeated violation which the Community Moderators have tried to address with warnings, or a single serious violation. + 2. Consequence: A private written warning with conditions for return from suspension. In general, temporary suspensions give the person being suspended time to reflect upon their behavior and possible corrective actions. + 3. Repair: Examples of repair include respecting the spirit of the suspension, meeting the specified conditions for return, and being thoughtful about how to reintegrate with the community when the suspension is lifted. +4. Permanent Ban + 1. Event: A pattern of repeated code of conduct violations that other steps on the ladder have failed to resolve, or a violation so serious that the Community Moderators determine there is no way to keep the community safe with this person as a member. + 2. Consequence: Access to all community spaces, tools, and communication channels is removed. In general, permanent bans should be rarely used, should have strong reasoning behind them, and should only be resorted to if working through other remedies has failed to change the behavior. + 3. Repair: There is no possible repair in cases of this severity. + +This enforcement ladder is intended as a guideline. It does not limit the ability of Community Managers to use their discretion and judgment, in keeping with the best interests of our community. ## Scope -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at -[hello@joinmastodon.org](mailto:hello@joinmastodon.org). -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of -actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or permanent -ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the -community. +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public or other spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.1, available at -[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. +This Code of Conduct is adapted from the Contributor Covenant, version 3.0, permanently available at [https://www.contributor-covenant.org/version/3/0/](https://www.contributor-covenant.org/version/3/0/). -Community Impact Guidelines were inspired by -[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. +Contributor Covenant is stewarded by the Organization for Ethical Source and licensed under CC BY-SA 4.0. To view a copy of this license, visit [https://creativecommons.org/licenses/by-sa/4.0/](https://creativecommons.org/licenses/by-sa/4.0/) -For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at -[https://www.contributor-covenant.org/translations][translations]. - -[homepage]: https://www.contributor-covenant.org -[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html -[Mozilla CoC]: https://github.com/mozilla/diversity -[FAQ]: https://www.contributor-covenant.org/faq -[translations]: https://www.contributor-covenant.org/translations +For answers to common questions about Contributor Covenant, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are provided at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations). Additional enforcement and community guideline resources can be found at [https://www.contributor-covenant.org/resources](https://www.contributor-covenant.org/resources). The enforcement ladder was inspired by the work of [Mozilla’s code of conduct team](https://github.com/mozilla/inclusion). diff --git a/app/controllers/api/v1/accounts/email_subscriptions_controller.rb b/app/controllers/api/v1/accounts/email_subscriptions_controller.rb index dcdd41f6db9..4e773f902bc 100644 --- a/app/controllers/api/v1/accounts/email_subscriptions_controller.rb +++ b/app/controllers/api/v1/accounts/email_subscriptions_controller.rb @@ -8,6 +8,8 @@ class Api::V1::Accounts::EmailSubscriptionsController < Api::BaseController def create @account.email_subscriptions.create!(email: params[:email], locale: I18n.locale) render_empty + rescue ActiveRecord::RecordInvalid => e + render json: ValidationErrorFormatter.new(e).as_json, status: 422 end private diff --git a/app/controllers/concerns/signature_verification.rb b/app/controllers/concerns/signature_verification.rb index f752e5cd93c..49b72872390 100644 --- a/app/controllers/concerns/signature_verification.rb +++ b/app/controllers/concerns/signature_verification.rb @@ -101,7 +101,7 @@ module SignatureVerification end if key_id.start_with?('acct:') - stoplight_wrapper.run { ResolveAccountService.new.call(key_id.delete_prefix('acct:'), suppress_errors: false) } + stoplight_wrapper.run { fetch_key_from_acct(key_id.delete_prefix('acct:')) } elsif !ActivityPub::TagManager.instance.local_uri?(key_id) keypair = Keypair.from_keyid(key_id) return keypair if keypair.present? @@ -114,6 +114,15 @@ module SignatureVerification raise Mastodon::SignatureVerificationError, e.message end + def fetch_key_from_acct(acct) + # This is legacy and can't let us pick a specific key, so pick the first + + account = ResolveAccountService.new.call(acct, suppress_errors: false) + return if account.nil? + + account.keypairs.first || Keypair.from_legacy_account(account) + end + def stoplight_wrapper Stoplight( "source:#{request.remote_ip}", diff --git a/app/javascript/mastodon/api/accounts.ts b/app/javascript/mastodon/api/accounts.ts index fc6e38fbc8d..2229d17c560 100644 --- a/app/javascript/mastodon/api/accounts.ts +++ b/app/javascript/mastodon/api/accounts.ts @@ -75,3 +75,6 @@ export const apiDeleteProfileAvatar = () => export const apiDeleteProfileHeader = () => apiRequestDelete('v1/profile/header'); + +export const apiSubscribeByEmail = (id: string, email: string) => + apiRequestPost(`v1/accounts/${id}/email_subscriptions`, { email }); diff --git a/app/javascript/mastodon/api_types/accounts.ts b/app/javascript/mastodon/api_types/accounts.ts index 351f3245cc6..0a5e847e8ea 100644 --- a/app/javascript/mastodon/api_types/accounts.ts +++ b/app/javascript/mastodon/api_types/accounts.ts @@ -68,6 +68,7 @@ export interface BaseApiAccountJSON { limited?: boolean; memorial?: boolean; hide_collections: boolean; + email_subscriptions?: boolean; } // See app/serializers/rest/muted_account_serializer.rb diff --git a/app/javascript/mastodon/api_types/errors.ts b/app/javascript/mastodon/api_types/errors.ts new file mode 100644 index 00000000000..46f8e0b8cda --- /dev/null +++ b/app/javascript/mastodon/api_types/errors.ts @@ -0,0 +1,22 @@ +export type ErrorToken = + | 'ERR_TAKEN' + | 'ERR_INVALID' + | 'ERR_BLOCKED' + | 'ERR_RESERVED' + | 'ERR_TOO_MANY' + | 'ERR_MALFORMED' + | 'ERR_UNUSABLE' + | 'ERR_TOO_SOON' + | 'ERR_BELOW_LIMIT' + | 'ERR_UNREACHABLE' + | 'ERR_ELEVATED'; + +export interface ValidationError { + error: ErrorToken; + description: string; +} + +export interface ValidationErrorResponse { + error: string; + details: Record; +} diff --git a/app/javascript/mastodon/components/follow_button.tsx b/app/javascript/mastodon/components/follow_button.tsx index 14f2d62d9aa..4f8b1b0bea2 100644 --- a/app/javascript/mastodon/components/follow_button.tsx +++ b/app/javascript/mastodon/components/follow_button.tsx @@ -6,7 +6,6 @@ import classNames from 'classnames'; import { Link } from 'react-router-dom'; import { useIdentity } from '@/mastodon/identity_context'; -import { isServerFeatureEnabled } from '@/mastodon/utils/environment'; import { fetchRelationships, followAccount, @@ -171,23 +170,10 @@ export const FollowButton: React.FC<{ 'button--compact': compact, }); - if (isServerFeatureEnabled('profile_redesign')) { - return ( - - {label} - - ); - } - return ( - + {label} - + ); } diff --git a/app/javascript/mastodon/components/number_fields/styles.module.scss b/app/javascript/mastodon/components/number_fields/styles.module.scss index 085bd5051dd..e61ace82350 100644 --- a/app/javascript/mastodon/components/number_fields/styles.module.scss +++ b/app/javascript/mastodon/components/number_fields/styles.module.scss @@ -23,6 +23,7 @@ a { padding: 0; + text-decoration: none; &:hover, &:focus { diff --git a/app/javascript/mastodon/components/status/header.tsx b/app/javascript/mastodon/components/status/header.tsx index 65790bb4932..9b1445e9c1c 100644 --- a/app/javascript/mastodon/components/status/header.tsx +++ b/app/javascript/mastodon/components/status/header.tsx @@ -56,7 +56,10 @@ export const StatusHeader: FC = ({ className='status__relative-time' > - + {editedAt && } diff --git a/app/javascript/mastodon/features/account_edit/modals/fields_modals.tsx b/app/javascript/mastodon/features/account_edit/modals/fields_modals.tsx index 0a4c64d9c4a..d0f67ddc62c 100644 --- a/app/javascript/mastodon/features/account_edit/modals/fields_modals.tsx +++ b/app/javascript/mastodon/features/account_edit/modals/fields_modals.tsx @@ -210,7 +210,7 @@ export const EditFieldModal = forwardRef< const labelStatus = checkField(newLabel); const valueStatus = checkField(newValue); - if (labelStatus || valueStatus) { + if (labelStatus?.variant === 'error' || valueStatus?.variant === 'error') { setFieldStatuses({ label: labelStatus ?? undefined, value: valueStatus ?? undefined, diff --git a/app/javascript/mastodon/features/account_edit/styles.module.scss b/app/javascript/mastodon/features/account_edit/styles.module.scss index cd3d34f31b7..1ca1e4646c3 100644 --- a/app/javascript/mastodon/features/account_edit/styles.module.scss +++ b/app/javascript/mastodon/features/account_edit/styles.module.scss @@ -182,6 +182,11 @@ // Field component +.fieldName, +.fieldValue { + word-break: break-all; +} + .fieldName { color: var(--color-text-secondary); font-size: 13px; diff --git a/app/javascript/mastodon/features/account_featured/index.tsx b/app/javascript/mastodon/features/account_featured/index.tsx index 0d9adfe3146..937a200e1cc 100644 --- a/app/javascript/mastodon/features/account_featured/index.tsx +++ b/app/javascript/mastodon/features/account_featured/index.tsx @@ -7,7 +7,6 @@ import { useHistory } from 'react-router'; import { List as ImmutableList } from 'immutable'; import { useAccount } from '@/mastodon/hooks/useAccount'; -import { isServerFeatureEnabled } from '@/mastodon/utils/environment'; import { fetchEndorsedAccounts } from 'mastodon/actions/accounts'; import { fetchFeaturedTags } from 'mastodon/actions/featured_tags'; import { Account } from 'mastodon/components/account'; @@ -49,11 +48,7 @@ const AccountFeatured: React.FC<{ multiColumn: boolean }> = ({ const history = useHistory(); useEffect(() => { - if ( - account && - !account.show_featured && - isServerFeatureEnabled('profile_redesign') - ) { + if (account && !account.show_featured) { history.push(`/@${account.acct}`); } }, [account, history]); @@ -111,8 +106,7 @@ const AccountFeatured: React.FC<{ multiColumn: boolean }> = ({ ); } - const noTags = - featuredTags.isEmpty() || isServerFeatureEnabled('profile_redesign'); + const noTags = featuredTags.isEmpty(); if ( noTags && diff --git a/app/javascript/mastodon/features/account_gallery/index.tsx b/app/javascript/mastodon/features/account_gallery/index.tsx index 2a69342a467..069f1242f70 100644 --- a/app/javascript/mastodon/features/account_gallery/index.tsx +++ b/app/javascript/mastodon/features/account_gallery/index.tsx @@ -4,7 +4,6 @@ import { FormattedMessage } from 'react-intl'; import { List as ImmutableList, isList } from 'immutable'; -import { isServerFeatureEnabled } from '@/mastodon/utils/environment'; import { openModal } from 'mastodon/actions/modal'; import { expandAccountMediaTimeline } from 'mastodon/actions/timelines'; import { ColumnBackButton } from 'mastodon/components/column_back_button'; @@ -27,8 +26,6 @@ import { MediaItem } from './components/media_item'; const emptyList = ImmutableList(); -const redesignEnabled = isServerFeatureEnabled('profile_redesign'); - const selectGalleryTimeline = createAppSelector( [ (_state, accountId?: string | null) => accountId, @@ -58,7 +55,7 @@ const selectGalleryTimeline = createAppSelector( const { show_media, show_media_replies } = account; // If the account disabled showing media, don't display anything. - if (!show_media && redesignEnabled) { + if (!show_media) { return { items, hasMore: false, @@ -67,7 +64,7 @@ const selectGalleryTimeline = createAppSelector( }; } - const withReplies = show_media_replies && redesignEnabled; + const withReplies = show_media_replies; const timeline = timelines.get( `account:${accountId}:media${withReplies ? ':with_replies' : ''}`, ); @@ -225,7 +222,7 @@ export const AccountGallery: React.FC<{ alwaysPrepend append={accountId && } scrollKey='account_gallery' - showLoading={isLoading} + isLoading={isLoading} hasMore={!forceEmptyState && hasMore} onLoadMore={handleLoadMore} emptyMessage={emptyMessage} diff --git a/app/javascript/mastodon/features/account_timeline/common.ts b/app/javascript/mastodon/features/account_timeline/common.ts index 7a939bbec9d..b036530e14d 100644 --- a/app/javascript/mastodon/features/account_timeline/common.ts +++ b/app/javascript/mastodon/features/account_timeline/common.ts @@ -1,9 +1,4 @@ import type { AccountFieldShape } from '@/mastodon/models/account'; -import { isServerFeatureEnabled } from '@/mastodon/utils/environment'; - -export function isRedesignEnabled() { - return isServerFeatureEnabled('profile_redesign'); -} export interface AccountField extends AccountFieldShape { nameHasEmojis: boolean; diff --git a/app/javascript/mastodon/features/account_timeline/components/account_header.tsx b/app/javascript/mastodon/features/account_timeline/components/account_header.tsx index 6a9d51f737c..90b0127e15d 100644 --- a/app/javascript/mastodon/features/account_timeline/components/account_header.tsx +++ b/app/javascript/mastodon/features/account_timeline/components/account_header.tsx @@ -7,7 +7,6 @@ import { openModal } from '@/mastodon/actions/modal'; import { AccountBio } from '@/mastodon/components/account_bio'; import { Avatar } from '@/mastodon/components/avatar'; import { AnimateEmojiProvider } from '@/mastodon/components/emoji/context'; -import { AccountNote } from '@/mastodon/features/account/components/account_note'; import FollowRequestNoteContainer from '@/mastodon/features/account/containers/follow_request_note_container'; import { useLayout } from '@/mastodon/hooks/useLayout'; import { useVisibility } from '@/mastodon/hooks/useVisibility'; @@ -20,14 +19,12 @@ import type { Account } from '@/mastodon/models/account'; import { getAccountHidden } from '@/mastodon/selectors/accounts'; import { useAppSelector, useAppDispatch } from '@/mastodon/store'; -import { isRedesignEnabled } from '../common'; - import { AccountName } from './account_name'; +import { AccountSubscriptionForm } from './account_subscription_form'; import { AccountBadges } from './badges'; import { AccountButtons } from './buttons'; import { FamiliarFollowers } from './familiar_followers'; import { AccountHeaderFields } from './fields'; -import { AccountInfo } from './info'; import { MemorialNote } from './memorial_note'; import { MovedNote } from './moved_note'; import { AccountNote as AccountNoteRedesign } from './note'; @@ -51,8 +48,6 @@ export const AccountHeader: React.FC<{ accountId: string; hideTabs?: boolean; }> = ({ accountId, hideTabs }) => { - const isRedesign = isRedesignEnabled(); - const dispatch = useAppDispatch(); const account = useAppSelector((state) => state.accounts.get(accountId)); const relationship = useAppSelector((state) => @@ -119,13 +114,9 @@ export const AccountHeader: React.FC<{
- {me !== account.id && relationship && !isRedesign && ( - - )} - {!suspendedOrHidden && (
- - {!isRedesign && ( - - )}
- {isRedesign && ( - - )} +
@@ -191,54 +173,45 @@ export const AccountHeader: React.FC<{ )} - {!isRedesign && ( - - )} - {!suspendedOrHidden && (
- {me && - account.id !== me && - (isRedesign ? ( - - ) : ( - - ))} + {me && account.id !== me && ( + + )} +
+ {!me && account.email_subscriptions && ( + + )} +
)} - {isRedesign && ( - - )} +
- {!hideTabs && !hidden && } + {!hideTabs && !hidden && }
diff --git a/app/javascript/mastodon/features/account_timeline/components/account_name.tsx b/app/javascript/mastodon/features/account_timeline/components/account_name.tsx index ac6ab2735e2..3fd9e30c286 100644 --- a/app/javascript/mastodon/features/account_timeline/components/account_name.tsx +++ b/app/javascript/mastodon/features/account_timeline/components/account_name.tsx @@ -14,10 +14,6 @@ import { useAppSelector } from '@/mastodon/store'; import AtIcon from '@/material-icons/400-24px/alternate_email.svg?react'; import HelpIcon from '@/material-icons/400-24px/help.svg?react'; import DomainIcon from '@/material-icons/400-24px/language.svg?react'; -import LockIcon from '@/material-icons/400-24px/lock.svg?react'; - -import { DomainPill } from '../../account/components/domain_pill'; -import { isRedesignEnabled } from '../common'; import classes from './redesign.module.scss'; @@ -34,7 +30,6 @@ const messages = defineMessages({ }); export const AccountName: FC<{ accountId: string }> = ({ accountId }) => { - const intl = useIntl(); const account = useAccount(accountId); const me = useAppSelector((state) => state.meta.get('me') as string); const localDomain = useAppSelector( @@ -47,32 +42,6 @@ export const AccountName: FC<{ accountId: string }> = ({ accountId }) => { const [username = '', domain = localDomain] = account.acct.split('@'); - if (!isRedesignEnabled()) { - return ( -

- - - - @{username} - @{domain} - - - {account.locked && ( - - )} - -

- ); - } - return (

diff --git a/app/javascript/mastodon/features/account_timeline/components/account_subscription_form.tsx b/app/javascript/mastodon/features/account_timeline/components/account_subscription_form.tsx new file mode 100644 index 00000000000..d183aa1cb30 --- /dev/null +++ b/app/javascript/mastodon/features/account_timeline/components/account_subscription_form.tsx @@ -0,0 +1,207 @@ +import { useState, useCallback, useId } from 'react'; + +import { FormattedMessage, useIntl, defineMessages } from 'react-intl'; +import type { IntlShape } from 'react-intl'; + +import { Link } from 'react-router-dom'; + +import { AxiosError } from 'axios'; + +import { apiSubscribeByEmail } from 'mastodon/api/accounts'; +import type { + ValidationErrorResponse, + ValidationError, +} from 'mastodon/api_types/errors'; +import { A11yLiveRegion } from 'mastodon/components/a11y_live_region'; +import { Button } from 'mastodon/components/button'; +import { CalloutInline } from 'mastodon/components/callout_inline'; +import { DisplayName } from 'mastodon/components/display_name'; +import type { FieldStatus } from 'mastodon/components/form_fields'; +import formFieldClasses from 'mastodon/components/form_fields/form_field_wrapper.module.scss'; +import { TextInput } from 'mastodon/components/form_fields/text_input_field'; +import { useAppSelector } from 'mastodon/store'; + +import classes from './redesign.module.scss'; + +const messages = defineMessages({ + emailInvalid: { + id: 'email_subscriptions.validation.email.invalid', + defaultMessage: 'Invalid email address', + }, + emailBlocked: { + id: 'email_subscriptions.validation.email.blocked', + defaultMessage: 'Blocked email provider', + }, + email: { + id: 'email_subscriptions.email', + defaultMessage: 'Email address', + }, +}); + +const isValidationErrorResponse = ( + data: unknown, +): data is ValidationErrorResponse => + typeof data === 'object' && + data !== null && + 'error' in data && + 'details' in data; + +const fieldStatusFromErrors = ( + intl: IntlShape, + errors: ValidationError[], +): FieldStatus | undefined => { + const error = errors[0]; + + if (!error) { + return undefined; + } + + let message: string; + + switch (error.error) { + case 'ERR_BLOCKED': + message = intl.formatMessage(messages.emailBlocked); + break; + case 'ERR_INVALID': + default: + message = intl.formatMessage(messages.emailInvalid); + break; + } + + return { variant: 'error', message }; +}; + +export const AccountSubscriptionForm: React.FC<{ accountId: string }> = ({ + accountId, +}) => { + const account = useAppSelector((state) => state.accounts.get(accountId)); + const intl = useIntl(); + const accessibilityId = useId(); + + const [email, setEmail] = useState(''); + const [submitting, setSubmitting] = useState(false); + const [submitted, setSubmitted] = useState(false); + const [errors, setErrors] = useState>({}); + + const handleChange = useCallback>( + (e) => { + setEmail(e.target.value); + setErrors({}); + }, + [], + ); + + const handleSubmit = useCallback( + (e) => { + e.preventDefault(); + + if (email.length === 0) { + return; + } + + setSubmitting(true); + + apiSubscribeByEmail(accountId, email) + .then(() => { + setSubmitting(false); + setSubmitted(true); + + return ''; + }) + .catch((err: unknown) => { + setSubmitting(false); + + if (err instanceof AxiosError && err.response) { + const data: unknown = err.response.data; + + if (isValidationErrorResponse(data)) { + if (data.details.email?.some((k) => k.error === 'ERR_TAKEN')) { + setSubmitted(true); + return; + } + + setErrors(data.details); + } + } + }); + }, + [accountId, email], + ); + + if (submitted) { + return ( +
+
+

+ +

+ +
+
+ ); + } + + return ( +
+
+

+ , + }} + /> +

+ +
+ +
+
+ + + + {errors.email && ( + + )} + +
+ + +
+ +
+ {str} }} + /> +
+
+ ); +}; diff --git a/app/javascript/mastodon/features/account_timeline/components/badges.tsx b/app/javascript/mastodon/features/account_timeline/components/badges.tsx index 9bfc3b5da53..75e0c31a183 100644 --- a/app/javascript/mastodon/features/account_timeline/components/badges.tsx +++ b/app/javascript/mastodon/features/account_timeline/components/badges.tsx @@ -20,8 +20,6 @@ import { useAccount } from '@/mastodon/hooks/useAccount'; import type { AccountRole } from '@/mastodon/models/account'; import { useAppDispatch, useAppSelector } from '@/mastodon/store'; -import { isRedesignEnabled } from '../common'; - import classes from './redesign.module.scss'; export const AccountBadges: FC<{ accountId: string }> = ({ accountId }) => { @@ -46,9 +44,6 @@ export const AccountBadges: FC<{ accountId: string }> = ({ accountId }) => { return null; } - const isRedesign = isRedesignEnabled(); - const className = isRedesign ? classes.badge : ''; - const domain = account.acct.includes('@') ? account.acct.split('@')[1] : localDomain; @@ -58,7 +53,7 @@ export const AccountBadges: FC<{ accountId: string }> = ({ accountId }) => { , @@ -68,8 +63,8 @@ export const AccountBadges: FC<{ accountId: string }> = ({ accountId }) => { , ); @@ -77,17 +72,17 @@ export const AccountBadges: FC<{ accountId: string }> = ({ accountId }) => { }); if (account.bot) { - badges.push(); + badges.push(); } if (account.group) { - badges.push(); + badges.push(); } - if (isRedesign && relationship) { + if (relationship) { if (relationship.blocking) { badges.push( , ); } @@ -95,7 +90,7 @@ export const AccountBadges: FC<{ accountId: string }> = ({ accountId }) => { badges.push( = ({ accountId }) => { badges.push( , ); @@ -136,5 +131,5 @@ export const PinnedBadge: FC = () => ( function isAdminBadge(role: AccountRole) { const name = role.name.toLowerCase(); - return isRedesignEnabled() && (name === 'admin' || name === 'owner'); + return name === 'admin' || name === 'owner'; } diff --git a/app/javascript/mastodon/features/account_timeline/components/buttons.tsx b/app/javascript/mastodon/features/account_timeline/components/buttons.tsx index fe0bbbfbd62..0c24207b6ab 100644 --- a/app/javascript/mastodon/features/account_timeline/components/buttons.tsx +++ b/app/javascript/mastodon/features/account_timeline/components/buttons.tsx @@ -16,8 +16,6 @@ import NotificationsIcon from '@/material-icons/400-24px/notifications.svg?react import NotificationsActiveIcon from '@/material-icons/400-24px/notifications_active-fill.svg?react'; import ShareIcon from '@/material-icons/400-24px/share.svg?react'; -import { isRedesignEnabled } from '../common'; - import { AccountMenu } from './menu'; const messages = defineMessages({ @@ -97,7 +95,6 @@ const AccountButtonsOther: FC< accountId={accountId} className='account__header__follow-button' labelLength='long' - withUnmute={!isRedesignEnabled()} /> )} {isFollowing && ( diff --git a/app/javascript/mastodon/features/account_timeline/components/fields.tsx b/app/javascript/mastodon/features/account_timeline/components/fields.tsx index 5bad90aaaeb..80d6cc7f679 100644 --- a/app/javascript/mastodon/features/account_timeline/components/fields.tsx +++ b/app/javascript/mastodon/features/account_timeline/components/fields.tsx @@ -1,68 +1,30 @@ import { useCallback, useMemo, useRef, useState } from 'react'; import type { FC } from 'react'; -import { defineMessage, FormattedMessage, useIntl } from 'react-intl'; +import { defineMessage, useIntl } from 'react-intl'; import classNames from 'classnames'; import IconVerified from '@/images/icons/icon_verified.svg?react'; import { openModal } from '@/mastodon/actions/modal'; -import { AccountFields } from '@/mastodon/components/account_fields'; import { CustomEmojiProvider } from '@/mastodon/components/emoji/context'; import type { EmojiHTMLProps } from '@/mastodon/components/emoji/html'; import { EmojiHTML } from '@/mastodon/components/emoji/html'; -import { FormattedDateWrapper } from '@/mastodon/components/formatted_date'; import { Icon } from '@/mastodon/components/icon'; import { IconButton } from '@/mastodon/components/icon_button'; import { MiniCard } from '@/mastodon/components/mini_card'; import { useElementHandledLink } from '@/mastodon/components/status/handled_link'; import { useAccount } from '@/mastodon/hooks/useAccount'; import { useResizeObserver } from '@/mastodon/hooks/useObserver'; -import type { Account } from '@/mastodon/models/account'; import { useAppDispatch } from '@/mastodon/store'; import MoreIcon from '@/material-icons/400-24px/more_horiz.svg?react'; import { cleanExtraEmojis } from '../../emoji/normalize'; import type { AccountField } from '../common'; -import { isRedesignEnabled } from '../common'; import { useFieldHtml } from '../hooks/useFieldHtml'; import classes from './redesign.module.scss'; -export const AccountHeaderFields: FC<{ accountId: string }> = ({ - accountId, -}) => { - const account = useAccount(accountId); - - if (!account) { - return null; - } - - if (isRedesignEnabled()) { - return ; - } - - return ( -
-
-
- -
-
- -
-
- - -
- ); -}; - const verifyMessage = defineMessage({ id: 'account.link_verified_on', defaultMessage: 'Ownership of this link was checked on {date}', @@ -75,13 +37,22 @@ const dateFormatOptions: Intl.DateTimeFormatOptions = { minute: '2-digit', }; -const RedesignAccountHeaderFields: FC<{ account: Account }> = ({ account }) => { +export const AccountHeaderFields: FC<{ accountId: string }> = ({ + accountId, +}) => { + const account = useAccount(accountId); + const emojis = useMemo( - () => cleanExtraEmojis(account.emojis), - [account.emojis], + () => cleanExtraEmojis(account?.emojis), + [account?.emojis], ); + const accountFields = account?.fields; const fields: AccountField[] = useMemo(() => { - const fields = account.fields.toJS(); + const fields = accountFields?.toJS(); + if (!fields) { + return []; + } + if (!emojis) { return fields.map((field) => ({ ...field, @@ -102,10 +73,10 @@ const RedesignAccountHeaderFields: FC<{ account: Account }> = ({ account }) => { field.value_plain?.includes(`:${code}:`), ), })); - }, [account.fields, emojis]); + }, [accountFields, emojis]); const htmlHandlers = useElementHandledLink({ - hashtagAccountId: account.id, + hashtagAccountId: account?.id, }); const { wrapperRef } = useColumnWrap(); diff --git a/app/javascript/mastodon/features/account_timeline/components/menu.tsx b/app/javascript/mastodon/features/account_timeline/components/menu.tsx index cd1ec82e4fa..24ef0912976 100644 --- a/app/javascript/mastodon/features/account_timeline/components/menu.tsx +++ b/app/javascript/mastodon/features/account_timeline/components/menu.tsx @@ -40,8 +40,6 @@ import PersonRemoveIcon from '@/material-icons/400-24px/person_remove.svg?react' import ReportIcon from '@/material-icons/400-24px/report.svg?react'; import ShareIcon from '@/material-icons/400-24px/share.svg?react'; -import { isRedesignEnabled } from '../common'; - import classes from './redesign.module.scss'; export const AccountMenu: FC<{ accountId: string }> = ({ accountId }) => { @@ -63,19 +61,9 @@ export const AccountMenu: FC<{ accountId: string }> = ({ accountId }) => { return []; } - if (isRedesignEnabled()) { - return redesignMenuItems({ - account, - signedIn: !isMe && signedIn, - permissions, - intl, - relationship, - dispatch, - }); - } - return currentMenuItems({ + return redesignMenuItems({ account, - signedIn, + signedIn: !isMe && signedIn, permissions, intl, relationship, @@ -178,269 +166,6 @@ const messages = defineMessages({ }, }); -function currentMenuItems({ - account, - signedIn, - permissions, - intl, - relationship, - dispatch, -}: MenuItemsParams): MenuItem[] { - const items: MenuItem[] = []; - const isRemote = account.acct !== account.username; - - if (signedIn && !account.suspended) { - items.push( - { - text: intl.formatMessage(messages.mention, { - name: account.username, - }), - action: () => { - dispatch(mentionCompose(account)); - }, - }, - { - text: intl.formatMessage(messages.direct, { - name: account.username, - }), - action: () => { - dispatch(directCompose(account)); - }, - }, - null, - ); - } - - if (isRemote) { - items.push( - { - text: intl.formatMessage(messages.openOriginalPage), - href: account.url, - }, - null, - ); - } - - if (!signedIn) { - return items; - } - - if (relationship?.following) { - // Timeline options - if (!relationship.muting) { - if (relationship.showing_reblogs) { - items.push({ - text: intl.formatMessage(messages.hideReblogs, { - name: account.username, - }), - action: () => { - dispatch(followAccount(account.id, { reblogs: false })); - }, - }); - } else { - items.push({ - text: intl.formatMessage(messages.showReblogs, { - name: account.username, - }), - action: () => { - dispatch(followAccount(account.id, { reblogs: true })); - }, - }); - } - - items.push( - { - text: intl.formatMessage(messages.languages), - action: () => { - dispatch( - openModal({ - modalType: 'SUBSCRIBED_LANGUAGES', - modalProps: { - accountId: account.id, - }, - }), - ); - }, - }, - null, - ); - } - - items.push( - { - text: intl.formatMessage( - relationship.endorsed ? messages.unendorse : messages.endorse, - ), - action: () => { - if (relationship.endorsed) { - dispatch(unpinAccount(account.id)); - } else { - dispatch(pinAccount(account.id)); - } - }, - }, - { - text: intl.formatMessage(messages.add_or_remove_from_list), - action: () => { - dispatch( - openModal({ - modalType: 'LIST_ADDER', - modalProps: { - accountId: account.id, - }, - }), - ); - }, - }, - null, - ); - } - - if (relationship?.followed_by) { - const handleRemoveFromFollowers = () => { - dispatch( - openModal({ - modalType: 'CONFIRM', - modalProps: { - title: intl.formatMessage(messages.confirmRemoveFromFollowersTitle), - message: intl.formatMessage( - messages.confirmRemoveFromFollowersMessage, - { name: {account.acct} }, - ), - confirm: intl.formatMessage( - messages.confirmRemoveFromFollowersButton, - ), - onConfirm: () => { - void dispatch( - removeAccountFromFollowers({ accountId: account.id }), - ); - }, - }, - }), - ); - }; - - items.push({ - text: intl.formatMessage(messages.removeFromFollowers, { - name: account.username, - }), - action: handleRemoveFromFollowers, - dangerous: true, - }); - } - - if (relationship?.muting) { - items.push({ - text: intl.formatMessage(messages.unmute, { - name: account.username, - }), - action: () => { - dispatch(unmuteAccount(account.id)); - }, - }); - } else { - items.push({ - text: intl.formatMessage(messages.mute, { - name: account.username, - }), - action: () => { - dispatch(initMuteModal(account)); - }, - dangerous: true, - }); - } - - if (relationship?.blocking) { - items.push({ - text: intl.formatMessage(messages.unblock, { - name: account.username, - }), - action: () => { - dispatch(unblockAccount(account.id)); - }, - }); - } else { - items.push({ - text: intl.formatMessage(messages.block, { - name: account.username, - }), - action: () => { - dispatch(blockAccount(account.id)); - }, - dangerous: true, - }); - } - - if (!account.suspended) { - items.push({ - text: intl.formatMessage(messages.report, { - name: account.username, - }), - action: () => { - dispatch(initReport(account)); - }, - dangerous: true, - }); - } - - const remoteDomain = isRemote ? account.acct.split('@')[1] : null; - if (remoteDomain) { - items.push(null); - - if (relationship?.domain_blocking) { - items.push({ - text: intl.formatMessage(messages.unblockDomain, { - domain: remoteDomain, - }), - action: () => { - dispatch(unblockDomain(remoteDomain)); - }, - }); - } else { - items.push({ - text: intl.formatMessage(messages.blockDomain, { - domain: remoteDomain, - }), - action: () => { - dispatch(initDomainBlockModal(account)); - }, - dangerous: true, - }); - } - } - - if ( - (permissions & PERMISSION_MANAGE_USERS) === PERMISSION_MANAGE_USERS || - (isRemote && - (permissions & PERMISSION_MANAGE_FEDERATION) === - PERMISSION_MANAGE_FEDERATION) - ) { - items.push(null); - if ((permissions & PERMISSION_MANAGE_USERS) === PERMISSION_MANAGE_USERS) { - items.push({ - text: intl.formatMessage(messages.admin_account, { - name: account.username, - }), - href: `/admin/accounts/${account.id}`, - }); - } - if ( - isRemote && - (permissions & PERMISSION_MANAGE_FEDERATION) === - PERMISSION_MANAGE_FEDERATION - ) { - items.push({ - text: intl.formatMessage(messages.admin_domain, { - domain: remoteDomain, - }), - href: `/admin/instances/${remoteDomain}`, - }); - } - } - - return items; -} - const redesignMessages = defineMessages({ share: { id: 'account.menu.share', defaultMessage: 'Share…' }, copy: { id: 'account.menu.copy', defaultMessage: 'Copy link' }, diff --git a/app/javascript/mastodon/features/account_timeline/components/number_fields.tsx b/app/javascript/mastodon/features/account_timeline/components/number_fields.tsx index 0fa805ac6ba..385ba2d28ab 100644 --- a/app/javascript/mastodon/features/account_timeline/components/number_fields.tsx +++ b/app/javascript/mastodon/features/account_timeline/components/number_fields.tsx @@ -3,13 +3,6 @@ import type { FC } from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; -import { NavLink } from 'react-router-dom'; - -import { - FollowersCounter, - FollowingCounter, - StatusesCounter, -} from '@/mastodon/components/counters'; import { FormattedDateWrapper } from '@/mastodon/components/formatted_date'; import { NumberFields, @@ -18,54 +11,9 @@ import { import { ShortNumber } from '@/mastodon/components/short_number'; import { useAccount } from '@/mastodon/hooks/useAccount'; -import { isRedesignEnabled } from '../common'; - -const LegacyNumberFields: FC<{ accountId: string }> = ({ accountId }) => { - const intl = useIntl(); - const account = useAccount(accountId); - - if (!account) { - return null; - } - - return ( -
- - - - - - - - - - - -
- ); -}; - -const RedesignNumberFields: FC<{ accountId: string }> = ({ accountId }) => { +export const AccountNumberFields: FC<{ accountId: string }> = ({ + accountId, +}) => { const intl = useIntl(); const account = useAccount(accountId); const createdThisYear = useMemo( @@ -125,7 +73,3 @@ const RedesignNumberFields: FC<{ accountId: string }> = ({ accountId }) => { ); }; - -export const AccountNumberFields = isRedesignEnabled() - ? RedesignNumberFields - : LegacyNumberFields; diff --git a/app/javascript/mastodon/features/account_timeline/components/redesign.module.scss b/app/javascript/mastodon/features/account_timeline/components/redesign.module.scss index 391a6ac7fe7..11446104a35 100644 --- a/app/javascript/mastodon/features/account_timeline/components/redesign.module.scss +++ b/app/javascript/mastodon/features/account_timeline/components/redesign.module.scss @@ -391,3 +391,65 @@ svg.badgeIcon { padding-bottom: 14px; } } + +.bannerBase { + box-sizing: border-box; + padding: 16px; + border-radius: 12px; + background: var(--color-bg-secondary); + display: flex; + flex-direction: column; + gap: 12px; + justify-content: center; + align-items: flex-start; + margin: 16px 0; +} + +.bannerTextAndActions { + display: flex; + flex-direction: column; + gap: 4px; + font-size: 13px; + font-weight: 400; + color: var(--color-text-primary); + + h2 { + font-size: 17px; + font-weight: 600; + } +} + +.bannerDisclaimer { + color: var(--color-text-secondary); + font-size: 11px; + + a { + color: inherit; + } +} + +.bannerBaseCentered { + composes: bannerBase; + min-height: 146px; + align-items: center; + + .bannerTextAndActions { + text-align: center; + } +} + +.bannerInputButton { + display: flex; + gap: 8px; + align-self: stretch; + align-items: flex-start; + + & > div { + flex-grow: 1; + } + + input[type='email'] { + padding: 7px 8px; // To align size with button + background: var(--color-bg-primary); + } +} diff --git a/app/javascript/mastodon/features/account_timeline/components/tabs.tsx b/app/javascript/mastodon/features/account_timeline/components/tabs.tsx index 5febb8eaf8c..021005d7449 100644 --- a/app/javascript/mastodon/features/account_timeline/components/tabs.tsx +++ b/app/javascript/mastodon/features/account_timeline/components/tabs.tsx @@ -8,40 +8,13 @@ import { NavLink } from 'react-router-dom'; import { useAccount } from '@/mastodon/hooks/useAccount'; import { useAccountId } from '@/mastodon/hooks/useAccountId'; -import { isRedesignEnabled } from '../common'; - import classes from './redesign.module.scss'; -export const AccountTabs: FC<{ acct: string }> = ({ acct }) => { - if (isRedesignEnabled()) { - return ; - } - return ( -
- - - - - - - - - - - - -
- ); -}; - const isActive: Required['isActive'] = (match, location) => match?.url === location.pathname || (!!match?.url && location.pathname.startsWith(`${match.url}/tagged/`)); -const RedesignTabs: FC = () => { +export const AccountTabs: FC = () => { const accountId = useAccountId(); const account = useAccount(accountId); diff --git a/app/javascript/mastodon/features/account_timeline/modals/field_modal.tsx b/app/javascript/mastodon/features/account_timeline/modals/field_modal.tsx index c778e08fa26..9c09be8e2bf 100644 --- a/app/javascript/mastodon/features/account_timeline/modals/field_modal.tsx +++ b/app/javascript/mastodon/features/account_timeline/modals/field_modal.tsx @@ -28,6 +28,7 @@ export const AccountFieldModal: FC<{ as='h2' htmlString={field.name_emojified} onElement={handleLabelElement} + className={classes.fieldName} /> { } return ( <> - +
diff --git a/app/javascript/mastodon/features/account_timeline/v2/pinned_statuses.tsx b/app/javascript/mastodon/features/account_timeline/v2/pinned_statuses.tsx index 694c107f3af..88503389c96 100644 --- a/app/javascript/mastodon/features/account_timeline/v2/pinned_statuses.tsx +++ b/app/javascript/mastodon/features/account_timeline/v2/pinned_statuses.tsx @@ -18,7 +18,6 @@ import type { StatusHeaderRenderFn } from '@/mastodon/components/status/header'; import { selectTimelineByKey } from '@/mastodon/selectors/timelines'; import { useAppDispatch, useAppSelector } from '@/mastodon/store'; -import { isRedesignEnabled } from '../common'; import { PinnedBadge } from '../components/badges'; import { useAccountContext } from './context'; @@ -88,10 +87,6 @@ export const renderPinnedStatusHeader: StatusHeaderRenderFn = ({ export const PinnedShowAllButton: FC = () => { const { onShowAllPinned } = useAccountContext(); - if (!isRedesignEnabled()) { - return null; - } - return (