Skip to content

Commit

Permalink
Merge pull request #2872 from ClearlyClaire/glitch-soc/merge-upstream
Browse files Browse the repository at this point in the history
Merge upstream changes up to 4238da6
  • Loading branch information
ClearlyClaire authored Oct 7, 2024
2 parents 6967031 + ee17081 commit fd75087
Show file tree
Hide file tree
Showing 103 changed files with 967 additions and 825 deletions.
5 changes: 5 additions & 0 deletions app/controllers/api/v1/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Api::V1::AccountsController < Api::BaseController
before_action :check_account_confirmation, except: [:index, :create]
before_action :check_enabled_registrations, only: [:create]
before_action :check_accounts_limit, only: [:index]
before_action :check_following_self, only: [:follow]

skip_before_action :require_authenticated_user!, only: :create

Expand Down Expand Up @@ -101,6 +102,10 @@ def check_accounts_limit
raise(Mastodon::ValidationError) if account_ids.size > DEFAULT_ACCOUNTS_LIMIT
end

def check_following_self
render json: { error: I18n.t('accounts.self_follow_error') }, status: 403 if current_user.account.id == @account.id
end

def relationships(**options)
AccountRelationshipsPresenter.new([@account], current_user.account_id, **options)
end
Expand Down
25 changes: 20 additions & 5 deletions app/javascript/flavours/glitch/components/avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { useState, useCallback } from 'react';

import classNames from 'classnames';

import { useHovering } from 'flavours/glitch/hooks/useHovering';
import { autoPlayGif } from 'flavours/glitch/initial_state';
import type { Account } from 'flavours/glitch/models/account';

import { useHovering } from '../hooks/useHovering';
import { autoPlayGif } from '../initial_state';

interface Props {
account: Account | undefined; // FIXME: remove `undefined` once we know for sure its always there
size: number;
Expand All @@ -25,6 +26,8 @@ export const Avatar: React.FC<Props> = ({
counterBorderColor,
}) => {
const { hovering, handleMouseEnter, handleMouseLeave } = useHovering(animate);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(false);

const style = {
...styleFromParent,
Expand All @@ -37,17 +40,29 @@ export const Avatar: React.FC<Props> = ({
? account?.get('avatar')
: account?.get('avatar_static');

const handleLoad = useCallback(() => {
setLoading(false);
}, [setLoading]);

const handleError = useCallback(() => {
setError(true);
}, [setError]);

return (
<div
className={classNames('account__avatar', {
'account__avatar-inline': inline,
'account__avatar--inline': inline,
'account__avatar--loading': loading,
})}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
style={style}
data-avatar-of={account && `@${account.get('acct')}`}
>
{src && <img src={src} alt='' />}
{src && !error && (
<img src={src} alt='' onLoad={handleLoad} onError={handleError} />
)}

{counter && (
<div
className='account__avatar__counter'
Expand Down
8 changes: 6 additions & 2 deletions app/javascript/flavours/glitch/styles/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,6 @@ body > [data-popper-placement] {
display: block;
position: relative;
border-radius: var(--avatar-border-radius);
background-color: var(--surface-background-color);

img {
width: 100%;
Expand All @@ -2269,7 +2268,11 @@ body > [data-popper-placement] {
display: inline-block; // to not show broken images
}

&-inline {
&--loading {
background-color: var(--surface-background-color);
}

&--inline {
display: inline-block;
vertical-align: middle;
margin-inline-end: 5px;
Expand Down Expand Up @@ -11172,6 +11175,7 @@ noscript {
gap: 8px;

.logo {
width: 16px;
height: 16px;
color: $darker-text-color;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`<Avatar /> Autoplay renders a animated avatar 1`] = `
<div
className="account__avatar"
className="account__avatar account__avatar--loading"
onMouseEnter={[Function]}
onMouseLeave={[Function]}
style={
Expand All @@ -14,14 +14,16 @@ exports[`<Avatar /> Autoplay renders a animated avatar 1`] = `
>
<img
alt=""
onError={[Function]}
onLoad={[Function]}
src="/animated/alice.gif"
/>
</div>
`;

exports[`<Avatar /> Still renders a still avatar 1`] = `
<div
className="account__avatar"
className="account__avatar account__avatar--loading"
onMouseEnter={[Function]}
onMouseLeave={[Function]}
style={
Expand All @@ -33,6 +35,8 @@ exports[`<Avatar /> Still renders a still avatar 1`] = `
>
<img
alt=""
onError={[Function]}
onLoad={[Function]}
src="/static/alice.jpg"
/>
</div>
Expand Down
25 changes: 20 additions & 5 deletions app/javascript/mastodon/components/avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { useState, useCallback } from 'react';

import classNames from 'classnames';

import { useHovering } from 'mastodon/../hooks/useHovering';
import { autoPlayGif } from 'mastodon/initial_state';
import type { Account } from 'mastodon/models/account';

import { useHovering } from '../../hooks/useHovering';
import { autoPlayGif } from '../initial_state';

interface Props {
account: Account | undefined; // FIXME: remove `undefined` once we know for sure its always there
size: number;
Expand All @@ -25,6 +26,8 @@ export const Avatar: React.FC<Props> = ({
counterBorderColor,
}) => {
const { hovering, handleMouseEnter, handleMouseLeave } = useHovering(animate);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(false);

const style = {
...styleFromParent,
Expand All @@ -37,16 +40,28 @@ export const Avatar: React.FC<Props> = ({
? account?.get('avatar')
: account?.get('avatar_static');

const handleLoad = useCallback(() => {
setLoading(false);
}, [setLoading]);

const handleError = useCallback(() => {
setError(true);
}, [setError]);

return (
<div
className={classNames('account__avatar', {
'account__avatar-inline': inline,
'account__avatar--inline': inline,
'account__avatar--loading': loading,
})}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
style={style}
>
{src && <img src={src} alt='' />}
{src && !error && (
<img src={src} alt='' onLoad={handleLoad} onError={handleError} />
)}

{counter && (
<div
className='account__avatar__counter'
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
"notification.label.private_reply": "Resposta en privat",
"notification.label.reply": "Resposta",
"notification.mention": "Menció",
"notification.mentioned_you": "{name} us ha mencionat",
"notification.moderation-warning.learn_more": "Per a saber-ne més",
"notification.moderation_warning": "Heu rebut un avís de moderació",
"notification.moderation_warning.action_delete_statuses": "S'han eliminat algunes de les vostres publicacions.",
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
"notification.label.private_reply": "Privat svar",
"notification.label.reply": "Besvar",
"notification.mention": "Omtale",
"notification.mentioned_you": "{name} nævnte dig",
"notification.moderation-warning.learn_more": "Læs mere",
"notification.moderation_warning": "Du er tildelt en moderationsadvarsel",
"notification.moderation_warning.action_delete_statuses": "Nogle af dine indlæg er blevet fjernet.",
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/mastodon/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"account.requested_follow": "{name} möchte dir folgen",
"account.share": "Profil von @{name} teilen",
"account.show_reblogs": "Geteilte Beiträge von @{name} anzeigen",
"account.statuses_counter": "{count, plural, one {{counter} Beitrag} other {{counter} Beiträge}}",
"account.statuses_counter": "{count, plural, one {{counter} post} other {{counter} posts}}",
"account.unblock": "Blockierung von @{name} aufheben",
"account.unblock_domain": "Blockierung von {domain} aufheben",
"account.unblock_short": "Blockierung aufheben",
Expand Down Expand Up @@ -516,6 +516,7 @@
"notification.label.private_reply": "Private Antwort",
"notification.label.reply": "Antwort",
"notification.mention": "Erwähnung",
"notification.mentioned_you": "{name} erwähnte dich",
"notification.moderation-warning.learn_more": "Mehr erfahren",
"notification.moderation_warning": "Du wurdest von den Moderator*innen verwarnt",
"notification.moderation_warning.action_delete_statuses": "Einige deiner Beiträge sind entfernt worden.",
Expand Down
5 changes: 5 additions & 0 deletions app/javascript/mastodon/locales/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,11 @@
"upload_error.poll": "File upload not allowed with polls.",
"upload_form.audio_description": "Describe for people who are deaf or hard of hearing",
"upload_form.description": "Describe for people who are blind or have low vision",
"upload_form.drag_and_drop.instructions": "To pick up a media attachment, press space or enter. While dragging, use the arrow keys to move the media attachment in any given direction. Press space or enter again to drop the media attachment in its new position, or press escape to cancel.",
"upload_form.drag_and_drop.on_drag_cancel": "Dragging was cancelled. Media attachment {item} was dropped.",
"upload_form.drag_and_drop.on_drag_end": "Media attachment {item} was dropped.",
"upload_form.drag_and_drop.on_drag_over": "Media attachment {item} was moved.",
"upload_form.drag_and_drop.on_drag_start": "Picked up media attachment {item}.",
"upload_form.edit": "Edit",
"upload_form.thumbnail": "Change thumbnail",
"upload_form.video_description": "Describe for people who are deaf, hard of hearing, blind or have low vision",
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/eo.json
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
"notification.label.private_reply": "Privata respondo",
"notification.label.reply": "Respondi",
"notification.mention": "Mencii",
"notification.mentioned_you": "{name} menciis vin",
"notification.moderation-warning.learn_more": "Lerni pli",
"notification.moderation_warning": "Vi ricevis moderigan averton",
"notification.moderation_warning.action_delete_statuses": "Kelkaj el viaj afiŝoj estis forigitaj.",
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/es-AR.json
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
"notification.label.private_reply": "Respuesta privada",
"notification.label.reply": "Respuesta",
"notification.mention": "Mención",
"notification.mentioned_you": "{name} te mencionó",
"notification.moderation-warning.learn_more": "Aprendé más",
"notification.moderation_warning": "Recibiste una advertencia de moderación",
"notification.moderation_warning.action_delete_statuses": "Se eliminaron algunos de tus mensajes.",
Expand Down
11 changes: 6 additions & 5 deletions app/javascript/mastodon/locales/es-MX.json
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
"notification.label.private_reply": "Respuesta privada",
"notification.label.reply": "Respuesta",
"notification.mention": "Mención",
"notification.mentioned_you": "{name} te ha mencionado",
"notification.moderation-warning.learn_more": "Saber más",
"notification.moderation_warning": "Has recibido una advertencia de moderación",
"notification.moderation_warning.action_delete_statuses": "Se han eliminado algunas de tus publicaciones.",
Expand Down Expand Up @@ -852,11 +853,11 @@
"upload_error.poll": "Subida de archivos no permitida con encuestas.",
"upload_form.audio_description": "Describir para personas con problemas auditivos",
"upload_form.description": "Describir para los usuarios con dificultad visual",
"upload_form.drag_and_drop.instructions": "Para recoger un archivo multimedia, pulsa la barra espaciadora o la tecla Enter. Mientras arrastras, utiliza las teclas de flecha para mover el archivo multimedia en cualquier dirección. Vuelve a pulsar la barra espaciadora o la tecla Enter para soltar el archivo multimedia en su nueva posición, o pulsa Escape para cancelar.",
"upload_form.drag_and_drop.on_drag_cancel": "Se canceló el arrastre. Se eliminó el archivo adjunto {item}.",
"upload_form.drag_and_drop.on_drag_end": "El archivo adjunto {item} ha sido eliminado.",
"upload_form.drag_and_drop.on_drag_over": "El archivo adjunto {item} se ha movido.",
"upload_form.drag_and_drop.on_drag_start": "Se ha recogido el archivo adjunto {item}.",
"upload_form.drag_and_drop.instructions": "Para recoger un archivo adjunto, pulsa la barra espaciadora o la tecla Intro. Mientras arrastras, usa las teclas de flecha para mover el archivo adjunto en cualquier dirección. Vuelve a pulsar la barra espaciadora o la tecla Intro para soltar el archivo adjunto en su nueva posición, o pulsa la tecla Escape para cancelar.",
"upload_form.drag_and_drop.on_drag_cancel": "Arrastre cancelado. El archivo adjunto {item} fue eliminado.",
"upload_form.drag_and_drop.on_drag_end": "El archivo adjunto {item} fue eliminado.",
"upload_form.drag_and_drop.on_drag_over": "El archivo adjunto {item} fue movido.",
"upload_form.drag_and_drop.on_drag_start": "Recogidos los archivos adjuntos {item}.",
"upload_form.edit": "Editar",
"upload_form.thumbnail": "Cambiar miniatura",
"upload_form.video_description": "Describir para personas con problemas auditivos o visuales",
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
"notification.label.private_reply": "Respuesta privada",
"notification.label.reply": "Respuesta",
"notification.mention": "Mención",
"notification.mentioned_you": "{name} te ha mencionado",
"notification.moderation-warning.learn_more": "Saber más",
"notification.moderation_warning": "Has recibido una advertencia de moderación",
"notification.moderation_warning.action_delete_statuses": "Se han eliminado algunas de tus publicaciones.",
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
"notification.label.private_reply": "Yksityinen vastaus",
"notification.label.reply": "Vastaus",
"notification.mention": "Maininta",
"notification.mentioned_you": "{name} mainitsi sinut",
"notification.moderation-warning.learn_more": "Lue lisää",
"notification.moderation_warning": "Olet saanut moderointivaroituksen",
"notification.moderation_warning.action_delete_statuses": "Julkaisujasi on poistettu.",
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/fo.json
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
"notification.label.private_reply": "Privat svar",
"notification.label.reply": "Svara",
"notification.mention": "Umrøð",
"notification.mentioned_you": "{name} nevndi teg",
"notification.moderation-warning.learn_more": "Lær meira",
"notification.moderation_warning": "Tú hevur móttikið eina umsjónarávaring",
"notification.moderation_warning.action_delete_statuses": "Onkrir av tínum postum eru strikaðir.",
Expand Down
15 changes: 15 additions & 0 deletions app/javascript/mastodon/locales/fy.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"alert.rate_limited.title": "Dataferkear beheind",
"alert.unexpected.message": "Der is in ûnferwachte flater bard.",
"alert.unexpected.title": "Oepsy!",
"alt_text_badge.title": "Alternative tekst",
"announcement.announcement": "Oankundiging",
"attachments_list.unprocessed": "(net ferwurke)",
"audio.hide": "Audio ferstopje",
Expand Down Expand Up @@ -221,6 +222,8 @@
"domain_block_modal.they_cant_follow": "Net ien op dizze server kin jo folgje.",
"domain_block_modal.they_wont_know": "Se krije net te witten dat se blokkearre wurde.",
"domain_block_modal.title": "Domein blokkearje?",
"domain_block_modal.you_will_lose_num_followers": "Jo ferlieze {followersCount, plural, one {{followersCountDisplay} folger} other {{followersCountDisplay} folgers}} en {followingCount, plural, one {{followingCountDisplay} persoan dy’t jo folgje} other {{followingCountDisplay} persoanen dy’t jo folgje}}.",
"domain_block_modal.you_will_lose_relationships": "Jo ferlieze alle folgers en minsken dy’t jo folgje fan dizze server.",
"domain_block_modal.you_wont_see_posts": "Jo sjogge gjin berjochten of meldingen mear fan brûkers op dizze server.",
"domain_pill.activitypub_lets_connect": "It soarget derfoar dat jo net allinnich mar ferbine en kommunisearje kinne mei minsken op Mastodon, mar ek mei oare sosjale apps.",
"domain_pill.activitypub_like_language": "ActivityPub is de taal dy’t Mastodon mei oare sosjale netwurken sprekt.",
Expand Down Expand Up @@ -433,6 +436,8 @@
"lightbox.close": "Slute",
"lightbox.next": "Folgjende",
"lightbox.previous": "Foarige",
"lightbox.zoom_in": "Oarspronklike grutte toane",
"lightbox.zoom_out": "Passend toane",
"limited_account_hint.action": "Profyl dochs besjen",
"limited_account_hint.title": "Dit profyl is troch de behearders fan {domain} ferstoppe.",
"link_preview.author": "Troch {name}",
Expand All @@ -454,6 +459,7 @@
"lists.subheading": "Jo listen",
"load_pending": "{count, plural, one {# nij item} other {# nije items}}",
"loading_indicator.label": "Lade…",
"media_gallery.hide": "Ferstopje",
"moved_to_account_banner.text": "Omdat jo nei {movedToAccount} ferhuze binne is jo account {disabledAccount} op dit stuit útskeakele.",
"mute_modal.hide_from_notifications": "Meldingen ferstopje",
"mute_modal.hide_options": "Opsjes ferstopje",
Expand Down Expand Up @@ -510,6 +516,7 @@
"notification.label.private_reply": "Priveereaksje",
"notification.label.reply": "Beäntwurdzje",
"notification.mention": "Fermelding",
"notification.mentioned_you": "{name} hat dy fermeld",
"notification.moderation-warning.learn_more": "Mear ynfo",
"notification.moderation_warning": "Jo hawwe in moderaasje-warskôging ûntfongen",
"notification.moderation_warning.action_delete_statuses": "Guon fan jo berjochten binne fuortsmiten.",
Expand Down Expand Up @@ -774,6 +781,7 @@
"status.bookmark": "Blêdwizer tafoegje",
"status.cancel_reblog_private": "Net langer booste",
"status.cannot_reblog": "Dit berjocht kin net boost wurde",
"status.continued_thread": "Ferfolgje it petear",
"status.copy": "Copy link to status",
"status.delete": "Fuortsmite",
"status.detailed_status": "Detaillearre petearoersjoch",
Expand All @@ -782,6 +790,7 @@
"status.edit": "Bewurkje",
"status.edited": "Lêst bywurke op {date}",
"status.edited_x_times": "{count, plural, one {{count} kear} other {{count} kearen}} bewurke",
"status.embed": "Koade om op te nimmen",
"status.favourite": "Favoryt",
"status.favourites": "{count, plural, one {favoryt} other {favoriten}}",
"status.filter": "Dit berjocht filterje",
Expand All @@ -806,6 +815,7 @@
"status.reblogs.empty": "Net ien hat dit berjocht noch boost. Wannear’t ien dit docht, falt dat hjir te sjen.",
"status.redraft": "Fuortsmite en opnij opstelle",
"status.remove_bookmark": "Blêdwizer fuortsmite",
"status.replied_in_thread": "Antwurde yn petear",
"status.replied_to": "Antwurde op {name}",
"status.reply": "Beäntwurdzje",
"status.replyAll": "Alle beäntwurdzje",
Expand Down Expand Up @@ -843,6 +853,11 @@
"upload_error.poll": "It opladen fan bestannen is yn enkêten net tastien.",
"upload_form.audio_description": "Describe for people with hearing loss",
"upload_form.description": "Describe for the visually impaired",
"upload_form.drag_and_drop.instructions": "Druk op spaasje of Enter om in mediabylage op te pakken. Bruk de pylktoetsen om de bylage yn in bepaalde rjochting te ferpleatsen. Druk opnij op de spaasjebalke of Enter om de mediabylage op de nije posysje te pleatsen, of druk op Esc om te annulearjen.",
"upload_form.drag_and_drop.on_drag_cancel": "Slepen is annulearre. Mediabylage {item} is net ferpleatst.",
"upload_form.drag_and_drop.on_drag_end": "Mediabylage {item} is net ferpleatst.",
"upload_form.drag_and_drop.on_drag_over": "Mediabylage {item} is ferpleatst.",
"upload_form.drag_and_drop.on_drag_start": "Mediabylage {item} is oppakt.",
"upload_form.edit": "Bewurkje",
"upload_form.thumbnail": "Miniatuerôfbylding wizigje",
"upload_form.video_description": "Describe for people with hearing loss or visual impairment",
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/gl.json
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
"notification.label.private_reply": "Resposta privada",
"notification.label.reply": "Resposta",
"notification.mention": "Mención",
"notification.mentioned_you": "{name} mencionoute",
"notification.moderation-warning.learn_more": "Saber máis",
"notification.moderation_warning": "Recibiches unha advertencia da moderación",
"notification.moderation_warning.action_delete_statuses": "Algunha das túas publicacións foron eliminadas.",
Expand Down
Loading

0 comments on commit fd75087

Please sign in to comment.